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 1 commit
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
99 changes: 82 additions & 17 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
6 changes: 3 additions & 3 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 @@ -24,7 +24,7 @@ tracing = { version = "=0.1.36" }
tracing-actix-web = { version = "0.7.4", features = ["opentelemetry_0_18"], optional = true }
ashokkjag marked this conversation as resolved.
Show resolved Hide resolved
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
16 changes: 10 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.69
ashokkjag marked this conversation as resolved.
Show resolved Hide resolved
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.69
command: cargo build --bin router
working_dir: /app
networks:
Expand All @@ -104,8 +104,9 @@ services:
- cargo_build_cache:/cargo_build_cache
environment:
- CARGO_TARGET_DIR=/cargo_build_cache
- CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
hyperswitch-server:
image: rust:1.65
image: rust:1.69
command: /cargo_build_cache/debug/router -f ./config/docker_compose.toml
working_dir: /app
ports:
Expand All @@ -132,7 +133,7 @@ services:
condition: service_completed_successfully

hyperswitch-producer:
image: rust:1.65
image: rust:1.69
command: cargo run --bin scheduler -- -f ./config/docker_compose.toml
working_dir: /app
networks:
Expand All @@ -146,14 +147,15 @@ services:
environment:
- CARGO_TARGET_DIR=/cargo_build_cache
- SCHEDULER_FLOW=producer
- CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
depends_on:
hyperswitch-consumer:
condition: service_healthy
labels:
logs: "promtail"

hyperswitch-consumer:
image: rust:1.65
image: rust:1.69
command: cargo run --bin scheduler -- -f ./config/docker_compose.toml
working_dir: /app
networks:
Expand All @@ -167,6 +169,7 @@ services:
environment:
- CARGO_TARGET_DIR=/cargo_build_cache
- SCHEDULER_FLOW=consumer
- CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
depends_on:
hyperswitch-server:
condition: service_started
Expand Down Expand Up @@ -270,7 +273,7 @@ services:
- "4317" # otlp grpc
restart: unless-stopped
hyperswitch-drainer:
image: rust:1.65
image: rust:1.69
command: cargo run --bin drainer -- -f ./config/docker_compose.toml
working_dir: /app
deploy:
Expand All @@ -285,6 +288,7 @@ services:
- cargo_build_cache:/cargo_build_cache
environment:
- CARGO_TARGET_DIR=/cargo_build_cache
- CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
restart: unless-stopped
depends_on:
hyperswitch-server:
Expand Down