pub(super) fn tracing_layer<S>(
        &self,
    ) -> Option<(opentelemetry_sdk::trace::TracerProvider, impl Layer<S>)>
    where
        S: tracing::Subscriber + for<'span> LookupSpan<'span> + Send + Sync,
    {
        let tracing_endpoint = self.tracing_endpoint.clone()?;
        // `otel::tracing` should be a level info to emit opentelemetry trace & span
        // `otel` set to debug to log detected resources, configuration read and inferred
        let filter = self
            .filter()
            .add_directive("otel::tracing=trace".parse().unwrap())
            .add_directive("otel=debug".parse().unwrap());

        let service_name = self.service.service_name.clone();
        let resource = self.service.clone().into_otlp_resource();

        let exporter = opentelemetry_otlp::new_exporter()
            .http()
            .with_endpoint(tracing_endpoint)
            .build_span_exporter()
            .expect("Failed to create OTLP exporter"); // URL is validated.

        let config = opentelemetry_sdk::trace::Config::default()
            .with_id_generator(RandomIdGenerator::default())
            .with_sampler(Sampler::AlwaysOn)
            .with_resource(resource);

        let provider = opentelemetry_sdk::trace::TracerProvider::builder()
            .with_batch_exporter(exporter, opentelemetry_sdk::runtime::Tokio)
            .with_config(config)
            .build();

        // TODO: Version and other metadata
        let tracer = provider.tracer_builder(service_name).build();

        opentelemetry::global::set_text_map_propagator(TraceContextPropagator::new());
        let layer = tracing_opentelemetry::layer()
            .with_tracer(tracer)
            .with_filter(filter);

        Some((provider, layer))
    }
Prepares an exporter for OTLP traces and layer for `tracing` library.
Will return `None` if no tracing URL was provided.
core/lib/vlog/src/opentelemetry/mod.rs