Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ ignore_errors = false # boolean [true or false],
sampling_rate = 0.1 # decimal rate between 0.0 - 1.0
otel_exporter_otlp_endpoint = "http://localhost:4317" # endpoint to send metrics and traces to, can include port number
otel_exporter_otlp_timeout = 5000 # timeout (in milliseconds) for sending metrics and traces
use_xray_generator = false # Set this to true for AWS X-ray compatible traces

# This section provides some secret values.
[secrets]
Expand Down
1 change: 1 addition & 0 deletions config/development.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ log_format = "default"
[log.telemetry]
traces_enabled = false
metrics_enabled = false
use_xray_generator = false

# TODO: Update database credentials before running application
[master_database]
Expand Down
1 change: 1 addition & 0 deletions config/docker_compose.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ traces_enabled = false # Whether traces are
metrics_enabled = false # Whether metrics are enabled.
ignore_errors = false # Whether to ignore errors during traces or metrics pipeline setup.
otel_exporter_otlp_endpoint = "https://otel-collector:4317" # Endpoint to send metrics and traces to.
use_xray_generator = false

[master_database]
username = "db_user"
Expand Down
2 changes: 2 additions & 0 deletions crates/router_env/src/logger/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion crates/router_env/src/logger/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,17 @@ 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),
))
.with_resource(Resource::new(vec![KeyValue::new(
"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))
Expand Down