Created
August 1, 2022 13:36
-
-
Save obervinov/3ced185794df135d2e414b025cd06fea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from opentelemetry import trace | |
from opentelemetry.exporter.jaeger.thrift import JaegerExporter | |
from opentelemetry.sdk.resources import SERVICE_NAME, Resource | |
from opentelemetry.sdk.trace import TracerProvider | |
from opentelemetry.sdk.trace.export import BatchSpanProcessor | |
trace.set_tracer_provider( | |
TracerProvider( | |
resource=Resource.create({SERVICE_NAME: "python-test-connection"}) | |
) | |
) | |
tracer = trace.get_tracer(__name__) | |
# create a JaegerExporter | |
jaeger_exporter = JaegerExporter( | |
# configure agent | |
agent_host_name='', | |
agent_port=1234, | |
# optional: configure also collector | |
# collector_endpoint='http://localhost:14268/api/traces?format=jaeger.thrift', | |
# username=xxxx, # optional | |
# password=xxxx, # optional | |
# max_tag_value_length=None # optional | |
) | |
# Create a BatchSpanProcessor and add the exporter to it | |
span_processor = BatchSpanProcessor(jaeger_exporter) | |
# add to the tracer | |
trace.get_tracer_provider().add_span_processor(span_processor) | |
with tracer.start_as_current_span('python-test-connection'): | |
print('test-connection-span') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment