OpenTelemetry support for Google Cloud Trace
Quick start
Cargo.toml:
[]
= "0.21"
Crypto provider error
Depends on your other dependencies you may see the error like:
no process-level CryptoProvider available -- call CryptoProvider::install_default() before this point
This is because the TLS providers are not installed by default and you can choose different. The easiest way to fix is just to include one of the provider, for example:
[]
= "0.23"
If you have multiple you may need to call CryptoProvider::install_default() before using the Firestore client.
default_provider.install_default.expect;
Compatibility matrix
| opentelemetry-gcloud-trace version | opentelemetry version | tracing-opentelemetry | gcloud-sdk |
|---|---|---|---|
| 0.21 | 0.30 | 0.31 | 0.28 |
| 0.20 | 0.30 | 0.31 | 0.27 |
| 0.19 | 0.29 | 0.30 | 0.27 |
| 0.18 | 0.28 | 0.29 | 0.26 |
Example:
let gcp_trace_exporter = for_default_project_id.await?; // or GcpCloudTraceExporterBuilder::new(config_env_var("PROJECT_ID")?)
let tracer_provider = gcp_trace_exporter.create_provider.await?;
let tracer: Tracer = gcp_trace_exporter.install.await?;
set_tracer_provider;
tracer.in_span;
tracer_provider.shutdown?;
All examples are available at examples directory.
To run an example use with environment variables:
# PROJECT_ID=<your-google-project-id> cargo run --example enable-exporter

[]
= { = "*", = [] }
= { = "*", = ["rt-tokio"] }
= "*"
Crypto provider error
Depends on your other dependencies you may see the error like:
no process-level CryptoProvider available -- call CryptoProvider::install_default() before this point
This is because the TLS providers are not installed by default and you can choose different. The easiest way to fix is just to include one of the provider, for example:
[]
= "0.23"
If you have multiple you may need to call CryptoProvider::install_default() before using the Firestore client.
default_provider.install_default.expect;
Configuration
You can specify trace configuration using with_tracer_provider_builder:
let exporter = new;
let provider = exporter.create_provider_from_builder );
Limitations
- This exporter doesn't support any other runtimes except Tokio.
Integration with logs
This crate intentionally doesn't export logs using API to avoid duplicate logs on GKE/GCE environments.
You can use this crate in combination with tracing-stackdriver crate to produce
JSON formatted logs and logs and traces will be correlated by trace_id and span_id
fields automatically.
This is an example of this kind of configuration:
async
async
TLS related features
Cargo provides support for different TLS features for dependencies:
tls-roots: default feature to support native TLS rootstls-webpki-roots: feature to switch to webpki crate roots
Licence
Apache Software License (ASL)
Author
Abdulla Abdurakhmanov