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

fix(logging): fix traces export through opentelemetry #1355

Merged
merged 2 commits into from
Jun 6, 2023
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
31 changes: 18 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ members = ["crates/*", "examples/*"]
strip = true
lto = true
codegen-units = 1

[patch.crates-io]
opentelemetry = { git = "https://github.com/open-telemetry/opentelemetry-rust", rev = "44b90202fd744598db8b0ace5b8f0bad7ec45658" }
1 change: 1 addition & 0 deletions config/docker_compose.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pool_size = 5
[secrets]
admin_api_key = "test_admin"
jwt_secret = "secret"
master_enc_key = "73ad7bbbbc640c845a150f67d058b279849370cd2c1f3c67c4dd6c869213e13a"

[locker]
host = ""
Expand Down
8 changes: 4 additions & 4 deletions crates/router_env/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ license = "Apache-2.0"
config = { version = "0.13.3", features = ["toml"] }
gethostname = "0.4.2"
once_cell = "1.17.1"
opentelemetry = { git = "https://github.com/open-telemetry/opentelemetry-rust/", rev = "44b90202fd744598db8b0ace5b8f0bad7ec45658", features = ["rt-tokio-current-thread", "metrics"] }
opentelemetry-otlp = { git = "https://github.com/open-telemetry/opentelemetry-rust/", rev = "44b90202fd744598db8b0ace5b8f0bad7ec45658", features = ["metrics"] }
opentelemetry = { version = "0.19.0", features = ["rt-tokio-current-thread", "metrics"] }
opentelemetry-otlp = { version = "0.12.0", features = ["metrics"] }
rustc-hash = "1.1"
serde = { version = "1.0.160", features = ["derive"] }
serde_json = "1.0.96"
Expand All @@ -21,10 +21,10 @@ strum = { version = "0.24.1", features = ["derive"] }
time = { version = "0.3.20", default-features = false, features = ["formatting"] }
tokio = { version = "1.27.0" }
tracing = { version = "=0.1.36" }
tracing-actix-web = { version = "0.7.4", features = ["opentelemetry_0_18"], optional = true }
tracing-actix-web = { version = "0.7.4", features = ["opentelemetry_0_19"], optional = true }
tracing-appender = { version = "0.2.2" }
tracing-attributes = "=0.1.22"
tracing-opentelemetry = { version = "0.18.0" }
tracing-opentelemetry = { version = "0.19.0" }
tracing-subscriber = { version = "0.3.16", default-features = true, features = ["env-filter", "json", "registry"] }
vergen = { version = "8.1.1", optional = true, features = ["cargo", "git", "git2", "rustc"] }

Expand Down
11 changes: 9 additions & 2 deletions crates/router_env/src/logger/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use opentelemetry::{
export::metrics::aggregation::cumulative_temporality_selector,
metrics::{controllers::BasicController, selectors::simple},
propagation::TraceContextPropagator,
trace, Resource,
trace,
trace::BatchConfig,
Resource,
},
KeyValue,
};
Expand Down Expand Up @@ -145,11 +147,16 @@ fn setup_tracing_pipeline(
if config.use_xray_generator {
trace_config = trace_config.with_id_generator(trace::XrayIdGenerator::default());
}

// Change the default export interval from 5 seconds to 1 second
let batch_config = BatchConfig::default().with_scheduled_delay(Duration::from_millis(1000));

let traces_layer_result = opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(get_opentelemetry_exporter(config))
.with_batch_config(batch_config)
.with_trace_config(trace_config)
.install_simple()
.install_batch(opentelemetry::runtime::TokioCurrentThread)
.map(|tracer| tracing_opentelemetry::layer().with_tracer(tracer));

if config.ignore_errors {
Expand Down
12 changes: 6 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ services:
- POSTGRES_DB=hyperswitch_db

migration_runner:
image: rust:1.65
image: rust:1.70
command: "bash -c 'cargo install diesel_cli --no-default-features --features \"postgres\" && diesel migration --database-url postgres://db_user:db_pass@pg:5432/hyperswitch_db run'"
working_dir: /app
networks:
Expand All @@ -93,7 +93,7 @@ services:
- ./:/app

hyperswitch-server-init:
image: rust:1.65
image: rust:1.70
command: cargo build --bin router
working_dir: /app
networks:
Expand All @@ -105,7 +105,7 @@ services:
environment:
- CARGO_TARGET_DIR=/cargo_build_cache
hyperswitch-server:
image: rust:1.65
image: rust:1.70
command: /cargo_build_cache/debug/router -f ./config/docker_compose.toml
working_dir: /app
ports:
Expand All @@ -132,7 +132,7 @@ services:
condition: service_completed_successfully

hyperswitch-producer:
image: rust:1.65
image: rust:1.70
command: cargo run --bin scheduler -- -f ./config/docker_compose.toml
working_dir: /app
networks:
Expand All @@ -153,7 +153,7 @@ services:
logs: "promtail"

hyperswitch-consumer:
image: rust:1.65
image: rust:1.70
command: cargo run --bin scheduler -- -f ./config/docker_compose.toml
working_dir: /app
networks:
Expand Down Expand Up @@ -270,7 +270,7 @@ services:
- "4317" # otlp grpc
restart: unless-stopped
hyperswitch-drainer:
image: rust:1.65
image: rust:1.70
command: cargo run --bin drainer -- -f ./config/docker_compose.toml
working_dir: /app
deploy:
Expand Down