Skip to content

Commit

Permalink
[opentelemetry-otlp] basic-otlp-http example - trivial cleanup (#1878)
Browse files Browse the repository at this point in the history
Co-authored-by: Cijo Thomas <[email protected]>
  • Loading branch information
markdingram and cijothomas committed Jun 13, 2024
1 parent 64aa506 commit 66e3ea5
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions opentelemetry-otlp/examples/basic-otlp-http/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,15 @@ fn init_tracer_provider() -> Result<sdktrace::TracerProvider, TraceError> {
}

fn init_metrics() -> Result<opentelemetry_sdk::metrics::SdkMeterProvider, MetricsError> {
let provider = opentelemetry_otlp::new_pipeline()
opentelemetry_otlp::new_pipeline()
.metrics(opentelemetry_sdk::runtime::Tokio)
.with_exporter(
opentelemetry_otlp::new_exporter()
.http()
.with_endpoint("http://localhost:4318/v1/metrics"),
)
.with_resource(RESOURCE.clone())
.build();
match provider {
Ok(provider) => Ok(provider),
Err(err) => Err(err),
}
.build()
}

#[tokio::main]
Expand All @@ -85,6 +81,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
);

let meter_provider = result.unwrap();
global::set_meter_provider(meter_provider.clone());

// Opentelemetry will not provide a global API to manage the logger
// provider. Application users must manage the lifecycle of the logger
Expand Down

0 comments on commit 66e3ea5

Please sign in to comment.