Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gateway: config open telemetry propagator #6648

Merged
merged 1 commit into from
Feb 15, 2024
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
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
Loading