{"library":"otel-extensions","title":"OpenTelemetry Python Extensions","description":"OpenTelemetry Extensions for Python is a collection of helper classes, functions, and decorators designed to simplify the use of the OpenTelemetry Python API and SDK packages. It currently supports Python >= 3.8 and is actively maintained, with version 1.1.0 released in October 2024.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install otel-extensions"],"cli":null},"imports":["from otel_extensions import init_telemetry_provider","from otel_extensions import TelemetryOptions","from otel_extensions import instrumented","from otel_extensions import TraceContextCarrier","from otel_extensions import TraceEventLogHandler"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom otel_extensions import init_telemetry_provider, TelemetryOptions\nfrom opentelemetry import trace\n\n# Configure telemetry options, can also be set via environment variables\noptions = TelemetryOptions(\n    OTEL_EXPORTER_OTLP_ENDPOINT=os.environ.get('OTEL_EXPORTER_OTLP_ENDPOINT', 'http://localhost:4317/'),\n    OTEL_EXPORTER_OTLP_PROTOCOL=os.environ.get('OTEL_EXPORTER_OTLP_PROTOCOL', 'grpc'),\n    OTEL_SERVICE_NAME=os.environ.get('OTEL_SERVICE_NAME', 'my-service'),\n    OTEL_PROCESSOR_TYPE=os.environ.get('OTEL_PROCESSOR_TYPE', 'batch')\n)\n\n# Initialize the global tracer provider\ninit_telemetry_provider(options)\n\n# Get a tracer and create a span\ntracer = trace.get_tracer(__name__)\n\nwith tracer.start_as_current_span(\"example-operation\") as span:\n    span.set_attribute(\"custom.attribute\", \"example_value\")\n    print(\"Performing an example operation with tracing...\")\n\nprint(\"Telemetry provider initialized and example span created.\")\n","lang":"python","description":"This quickstart demonstrates how to initialize the OpenTelemetry tracer provider using `otel-extensions` and create a basic traced operation. It shows how to configure common options, which can also be provided via environment variables.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}