Enrich with OpenTelemetry APIs
Python
Required dependencies
Install the API from PyPI using pip:
pip install opentelemetry-api
Creating Spans
To create a span, use the tracer
object from the opentelemetry.trace
module. The tracer
object is a factory for creating spans.
from opentelemetry import trace
tracer = trace.get_tracer(__name__)
def my_function():
with tracer.start_as_current_span("foo") as span:
print("Hello world!")
Additional information
For more use cases, see the OpenTelemetry Python API documentation.