chore: remove otlp logging
All checks were successful
ci/woodpecker/push/ci Pipeline was successful

Let's stick with traces and metrics for now?
This commit is contained in:
Daniel Lundin 2024-11-30 01:07:13 +01:00
parent a4b5f734cb
commit dcd9970b3b
Signed by: dln
SSH key fingerprint: SHA256:dQy1Xj3UiqJYpKR5ggQ2bxgz4jCH8IF+k3AB8o0kmdI

View file

@ -1,9 +1,7 @@
use anyhow::{anyhow, Result};
use once_cell::sync::Lazy;
use opentelemetry::{trace::TracerProvider as _, KeyValue};
use opentelemetry_appender_tracing::layer::OpenTelemetryTracingBridge;
use opentelemetry_sdk::{
logs::LoggerProvider,
metrics::{MeterProviderBuilder, PeriodicReader, SdkMeterProvider},
runtime,
trace::{RandomIdGenerator, Sampler, TracerProvider},
@ -26,18 +24,6 @@ static RESOURCE: Lazy<Resource> = Lazy::new(|| {
])
});
// Construct LoggingProdiver for LoggingLayer
fn init_logging_provider() -> Result<LoggerProvider> {
let exporter = opentelemetry_otlp::LogExporter::builder()
.with_tonic()
.build()?;
let logging_provider: LoggerProvider = LoggerProvider::builder()
.with_resource(RESOURCE.clone())
.with_batch_exporter(exporter, runtime::Tokio)
.build();
Ok(logging_provider)
}
// Construct MeterProvider for MetricsLayer
fn init_meter_provider() -> Result<SdkMeterProvider> {
let exporter = opentelemetry_otlp::MetricExporter::builder()
@ -81,7 +67,6 @@ fn init_tracer_provider() -> Result<TracerProvider> {
// Initialize tracing-subscriber and return OtelGuard for opentelemetry-related termination processing
pub fn init_tracing_subscriber() -> Result<OtelGuard> {
let logging_provider = init_logging_provider()?;
let meter_provider = init_meter_provider()?;
let tracer_provider = init_tracer_provider()?;
@ -92,18 +77,15 @@ pub fn init_tracing_subscriber() -> Result<OtelGuard> {
.with(tracing_subscriber::fmt::layer())
.with(MetricsLayer::new(meter_provider.clone()))
.with(OpenTelemetryLayer::new(tracer))
.with(OpenTelemetryTracingBridge::new(&logging_provider))
.init();
Ok(OtelGuard {
logging_provider,
meter_provider,
tracer_provider,
})
}
pub struct OtelGuard {
logging_provider: LoggerProvider,
meter_provider: SdkMeterProvider,
tracer_provider: TracerProvider,
}
@ -113,9 +95,6 @@ impl Drop for OtelGuard {
if let Err(err) = self.tracer_provider.shutdown() {
eprintln!("{err:?}");
}
if let Err(err) = self.logging_provider.shutdown() {
eprintln!("{err:?}");
}
if let Err(err) = self.meter_provider.shutdown() {
eprintln!("{err:?}");
}