Ask Your Question

How can we programmatically activate/deactivate opentelemetry exporters?

asked 2023-05-26 04:44:16 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2023-05-26 04:50:02 +0000

nofretete gravatar image

Opentelemetry exporters can be programmatically activated/deactivated using the SDK API of the chosen language.

In Python, for example, you can create an exporter and register/unregister it using the trace_provider module:

from opentelemetry import trace
from opentelemetry.exporter.otlp.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider

# Create an exporter
exporter = OTLPSpanExporter()

# Create a tracer provider and register the exporter
trace_provider = TracerProvider()

# Disable the exporter

Similarly, in Java, you can use the TracerSdkProvider class and its addSpanProcessor() and shutdown() methods:

import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
import io.opentelemetry.sdk.trace.SdkTracerProvider;
import io.opentelemetry.sdk.trace.export.SpanExporter;
import io.opentelemetry.sdk.trace.export.SpanExporter.SpanExportingExceptionHandler;

// Create an exporter
SpanExporter exporter = OtlpGrpcSpanExporter.newBuilder().build();

// Create a tracer provider and register the exporter
SdkTracerProvider tracerProvider = SdkTracerProvider.builder()

// Disable the exporter
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer

Question Tools


Asked: 2023-05-26 04:44:16 +0000

Seen: 1 times

Last updated: May 26