Skip to content
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
1 change: 1 addition & 0 deletions docker-compose-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ services:
condition: service_healthy
environment:
MONGODB_URI: mongodb://review-db:27017
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector:4318"
review-db:
image: mongo
volumes:
Expand Down
9 changes: 8 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,16 @@ static RESOURCE: Lazy<Resource> = Lazy::new(|| {

/// Initializes OpenTelemetry metrics exporter and sets the global meter provider.
fn init_otlp() -> HttpMetricsLayer {
let otlp_url = match env::var_os("OTEL_EXPORTER_OTLP_ENDPOINT") {
Some(uri) => uri.into_string().unwrap(),
None => "http://localhost:4318".to_string(),
};

let otlp_endpoint = format!("{}/v1/metrics", otlp_url.trim_end_matches('/'));

let exporter = opentelemetry_otlp::MetricExporter::builder()
.with_http()
.with_endpoint("http://otel-collector:4318/v1/metrics")
.with_endpoint(otlp_endpoint)
.with_temporality(Temporality::default())
.build()
.unwrap();
Expand Down
Loading