TracerProvider Interface

public interface TracerProvider

Resolves and provides Tracer implementation.

This class is intended to be used by Azure client libraries and provides abstraction over possible tracing implementations. Application developers should use tracing libraries such as OpenTelemetry or Spring tracing.

Method Summary

Modifier and Type Method and Description
default Tracer createTracer(LibraryTelemetryOptions libraryOptions, TracingOptions options)

Creates tracer provider instance.

abstract Tracer createTracer(String libraryName, String libraryVersion, String azNamespace, TracingOptions options)

Creates named and versioned tracer instance.

static TracerProvider getDefaultProvider()

Returns default implementation of TracerProvider that uses SPI to resolve tracing implementation.

Method Details

createTracer

public default Tracer createTracer(LibraryTelemetryOptions libraryOptions, TracingOptions options)

Creates tracer provider instance.

Code Samples

LibraryTelemetryOptions libraryOptions = new LibraryTelemetryOptions("azure-storage-blobs")
     .setLibraryVersion("12.20.0")
     .setResourceProviderNamespace("Microsoft.Storage")
     .setSchemaUrl("https://opentelemetry.io/schemas/1.23.1");

 Tracer tracer = TracerProvider.getDefaultProvider()
     .createTracer(libraryOptions, clientOptions.getTracingOptions());
 HttpPipeline pipeline = new HttpPipelineBuilder()
     .tracer(tracer)
     .clientOptions(clientOptions)
     .build();

Parameters:

libraryOptions - Library-specific telemetry options.
options - Tracing options configured by the application.

Returns:

a tracer instance.

createTracer

public abstract Tracer createTracer(String libraryName, String libraryVersion, String azNamespace, TracingOptions options)

Creates named and versioned tracer instance.

Parameters:

libraryName - Azure client library package name
libraryVersion - Azure client library version
azNamespace - Azure Resource Provider namespace.
options - instance of TracingOptions

Returns:

a tracer instance.

getDefaultProvider

public static TracerProvider getDefaultProvider()

Returns default implementation of TracerProvider that uses SPI to resolve tracing implementation.

Returns:

an instance of TracerProvider

Applies to