Function opentelemetry::global::tracer_with_scope

source ·
pub fn tracer_with_scope(scope: InstrumentationScope) -> BoxedTracer
Expand description

Creates a Tracer with the given instrumentation scope via the configured GlobalTracerProvider.

This is a simpler alternative to global::tracer_provider().tracer_with_scope(...)

§Example

use std::sync::Arc;
use opentelemetry::global::tracer_with_scope;
use opentelemetry::InstrumentationScope;
use opentelemetry::KeyValue;

let scope = InstrumentationScope::builder("io.opentelemetry")
    .with_version("0.17")
    .with_schema_url("https://opentelemetry.io/schema/1.2.0")
    .with_attributes(vec![(KeyValue::new("key", "value"))])
    .build();

let tracer = tracer_with_scope(scope);