Skip to content

Fixes telemetry via http #191

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

Merged
merged 1 commit into from
Mar 18, 2025
Merged
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
21 changes: 16 additions & 5 deletions scope/src/shared/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use opentelemetry_sdk::{
trace::{RandomIdGenerator, Sampler, TracerProvider},
Resource,
};
use url::Url;

use std::env;
use std::fs::File;
Expand Down Expand Up @@ -222,11 +223,21 @@ impl LoggingOpts {
.with_timeout(*timeout)
.with_metadata(metadata_map.clone())
.build(),
OtelProtocol::Http => SpanExporter::builder()
.with_http()
.with_endpoint(endpoint)
.with_timeout(*timeout)
.build(),
OtelProtocol::Http => {
// with_endpoint() is _roughly_ equivalent to using the OTEL_EXPORTER_OTLP_TRACES_ENDPOINT env var
// So we have to append the `v1/traces` to the base URL when using http
// https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/#otel_exporter_otlp_traces_endpoint
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#endpoint-urls-for-otlphttp
let url = Url::parse(endpoint)
.expect("Expected a valid URI")
.join("v1/traces")
.unwrap();
SpanExporter::builder()
.with_http()
.with_endpoint(url)
.with_timeout(*timeout)
.build()
}
};

let tracer = TracerProvider::builder()
Expand Down
Loading