feat(traces): add support for aws xray (#1194)

This commit is contained in:
Sampras Lopes
2023-05-18 23:04:29 +05:30
committed by GitHub
parent b3fd174d04
commit 8947e1c9db
5 changed files with 9 additions and 1 deletions

View File

@ -99,6 +99,8 @@ pub struct LogTelemetry {
pub otel_exporter_otlp_endpoint: Option<String>,
/// Timeout (in milliseconds) for sending metrics and traces.
pub otel_exporter_otlp_timeout: Option<u64>,
/// Whether to use xray ID generator, (enable this if you plan to use AWS-XRAY)
pub use_xray_generator: bool,
}
/// Telemetry / tracing.

View File

@ -134,7 +134,7 @@ fn setup_tracing_pipeline(
{
global::set_text_map_propagator(TraceContextPropagator::new());
let trace_config = trace::config()
let mut trace_config = trace::config()
.with_sampler(trace::Sampler::TraceIdRatioBased(
config.sampling_rate.unwrap_or(1.0),
))
@ -142,6 +142,9 @@ fn setup_tracing_pipeline(
"service.name",
service_name,
)]));
if config.use_xray_generator {
trace_config = trace_config.with_id_generator(trace::XrayIdGenerator::default());
}
let traces_layer_result = opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(get_opentelemetry_exporter(config))