Skip to content

Commit

Permalink
gateway: config open telemetry propagator
Browse files Browse the repository at this point in the history
  • Loading branch information
Wadjetz committed Feb 15, 2024
1 parent 5e1c2a3 commit e9399c4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docker/gateway.dev.simple.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ listen_addr = "0.0.0.0"

[telemetry.tracing]
enable = true
type = "Otlp"
service_name = "gateway"
endpoint = "http://osrd-jaeger:4317"

[[targets]]
Expand Down
9 changes: 9 additions & 0 deletions gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,12 @@ user_id = "example-user-id"
# It's used for testing.
require_login = true
```

# Enable open telemetry
```toml
[telemetry.tracing]
endpoint = "http://localhost:4317"
type = "Otlp"
enable = true
service_name = "gateway"
```
6 changes: 6 additions & 0 deletions gateway/gateway.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
# python3 -c "import secrets, base64; print(base64.standard_b64encode(secrets.token_bytes(64)).decode())"
secret_key = "NOT+A+SECRET++NOT+A+SECRET++NOT+A+SECRET++NOT+A+SECRET++NOT+A+SECRET++NOT+A+SECRET++NOT+A+SECRET"

[telemetry.tracing]
type = "Otlp"
enable = true
service_name = "gateway"
endpoint = "http://localhost::4317"

[[targets]]
prefix = "/api"
upstream = "http://localhost:8090"
Expand Down
5 changes: 4 additions & 1 deletion gateway/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use figment::{
use log::info;
use opentelemetry::global;
use opentelemetry_otlp::WithExportConfig;
use opentelemetry_sdk::{runtime::TokioCurrentThread, trace::TracerProvider};
use opentelemetry_sdk::{
propagation::TraceContextPropagator, runtime::TokioCurrentThread, trace::TracerProvider,
};
use serde::{Deserialize, Serialize};

#[derive(Deserialize, Serialize, Clone)]
Expand Down Expand Up @@ -63,6 +65,7 @@ impl TracingTelemetry {
.with_batch_exporter(exporter, TokioCurrentThread)
.build();

global::set_text_map_propagator(TraceContextPropagator::new());
global::set_tracer_provider(provider);
}

Expand Down

0 comments on commit e9399c4

Please sign in to comment.