6 releases (3 breaking)
0.4.2 | Feb 4, 2023 |
---|---|
0.4.1 | Oct 8, 2022 |
0.3.0 | Sep 19, 2022 |
0.2.0 | Jul 31, 2022 |
0.1.0 | Jul 23, 2022 |
#624 in Web programming
1,917 downloads per month
24KB
381 lines
OpenTelemetry support for Google Cloud Trace
Quick start
Cargo.toml:
[dependencies]
opentelemetry-gcloud-trace = "0.4"
Compatibility matrix
opentelemetry-gcloud-trace version | opentelemetry version | tracing-opentelemetry | gcloud-sdk |
---|---|---|---|
0.4 | 0.18 | 0.18 | 0.19 |
0.3 | 0.18 | 0.18 | 0.18 |
0.2 | 0.17 | 0.17 | 0.18 |
Example code:
use opentelemetry::KeyValue;
use opentelemetry::trace::*;
use opentelemetry_gcloud_trace::*;
let tracer: opentelemetry::sdk::trace::Tracer =
GcpCloudTraceExporterBuilder::for_default_project_id().await? // or GcpCloudTraceExporterBuilder::new(config_env_var("PROJECT_ID")?)
.install_simple() // use install_batch for production/performance reasons
.await?;
tracer.in_span("doing_work_parent", |cx| {
// ...
});
All examples available at examples directory.
To run example use with environment variables:
# PROJECT_ID=<your-google-project-id> cargo run --example enable-exporter
Performance
For optimal performance, a batch exporter is recommended as the simple exporter will export
each span synchronously on drop. You can enable the [rt-tokio
], [rt-tokio-current-thread
]
features and specify a runtime on the pipeline to have a batch exporter
configured for you automatically.
[dependencies]
opentelemetry = { version = "*", features = ["rt-tokio"] }
opentelemetry-gcloud-trace = "*"
let tracer: opentelemetry::sdk::trace::Tracer =
GcpCloudTraceExporterBuilder::for_default_project_id().await? // or GcpCloudTraceExporterBuilder::new(config_env_var("PROJECT_ID")?)
.install_batch(
opentelemetry::runtime::Tokio
)
.await?;
Configuration
You can specify trace configuration using with_trace_config
:
GcpCloudTraceExporterBuilder::new(google_project_id).with_trace_config(
trace::config()
.with_sampler(Sampler::AlwaysOn)
.with_id_generator(RandomIdGenerator::default())
)
Limitations
- This exporter doesn't support any other runtimes except Tokio.
Licence
Apache Software License (ASL)
Author
Abdulla Abdurakhmanov
Dependencies
~76–110MB
~2M SLoC