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(interactive): add metadata for rust otel exporting #3811

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions interactive_engine/executor/engine/pegasus/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "pegasus_server"
version = "0.1.0"
authors = ["chenqiang.mcq <[email protected]>"]
edition = "2018"
edition = "2021"

[dependencies]
pegasus_common = { path = "../common" }
Expand All @@ -12,8 +12,8 @@ pegasus = { path = "../pegasus" }
log = "0.4"
crossbeam-utils = "0.8.14"
#crossbeam-channel = "0.5.6"
tonic = "0.8"
prost = "0.11"
tonic = "0.11"
prost = "0.12"
tokio = { version = "1.24", features = ["macros", "sync", "rt-multi-thread"] }
tokio-stream = "0.1.11"
toml = "0.5"
Expand All @@ -30,7 +30,7 @@ opentelemetry-otlp = { version = "0.15.0", features = ["trace", "metrics", "grpc
structopt = "0.3"

[build-dependencies]
tonic-build = "0.8"
tonic-build = "0.11"

[features]
default = []
Expand Down
24 changes: 12 additions & 12 deletions interactive_engine/executor/engine/pegasus/server/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,14 @@ fn init_otel() -> Result<bool, Box<dyn std::error::Error>> {
return Ok(true);
}

// let mut metadata = tonic::metadata::MetadataMap::with_capacity(1);
// let dsn = std::env::var("UPTRACE_DSN").unwrap_or_default();
// if !dsn.is_empty() {
// metadata.insert("uptrace-dsn", dsn.parse().unwrap());
// info!("using DSN: {}", dsn);
// } else {
// warn!("Error: UPTRACE_DSN not found.");
// }
let mut metadata = tonic::metadata::MetadataMap::with_capacity(1);
let dsn = std::env::var("UPTRACE_DSN").unwrap_or_default();
if !dsn.is_empty() {
metadata.insert("uptrace-dsn", dsn.parse().unwrap());
info!("using DSN: {}", dsn);
} else {
warn!("Error: UPTRACE_DSN not found.");
}

let default_endpoint = "http://localhost:4317".to_string();
let endpoint = std::env::var("OTEL_EXPORTER_OTLP_ENDPOINT").unwrap_or(default_endpoint);
Expand All @@ -416,15 +416,15 @@ fn init_otel() -> Result<bool, Box<dyn std::error::Error>> {
let exporter = opentelemetry_otlp::new_exporter()
.tonic()
.with_timeout(Duration::from_secs(5))
.with_endpoint(endpoint.clone());
// .with_metadata(metadata.clone());
.with_endpoint(endpoint.clone())
.with_metadata(metadata.clone());
let _tracer = init_tracer(resource.clone(), exporter)?;

let exporter = opentelemetry_otlp::new_exporter()
.tonic()
.with_timeout(Duration::from_secs(5))
.with_endpoint(endpoint);
// .with_metadata(metadata);
.with_endpoint(endpoint)
.with_metadata(metadata);

let _meter = init_meter_provider(resource, exporter)?;
global::set_meter_provider(_meter);
Expand Down
Loading