├── docs ├── getting_started │ ├── __init__.py │ ├── tests │ │ ├── __init__.py │ │ ├── requirements.txt │ │ └── test_tracing.py │ └── tracing_example.py ├── examples │ ├── opentracing │ │ ├── __init__.py │ │ └── requirements.txt │ ├── django │ │ ├── pages │ │ │ ├── migrations │ │ │ │ └── __init__.py │ │ │ ├── __init__.py │ │ │ ├── apps.py │ │ │ ├── urls.py │ │ │ └── views.py │ │ └── instrumentation_example │ │ │ ├── __init__.py │ │ │ ├── asgi.py │ │ │ └── wsgi.py │ ├── opencensus-shim │ │ ├── .gitignore │ │ └── requirements.txt │ ├── metrics │ │ ├── prometheus-grafana │ │ │ ├── requirements.txt │ │ │ └── prometheus-monitor.py │ │ ├── instruments │ │ │ ├── requirements.txt │ │ │ └── otel-collector-config.yaml │ │ ├── views │ │ │ ├── requirements.txt │ │ │ └── README.rst │ │ └── reader │ │ │ ├── requirements.txt │ │ │ └── README.rst │ ├── error_handler │ │ ├── error_handler_0 │ │ │ ├── README.rst │ │ │ ├── src │ │ │ │ └── error_handler_0 │ │ │ │ │ ├── version │ │ │ │ │ └── __init__.py │ │ │ │ │ └── __init__.py │ │ │ └── pyproject.toml │ │ ├── error_handler_1 │ │ │ ├── README.rst │ │ │ ├── src │ │ │ │ └── error_handler_1 │ │ │ │ │ ├── version │ │ │ │ │ └── __init__.py │ │ │ │ │ └── __init__.py │ │ │ └── pyproject.toml │ │ └── example.py │ ├── index.rst │ ├── fork-process-model │ │ ├── flask-gunicorn │ │ │ ├── README.rst │ │ │ └── requirements.txt │ │ └── flask-uwsgi │ │ │ ├── README.rst │ │ │ └── requirements.txt │ ├── auto-instrumentation │ │ ├── README.rst │ │ └── server_automatic.py │ ├── sqlcommenter │ │ ├── collector-config.yaml │ │ └── books_database │ │ │ └── Dockerfile │ ├── logs │ │ └── otel-collector-config.yaml │ ├── opencensus-exporter-tracer │ │ └── docker │ │ │ ├── collector-config.yaml │ │ │ └── docker-compose.yaml │ ├── basic_tracer │ │ ├── README.rst │ │ ├── basic_trace.py │ │ └── resources.py │ └── basic_context │ │ ├── README.rst │ │ ├── implicit_context.py │ │ ├── async_context.py │ │ └── child_context.py ├── api │ ├── _logs.severity.rst │ ├── propagate.rst │ ├── trace.span.rst │ ├── trace.status.rst │ ├── metrics.rst │ ├── propagators.textmap.rst │ ├── environment_variables.rst │ ├── propagators.composite.rst │ ├── propagators.rst │ ├── baggage.propagation.rst │ ├── context.context.rst │ ├── _logs.rst │ ├── context.rst │ ├── trace.rst │ ├── baggage.rst │ └── index.rst ├── shim │ ├── index.rst │ ├── opencensus_shim │ │ └── opencensus_shim.rst │ └── opentracing_shim │ │ └── opentracing_shim.rst ├── exporter │ ├── index.rst │ ├── opencensus │ │ └── opencensus.rst │ ├── zipkin │ │ └── zipkin.rst │ └── otlp │ │ └── otlp.rst ├── sdk │ ├── util.instrumentation.rst │ ├── _logs.rst │ ├── metrics.view.rst │ ├── metrics.export.rst │ ├── trace.export.rst │ ├── resources.rst │ ├── trace.sampling.rst │ ├── error_handler.rst │ ├── trace.id_generator.rst │ ├── index.rst │ ├── metrics.rst │ ├── environment_variables.rst │ └── trace.rst ├── Makefile └── make.bat ├── opentelemetry-proto ├── tests │ ├── __init__.py │ └── test_proto.py ├── src │ └── opentelemetry │ │ └── proto │ │ ├── py.typed │ │ ├── __init__.py │ │ ├── common │ │ ├── __init__.py │ │ └── v1 │ │ │ └── __init__.py │ │ ├── metrics │ │ ├── __init__.py │ │ └── v1 │ │ │ └── __init__.py │ │ ├── trace │ │ ├── __init__.py │ │ └── v1 │ │ │ └── __init__.py │ │ ├── collector │ │ ├── __init__.py │ │ ├── metrics │ │ │ ├── __init__.py │ │ │ └── v1 │ │ │ │ └── __init__.py │ │ └── trace │ │ │ ├── __init__.py │ │ │ └── v1 │ │ │ └── __init__.py │ │ ├── resource │ │ ├── __init__.py │ │ └── v1 │ │ │ └── __init__.py │ │ └── version │ │ └── __init__.py ├── test-requirements.in ├── test-requirements.latest.txt └── test-requirements.oldest.txt ├── opentelemetry-api ├── tests │ ├── context │ │ ├── __init__.py │ │ └── propagation │ │ │ └── __init__.py │ ├── __init__.py │ ├── trace │ │ ├── __init__.py │ │ └── test_defaultspan.py │ ├── distributedcontext │ │ └── __init__.py │ ├── mypysmoke.py │ ├── events │ │ └── test_event.py │ └── logs │ │ └── test_log_record.py ├── src │ └── opentelemetry │ │ ├── py.typed │ │ ├── _events │ │ └── py.typed │ │ ├── _logs │ │ └── py.typed │ │ ├── baggage │ │ └── py.typed │ │ ├── context │ │ └── py.typed │ │ ├── metrics │ │ └── py.typed │ │ ├── trace │ │ └── py.typed │ │ ├── util │ │ └── py.typed │ │ ├── version │ │ ├── py.typed │ │ └── __init__.py │ │ ├── attributes │ │ └── py.typed │ │ ├── propagate │ │ └── py.typed │ │ ├── propagators │ │ └── py.typed │ │ └── environment_variables │ │ └── py.typed ├── test-requirements.txt └── README.rst ├── opentelemetry-sdk ├── tests │ ├── context │ │ └── __init__.py │ ├── resources │ │ └── __init__.py │ ├── error_handler │ │ └── __init__.py │ ├── trace │ │ ├── propagation │ │ │ └── __init__.py │ │ ├── composite_sampler │ │ │ └── __init__.py │ │ ├── __init__.py │ │ ├── export │ │ │ └── __init__.py │ │ └── test_globals.py │ ├── __init__.py │ ├── events │ │ └── __init__.py │ ├── logs │ │ └── __init__.py │ ├── shared_internal │ │ └── __init__.py │ └── conftest.py ├── src │ └── opentelemetry │ │ └── sdk │ │ ├── py.typed │ │ ├── metrics │ │ ├── _internal │ │ │ ├── exponential_histogram │ │ │ │ ├── __init__.py │ │ │ │ └── mapping │ │ │ │ │ └── errors.py │ │ │ ├── exceptions.py │ │ │ └── sdk_configuration.py │ │ └── view │ │ │ └── __init__.py │ │ ├── version │ │ └── __init__.py │ │ ├── __init__.pyi │ │ ├── trace │ │ └── _sampling_experimental │ │ │ ├── __init__.py │ │ │ └── _util.py │ │ └── _logs │ │ └── __init__.py ├── benchmark-requirements.txt ├── test-requirements.txt ├── README.rst └── benchmarks │ └── logs │ └── test_benchmark_logging_handler.py ├── propagator ├── opentelemetry-propagator-b3 │ ├── py.typed │ ├── src │ │ └── opentelemetry │ │ │ └── propagators │ │ │ └── b3 │ │ │ ├── py.typed │ │ │ └── version │ │ │ └── __init__.py │ ├── benchmark-requirements.txt │ ├── test-requirements.txt │ ├── README.rst │ └── tests │ │ └── __init__.py └── opentelemetry-propagator-jaeger │ ├── py.typed │ ├── src │ └── opentelemetry │ │ └── propagators │ │ └── jaeger │ │ ├── py.typed │ │ └── version │ │ └── __init__.py │ ├── test-requirements.txt │ ├── README.rst │ └── tests │ └── __init__.py ├── opentelemetry-semantic-conventions ├── tests │ ├── __init__.py │ └── test_semconv.py ├── src │ └── opentelemetry │ │ └── semconv │ │ ├── __init__.py │ │ ├── py.typed │ │ ├── attributes │ │ ├── __init__.py │ │ ├── user_agent_attributes.py │ │ └── service_attributes.py │ │ ├── version │ │ └── __init__.py │ │ ├── _incubating │ │ ├── attributes │ │ │ ├── pool_attributes.py │ │ │ ├── mainframe_attributes.py │ │ │ ├── elasticsearch_attributes.py │ │ │ ├── event_attributes.py │ │ │ ├── session_attributes.py │ │ │ ├── openshift_attributes.py │ │ │ ├── az_attributes.py │ │ │ ├── disk_attributes.py │ │ │ ├── nfs_attributes.py │ │ │ ├── linux_attributes.py │ │ │ ├── dns_attributes.py │ │ │ ├── client_attributes.py │ │ │ ├── server_attributes.py │ │ │ ├── zos_attributes.py │ │ │ ├── cpython_attributes.py │ │ │ ├── heroku_attributes.py │ │ │ ├── webengine_attributes.py │ │ │ ├── other_attributes.py │ │ │ ├── onc_rpc_attributes.py │ │ │ ├── source_attributes.py │ │ │ ├── opentracing_attributes.py │ │ │ ├── destination_attributes.py │ │ │ ├── peer_attributes.py │ │ │ ├── oci_attributes.py │ │ │ └── cpu_attributes.py │ │ └── metrics │ │ │ └── dns_metrics.py │ │ └── metrics │ │ ├── db_metrics.py │ │ └── http_metrics.py └── test-requirements.txt ├── scripts ├── semconv │ └── .gitignore ├── generate_website_docs.sh ├── build.sh └── coverage.sh ├── shim ├── opentelemetry-opencensus-shim │ ├── tests │ │ └── __init__.py │ ├── src │ │ └── opentelemetry │ │ │ └── shim │ │ │ └── opencensus │ │ │ ├── py.typed │ │ │ └── version │ │ │ └── __init__.py │ ├── README.rst │ └── test-requirements.txt └── opentelemetry-opentracing-shim │ ├── tests │ ├── __init__.py │ └── testbed │ │ ├── __init__.py │ │ ├── test_client_server │ │ ├── __init__.py │ │ └── README.rst │ │ ├── test_late_span_finish │ │ ├── __init__.py │ │ └── README.rst │ │ ├── test_nested_callbacks │ │ └── __init__.py │ │ ├── test_listener_per_request │ │ ├── __init__.py │ │ ├── response_listener.py │ │ └── README.rst │ │ ├── test_multiple_callbacks │ │ └── __init__.py │ │ ├── test_active_span_replacement │ │ ├── __init__.py │ │ └── README.rst │ │ ├── test_common_request_handler │ │ ├── __init__.py │ │ └── README.rst │ │ ├── test_subtask_span_propagation │ │ └── __init__.py │ │ └── otel_ot_shim_tracer.py │ ├── src │ └── opentelemetry │ │ └── shim │ │ └── opentracing_shim │ │ ├── py.typed │ │ └── version │ │ └── __init__.py │ ├── test-requirements.txt │ └── README.rst ├── exporter ├── opentelemetry-exporter-otlp │ ├── tests │ │ └── __init__.py │ ├── src │ │ └── opentelemetry │ │ │ └── exporter │ │ │ └── otlp │ │ │ ├── py.typed │ │ │ └── version │ │ │ └── __init__.py │ ├── test-requirements.txt │ └── README.rst ├── opentelemetry-exporter-zipkin-json │ ├── CHANGELOG.md │ ├── tests │ │ ├── encoder │ │ │ └── __init__.py │ │ └── __init__.py │ ├── src │ │ └── opentelemetry │ │ │ └── exporter │ │ │ └── zipkin │ │ │ ├── py.typed │ │ │ └── json │ │ │ └── version │ │ │ └── __init__.py │ ├── test-requirements.txt │ └── README.rst ├── opentelemetry-exporter-zipkin │ ├── tests │ │ ├── __init__.py │ │ └── test_zipkin.py │ ├── src │ │ └── opentelemetry │ │ │ └── exporter │ │ │ └── zipkin │ │ │ ├── py.typed │ │ │ └── version │ │ │ └── __init__.py │ ├── test-requirements.txt │ └── README.rst ├── opentelemetry-exporter-opencensus │ ├── tests │ │ └── __init__.py │ ├── src │ │ └── opentelemetry │ │ │ └── exporter │ │ │ └── opencensus │ │ │ ├── py.typed │ │ │ ├── version │ │ │ └── __init__.py │ │ │ └── __init__.py │ ├── test-requirements.txt │ └── README.rst ├── opentelemetry-exporter-zipkin-proto-http │ ├── CHANGELOG.md │ ├── tests │ │ ├── encoder │ │ │ └── __init__.py │ │ └── __init__.py │ ├── src │ │ └── opentelemetry │ │ │ └── exporter │ │ │ └── zipkin │ │ │ └── proto │ │ │ └── http │ │ │ ├── py.typed │ │ │ ├── v2 │ │ │ └── gen │ │ │ │ └── __init__.py │ │ │ └── version │ │ │ └── __init__.py │ ├── test-requirements.txt │ └── README.rst ├── opentelemetry-exporter-otlp-proto-common │ ├── tests │ │ └── __init__.py │ ├── src │ │ └── opentelemetry │ │ │ └── exporter │ │ │ └── otlp │ │ │ └── proto │ │ │ └── common │ │ │ ├── py.typed │ │ │ ├── version │ │ │ └── __init__.py │ │ │ ├── __init__.py │ │ │ ├── _log_encoder.py │ │ │ ├── trace_encoder.py │ │ │ └── metrics_encoder.py │ ├── test-requirements.txt │ └── README.rst ├── opentelemetry-exporter-otlp-proto-grpc │ ├── tests │ │ ├── __init__.py │ │ ├── fixtures │ │ │ ├── test.cert │ │ │ ├── test-client-cert.pem │ │ │ └── test-client-key.pem │ │ └── logs │ │ │ └── __init__.py │ ├── benchmark-requirements.txt │ ├── src │ │ └── opentelemetry │ │ │ └── exporter │ │ │ └── otlp │ │ │ └── proto │ │ │ └── grpc │ │ │ ├── py.typed │ │ │ └── version │ │ │ └── __init__.py │ ├── test-requirements.in │ └── README.rst ├── opentelemetry-exporter-otlp-proto-http │ ├── tests │ │ ├── __init__.py │ │ └── metrics │ │ │ └── __init__.py │ ├── src │ │ └── opentelemetry │ │ │ └── exporter │ │ │ └── otlp │ │ │ └── proto │ │ │ └── http │ │ │ ├── py.typed │ │ │ └── version │ │ │ └── __init__.py │ ├── test-requirements.txt │ └── README.rst └── opentelemetry-exporter-prometheus │ ├── src │ └── opentelemetry │ │ └── exporter │ │ └── prometheus │ │ ├── py.typed │ │ └── version │ │ └── __init__.py │ ├── test-requirements.txt │ ├── tests │ └── __init__.py │ └── README.rst ├── .coveragerc ├── .rstcheck.cfg ├── tests ├── opentelemetry-test-utils │ ├── src │ │ └── opentelemetry │ │ │ └── test │ │ │ ├── version │ │ │ └── __init__.py │ │ │ └── mock_test_classes.py │ ├── test-requirements.txt │ ├── README.rst │ └── tests │ │ ├── __init__.py │ │ └── test_base.py └── opentelemetry-docker-tests │ └── tests │ └── docker-compose.yml ├── tox-uv.toml ├── .gitattributes ├── .github ├── rtd-build-instructions.png ├── scripts │ ├── use-cla-approved-github-bot.sh │ ├── update-version.sh │ └── update-version-patch.sh ├── ISSUE_TEMPLATE │ └── config.yml ├── CODEOWNERS ├── workflows │ ├── check_links_config.json │ ├── fossa.yml │ ├── contrib.yml │ ├── codeql-analysis.yml │ └── changelog.yml └── dependabot.yml ├── .clomonitor.yml ├── .codespellrc ├── .readthedocs.yml ├── gen-requirements.txt ├── dev-requirements.txt ├── .pre-commit-config.yaml ├── docs-requirements.txt ├── .gitignore └── eachdist.ini /docs/getting_started/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/examples/opentracing/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-proto/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-api/tests/context/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-sdk/tests/context/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-api/src/opentelemetry/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-sdk/src/opentelemetry/sdk/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-sdk/tests/resources/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /propagator/opentelemetry-propagator-b3/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/examples/django/pages/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-api/src/opentelemetry/_events/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-api/src/opentelemetry/_logs/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-api/src/opentelemetry/baggage/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-api/src/opentelemetry/context/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-api/src/opentelemetry/metrics/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-api/src/opentelemetry/trace/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-api/src/opentelemetry/util/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-api/src/opentelemetry/version/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-proto/src/opentelemetry/proto/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-sdk/tests/error_handler/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-sdk/tests/trace/propagation/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /propagator/opentelemetry-propagator-jaeger/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /scripts/semconv/.gitignore: -------------------------------------------------------------------------------- 1 | opentelemetry-specification -------------------------------------------------------------------------------- /shim/opentelemetry-opencensus-shim/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/examples/django/instrumentation_example/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/examples/opencensus-shim/.gitignore: -------------------------------------------------------------------------------- 1 | example.db 2 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin-json/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-api/src/opentelemetry/attributes/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-api/src/opentelemetry/propagate/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-api/src/opentelemetry/propagators/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-api/tests/context/propagation/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-proto/src/opentelemetry/proto/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-opencensus/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin-proto-http/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-proto/src/opentelemetry/proto/common/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-proto/src/opentelemetry/proto/metrics/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-proto/src/opentelemetry/proto/trace/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-sdk/tests/trace/composite_sampler/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/tests/testbed/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | omit = 3 | */tests/* 4 | */gen/* 5 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-common/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-grpc/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-http/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-api/src/opentelemetry/environment_variables/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-proto/src/opentelemetry/proto/collector/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-proto/src/opentelemetry/proto/common/v1/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-proto/src/opentelemetry/proto/metrics/v1/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-proto/src/opentelemetry/proto/resource/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-proto/src/opentelemetry/proto/resource/v1/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-proto/src/opentelemetry/proto/trace/v1/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-grpc/tests/fixtures/test.cert: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-grpc/tests/logs/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-http/tests/metrics/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin-json/tests/encoder/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-proto/src/opentelemetry/proto/collector/metrics/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-proto/src/opentelemetry/proto/collector/trace/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-sdk/benchmark-requirements.txt: -------------------------------------------------------------------------------- 1 | pytest-benchmark==4.0.0 2 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp/src/opentelemetry/exporter/otlp/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin-proto-http/tests/encoder/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-proto/src/opentelemetry/proto/collector/metrics/v1/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-proto/src/opentelemetry/proto/collector/trace/v1/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /shim/opentelemetry-opencensus-shim/src/opentelemetry/shim/opencensus/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-grpc/tests/fixtures/test-client-cert.pem: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-grpc/tests/fixtures/test-client-key.pem: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin/src/opentelemetry/exporter/zipkin/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /propagator/opentelemetry-propagator-b3/src/opentelemetry/propagators/b3/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/tests/testbed/test_client_server/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/tests/testbed/test_late_span_finish/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/tests/testbed/test_nested_callbacks/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin-json/src/opentelemetry/exporter/zipkin/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /propagator/opentelemetry-propagator-jaeger/src/opentelemetry/propagators/jaeger/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/src/opentelemetry/shim/opentracing_shim/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/tests/testbed/test_listener_per_request/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/tests/testbed/test_multiple_callbacks/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-opencensus/src/opentelemetry/exporter/opencensus/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/exponential_histogram/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /propagator/opentelemetry-propagator-b3/benchmark-requirements.txt: -------------------------------------------------------------------------------- 1 | pytest-benchmark==4.0.0 2 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/tests/testbed/test_active_span_replacement/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/tests/testbed/test_common_request_handler/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/tests/testbed/test_subtask_span_propagation/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.rstcheck.cfg: -------------------------------------------------------------------------------- 1 | [rstcheck] 2 | ignore_directives = automodule 3 | ignore_roles = scm_web,scm_raw_web 4 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-grpc/benchmark-requirements.txt: -------------------------------------------------------------------------------- 1 | pytest-benchmark==4.0.0 2 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin-proto-http/src/opentelemetry/exporter/zipkin/proto/http/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/opentelemetry-test-utils/src/opentelemetry/test/version/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "0.61b0.dev" 2 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin-proto-http/src/opentelemetry/exporter/zipkin/proto/http/v2/gen/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tox-uv.toml: -------------------------------------------------------------------------------- 1 | # https://docs.astral.sh/uv/reference/settings/#pip_no-sources 2 | [pip] 3 | no-sources = true 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # tells github that proto code is generated 2 | opentelemetry-proto/src/**/*_pb2*.py* linguist-generated=true 3 | -------------------------------------------------------------------------------- /docs/examples/metrics/prometheus-grafana/requirements.txt: -------------------------------------------------------------------------------- 1 | opentelemetry-exporter-prometheus==1.12.0rc1 2 | protobuf~=3.18.1 3 | -------------------------------------------------------------------------------- /.github/rtd-build-instructions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-telemetry/opentelemetry-python/HEAD/.github/rtd-build-instructions.png -------------------------------------------------------------------------------- /docs/api/_logs.severity.rst: -------------------------------------------------------------------------------- 1 | opentelemetry._logs.severity 2 | ============================ 3 | 4 | .. automodule:: opentelemetry._logs.severity -------------------------------------------------------------------------------- /docs/shim/index.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | Shims 4 | ===== 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | :glob: 9 | 10 | ** 11 | -------------------------------------------------------------------------------- /docs/examples/metrics/instruments/requirements.txt: -------------------------------------------------------------------------------- 1 | opentelemetry-api~=1.25 2 | opentelemetry-sdk~=1.25 3 | opentelemetry-exporter-otlp~=1.25 4 | -------------------------------------------------------------------------------- /docs/examples/error_handler/error_handler_0/README.rst: -------------------------------------------------------------------------------- 1 | Error Handler 0 2 | =============== 3 | 4 | This is just an error handler for this example. 5 | -------------------------------------------------------------------------------- /docs/examples/error_handler/error_handler_1/README.rst: -------------------------------------------------------------------------------- 1 | Error Handler 1 2 | =============== 3 | 4 | This is just an error handler for this example. 5 | -------------------------------------------------------------------------------- /docs/examples/index.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | Examples 4 | ======== 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | :glob: 9 | 10 | ** 11 | -------------------------------------------------------------------------------- /docs/exporter/index.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | Exporters 4 | ========= 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | :glob: 9 | 10 | ** 11 | -------------------------------------------------------------------------------- /opentelemetry-proto/test-requirements.in: -------------------------------------------------------------------------------- 1 | colorama>=0.4.6 2 | iniconfig>=2.0.0 3 | packaging>=24.0 4 | protobuf>=5.29.5 5 | pytest>=7.4.4 6 | -e opentelemetry-proto 7 | -------------------------------------------------------------------------------- /.github/scripts/use-cla-approved-github-bot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | git config user.name otelbot 4 | git config user.email 197425009+otelbot@users.noreply.github.com 5 | -------------------------------------------------------------------------------- /docs/examples/opentracing/requirements.txt: -------------------------------------------------------------------------------- 1 | opentelemetry-api 2 | opentelemetry-sdk 3 | opentelemetry-exporter-otlp 4 | opentelemetry-opentracing-shim 5 | redis 6 | redis_opentracing 7 | -------------------------------------------------------------------------------- /docs/sdk/util.instrumentation.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.sdk.util.instrumentation 2 | ========================================== 3 | 4 | .. automodule:: opentelemetry.sdk.util.instrumentation 5 | -------------------------------------------------------------------------------- /docs/api/propagate.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.propagate package 2 | ======================================== 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: opentelemetry.propagate 8 | -------------------------------------------------------------------------------- /docs/examples/metrics/views/requirements.txt: -------------------------------------------------------------------------------- 1 | opentelemetry-api==1.12.0 2 | opentelemetry-sdk==1.12.0 3 | opentelemetry-semantic-conventions==0.33b0 4 | typing_extensions==4.5.0 5 | wrapt==1.14.1 6 | -------------------------------------------------------------------------------- /.clomonitor.yml: -------------------------------------------------------------------------------- 1 | # see https://github.com/cncf/clomonitor/blob/main/docs/checks.md#exemptions 2 | exemptions: 3 | - check: artifacthub_badge 4 | reason: "Artifact Hub doesn't support python packages" -------------------------------------------------------------------------------- /docs/api/trace.span.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.trace.span 2 | ======================== 3 | 4 | .. automodule:: opentelemetry.trace.span 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/examples/metrics/reader/requirements.txt: -------------------------------------------------------------------------------- 1 | opentelemetry-api==1.15.0 2 | opentelemetry-sdk==1.15.0 3 | opentelemetry-semantic-conventions==0.36b0 4 | typing_extensions==4.5.0 5 | wrapt==1.14.1 6 | -------------------------------------------------------------------------------- /docs/api/trace.status.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.trace.status 2 | ========================== 3 | 4 | .. automodule:: opentelemetry.trace.status 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/sdk/_logs.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.sdk._logs package 2 | =============================== 3 | 4 | .. automodule:: opentelemetry.sdk._logs 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/shim/opencensus_shim/opencensus_shim.rst: -------------------------------------------------------------------------------- 1 | OpenCensus Shim for OpenTelemetry 2 | ================================== 3 | 4 | .. automodule:: opentelemetry.shim.opencensus 5 | :no-show-inheritance: 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | contact_links: 2 | - name: Slack 3 | url: https://cloud-native.slack.com/archives/C01PD4HUVBL 4 | about: Or the `#otel-python` channel in the CNCF Slack instance. 5 | -------------------------------------------------------------------------------- /docs/api/metrics.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.metrics package 2 | ============================= 3 | 4 | .. toctree:: 5 | 6 | 7 | Module contents 8 | --------------- 9 | 10 | .. automodule:: opentelemetry.metrics 11 | -------------------------------------------------------------------------------- /docs/exporter/opencensus/opencensus.rst: -------------------------------------------------------------------------------- 1 | OpenCensus Exporter 2 | =================== 3 | 4 | .. automodule:: opentelemetry.exporter.opencensus 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/shim/opentracing_shim/opentracing_shim.rst: -------------------------------------------------------------------------------- 1 | OpenTracing Shim for OpenTelemetry 2 | ================================== 3 | 4 | .. automodule:: opentelemetry.shim.opentracing_shim 5 | :no-show-inheritance: 6 | -------------------------------------------------------------------------------- /docs/sdk/metrics.view.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.sdk.metrics.view 2 | ============================== 3 | 4 | .. automodule:: opentelemetry.sdk.metrics.view 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/sdk/metrics.export.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.sdk.metrics.export 2 | ================================ 3 | 4 | .. automodule:: opentelemetry.sdk.metrics.export 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/sdk/trace.export.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.sdk.trace.export 2 | ========================================== 3 | 4 | .. automodule:: opentelemetry.sdk.trace.export 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: -------------------------------------------------------------------------------- /docs/api/propagators.textmap.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.propagators.textmap 2 | ==================================================== 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: opentelemetry.propagators.textmap 8 | -------------------------------------------------------------------------------- /docs/sdk/resources.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.sdk.resources package 2 | ========================================== 3 | 4 | .. automodule:: opentelemetry.sdk.resources 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/sdk/trace.sampling.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.sdk.trace.sampling 2 | ========================================== 3 | 4 | .. automodule:: opentelemetry.sdk.trace.sampling 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Code owners file. 2 | # This file controls who is tagged for review for any given pull request. 3 | 4 | # For anything not explicitly taken by someone else: 5 | * @open-telemetry/python-approvers 6 | -------------------------------------------------------------------------------- /docs/api/environment_variables.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.environment_variables package 2 | =========================================== 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: opentelemetry.environment_variables 8 | -------------------------------------------------------------------------------- /docs/api/propagators.composite.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.propagators.composite 2 | ==================================================== 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: opentelemetry.propagators.composite 8 | -------------------------------------------------------------------------------- /docs/api/propagators.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.propagators package 2 | ======================================== 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | 9 | propagators.textmap 10 | propagators.composite 11 | -------------------------------------------------------------------------------- /.codespellrc: -------------------------------------------------------------------------------- 1 | [codespell] 2 | # skipping auto generated folders 3 | skip = ./.tox,./.mypy_cache,./docs/_build,./target,*/LICENSE,./venv,.git,./opentelemetry-semantic-conventions,*-requirements*.txt 4 | ignore-words-list = ans,ue,ot,hist,ro 5 | -------------------------------------------------------------------------------- /docs/api/baggage.propagation.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.baggage.propagation package 2 | ==================================================== 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: opentelemetry.baggage.propagation 8 | -------------------------------------------------------------------------------- /docs/sdk/error_handler.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.sdk.error_handler package 2 | ======================================= 3 | 4 | .. automodule:: opentelemetry.sdk.error_handler 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/api/context.context.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.context.base\_context module 2 | ========================================== 3 | 4 | .. automodule:: opentelemetry.context.context 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/examples/opencensus-shim/requirements.txt: -------------------------------------------------------------------------------- 1 | opentelemetry-api 2 | opentelemetry-sdk 3 | opentelemetry-exporter-otlp 4 | opentelemetry-opencensus-shim 5 | opentelemetry-instrumentation-sqlite3 6 | opencensus 7 | opencensus-ext-flask 8 | Flask 9 | -------------------------------------------------------------------------------- /docs/sdk/trace.id_generator.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.sdk.trace.id_generator 2 | ==================================== 3 | 4 | .. automodule:: opentelemetry.sdk.trace.id_generator 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /.github/scripts/update-version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | sed -i "/\[stable\]/{n;s/version=.*/version=$1/}" eachdist.ini 4 | sed -i "/\[prerelease\]/{n;s/version=.*/version=$2/}" eachdist.ini 5 | 6 | ./scripts/eachdist.py update_versions --versions stable,prerelease 7 | -------------------------------------------------------------------------------- /docs/api/_logs.rst: -------------------------------------------------------------------------------- 1 | opentelemetry._logs package 2 | ============================= 3 | 4 | Submodules 5 | ---------- 6 | 7 | .. toctree:: 8 | 9 | _logs.severity 10 | 11 | Module contents 12 | --------------- 13 | 14 | .. automodule:: opentelemetry._logs 15 | -------------------------------------------------------------------------------- /docs/api/context.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.context package 2 | ============================= 3 | 4 | Submodules 5 | ---------- 6 | 7 | .. toctree:: 8 | 9 | context.context 10 | 11 | Module contents 12 | --------------- 13 | 14 | .. automodule:: opentelemetry.context 15 | -------------------------------------------------------------------------------- /docs/api/trace.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.trace package 2 | =========================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | .. toctree:: 8 | 9 | trace.status 10 | trace.span 11 | 12 | Module contents 13 | --------------- 14 | 15 | .. automodule:: opentelemetry.trace -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/tests/testbed/test_listener_per_request/response_listener.py: -------------------------------------------------------------------------------- 1 | class ResponseListener: 2 | def __init__(self, span): 3 | self.span = span 4 | 5 | def on_response(self, res): 6 | del res 7 | self.span.finish() 8 | -------------------------------------------------------------------------------- /docs/examples/fork-process-model/flask-gunicorn/README.rst: -------------------------------------------------------------------------------- 1 | Installation 2 | ------------ 3 | .. code-block:: sh 4 | 5 | pip install -rrequirements.txt 6 | 7 | Run application 8 | --------------- 9 | .. code-block:: sh 10 | 11 | gunicorn app -c gunicorn.conf.py 12 | -------------------------------------------------------------------------------- /docs/sdk/index.rst: -------------------------------------------------------------------------------- 1 | OpenTelemetry Python SDK 2 | ======================== 3 | 4 | .. TODO: what is the SDK 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | 9 | _logs 10 | resources 11 | trace 12 | metrics 13 | error_handler 14 | environment_variables 15 | -------------------------------------------------------------------------------- /docs/api/baggage.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.baggage package 2 | ======================================== 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | 9 | baggage.propagation 10 | 11 | Module contents 12 | --------------- 13 | 14 | .. automodule:: opentelemetry.baggage 15 | -------------------------------------------------------------------------------- /scripts/generate_website_docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # this script generates the documentation required for 5 | # opentelemetry.io 6 | 7 | pip install -r docs-requirements.txt 8 | 9 | TMP_DIR=/tmp/python_otel_docs 10 | rm -Rf ${TMP_DIR} 11 | 12 | sphinx-build -M jekyll ./docs ${TMP_DIR} 13 | -------------------------------------------------------------------------------- /docs/api/index.rst: -------------------------------------------------------------------------------- 1 | OpenTelemetry Python API 2 | ======================== 3 | 4 | .. TODO: what is the API 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | 9 | _logs 10 | baggage 11 | context 12 | propagate 13 | propagators 14 | trace 15 | metrics 16 | environment_variables 17 | -------------------------------------------------------------------------------- /docs/sdk/metrics.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.sdk.metrics package 2 | ================================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | .. toctree:: 8 | 9 | metrics.export 10 | metrics.view 11 | 12 | .. automodule:: opentelemetry.sdk.metrics 13 | :members: 14 | :undoc-members: 15 | :show-inheritance: 16 | -------------------------------------------------------------------------------- /docs/examples/auto-instrumentation/README.rst: -------------------------------------------------------------------------------- 1 | Auto-instrumentation 2 | ==================== 3 | 4 | To learn about automatic instrumentation and how to run the example in this 5 | directory, see `Automatic Instrumentation`_. 6 | 7 | .. _Automatic Instrumentation: https://opentelemetry.io/docs/instrumentation/python/automatic/example 8 | -------------------------------------------------------------------------------- /docs/examples/fork-process-model/flask-uwsgi/README.rst: -------------------------------------------------------------------------------- 1 | Installation 2 | ------------ 3 | .. code-block:: sh 4 | 5 | pip install -rrequirements.txt 6 | 7 | Run application 8 | --------------- 9 | 10 | .. code-block:: sh 11 | 12 | uwsgi --http :8000 --wsgi-file app.py --callable application --master --enable-threads 13 | -------------------------------------------------------------------------------- /docs/sdk/environment_variables.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.sdk.environment_variables 2 | ======================================= 3 | 4 | .. TODO: what is the SDK 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | 9 | .. automodule:: opentelemetry.sdk.environment_variables 10 | :members: 11 | :undoc-members: 12 | :show-inheritance: 13 | -------------------------------------------------------------------------------- /docs/examples/metrics/instruments/otel-collector-config.yaml: -------------------------------------------------------------------------------- 1 | receivers: 2 | otlp: 3 | protocols: 4 | grpc: 5 | endpoint: 0.0.0.0:4317 6 | 7 | exporters: 8 | debug: 9 | 10 | service: 11 | pipelines: 12 | metrics: 13 | receivers: [otlp] 14 | exporters: [debug] 15 | -------------------------------------------------------------------------------- /docs/examples/sqlcommenter/collector-config.yaml: -------------------------------------------------------------------------------- 1 | receivers: 2 | otlp: 3 | protocols: 4 | grpc: 5 | endpoint: 0.0.0.0:4317 6 | 7 | exporters: 8 | debug: 9 | verbosity: detailed 10 | 11 | service: 12 | pipelines: 13 | traces: 14 | receivers: [otlp] 15 | processors: [] 16 | exporters: [debug] 17 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/test-requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.7.2 2 | importlib-metadata==6.11.0 3 | iniconfig==2.0.0 4 | packaging==24.0 5 | pluggy==1.5.0 6 | py-cpuinfo==9.0.0 7 | pytest==7.4.4 8 | tomli==2.0.1 9 | typing_extensions==4.10.0 10 | wrapt==1.16.0 11 | zipp==3.19.2 12 | -e opentelemetry-api 13 | -e opentelemetry-semantic-conventions 14 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | # Read the Docs configuration file 2 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 3 | version: 2 4 | 5 | build: 6 | os: "ubuntu-22.04" 7 | tools: 8 | python: "3.9" 9 | 10 | sphinx: 11 | configuration: docs/conf.py 12 | 13 | python: 14 | install: 15 | - requirements: docs-requirements.txt 16 | -------------------------------------------------------------------------------- /docs/sdk/trace.rst: -------------------------------------------------------------------------------- 1 | opentelemetry.sdk.trace package 2 | =============================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | .. toctree:: 8 | 9 | trace.export 10 | trace.id_generator 11 | trace.sampling 12 | util.instrumentation 13 | 14 | .. automodule:: opentelemetry.sdk.trace 15 | :members: 16 | :undoc-members: 17 | :show-inheritance: 18 | -------------------------------------------------------------------------------- /gen-requirements.txt: -------------------------------------------------------------------------------- 1 | # Use caution when bumping this version to ensure compatibility with the currently supported protobuf version. 2 | # Pinning this to the oldest grpcio version that supports protobuf 5 helps avoid RuntimeWarning messages 3 | # from the generated protobuf code and ensures continued stability for newer grpcio versions. 4 | grpcio-tools==1.63.2 5 | mypy-protobuf~=3.5.0 6 | -------------------------------------------------------------------------------- /.github/workflows/check_links_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "ignorePatterns": [ 3 | { 4 | "pattern": "http(s)?://\\d+\\.\\d+\\.\\d+\\.\\d+" 5 | }, 6 | { 7 | "pattern": "http(s)?://localhost" 8 | }, 9 | { 10 | "pattern": "http(s)?://example.com" 11 | } 12 | ], 13 | "aliveStatusCodes": [429, 200] 14 | } 15 | -------------------------------------------------------------------------------- /.github/scripts/update-version-patch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | sed -i "/\[stable\]/{n;s/version=.*/version=$1/}" eachdist.ini 4 | sed -i "/\[prerelease\]/{n;s/version=.*/version=$2/}" eachdist.ini 5 | 6 | ./scripts/eachdist.py update_patch_versions \ 7 | --stable_version=$1 \ 8 | --unstable_version=$2 \ 9 | --stable_version_prev=$3 \ 10 | --unstable_version_prev=$4 11 | 12 | -------------------------------------------------------------------------------- /tests/opentelemetry-docker-tests/tests/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | otopencensus: 5 | image: rafaeljesus/opencensus-collector:latest 6 | command: --logging-exporter DEBUG 7 | ports: 8 | - "8888:8888" 9 | - "55678:55678" 10 | otcollector: 11 | image: otel/opentelemetry-collector:0.31.0 12 | ports: 13 | - "4317:4317" 14 | - "4318:55681" 15 | -------------------------------------------------------------------------------- /tests/opentelemetry-test-utils/test-requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.7.2 2 | importlib-metadata==6.11.0 3 | iniconfig==2.0.0 4 | packaging==24.0 5 | pluggy==1.5.0 6 | py-cpuinfo==9.0.0 7 | pytest==7.4.4 8 | tomli==2.0.1 9 | typing_extensions==4.10.0 10 | wrapt==1.16.0 11 | zipp==3.19.2 12 | -e opentelemetry-api 13 | -e opentelemetry-sdk 14 | -e opentelemetry-semantic-conventions 15 | -e tests/opentelemetry-test-utils 16 | -------------------------------------------------------------------------------- /docs/examples/logs/otel-collector-config.yaml: -------------------------------------------------------------------------------- 1 | receivers: 2 | otlp: 3 | protocols: 4 | grpc: 5 | endpoint: 0.0.0.0:4317 6 | 7 | exporters: 8 | debug: 9 | verbosity: detailed 10 | 11 | 12 | service: 13 | pipelines: 14 | logs: 15 | receivers: [otlp] 16 | exporters: [debug] 17 | traces: 18 | receivers: [otlp] 19 | exporters: [debug] -------------------------------------------------------------------------------- /propagator/opentelemetry-propagator-b3/test-requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.7.2 2 | importlib-metadata==6.11.0 3 | iniconfig==2.0.0 4 | packaging==24.0 5 | pluggy==1.5.0 6 | py-cpuinfo==9.0.0 7 | pytest==7.4.4 8 | tomli==2.0.1 9 | typing_extensions==4.10.0 10 | wrapt==1.16.0 11 | zipp==3.19.2 12 | -e opentelemetry-api 13 | -e opentelemetry-sdk 14 | -e opentelemetry-semantic-conventions 15 | -e propagator/opentelemetry-propagator-b3 16 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements.in: -------------------------------------------------------------------------------- 1 | colorama>=0.4.6 2 | iniconfig>=2.0.0 3 | packaging>=24.0 4 | pluggy>=1.5.0 5 | protobuf>=5.29.5 6 | pytest>=7.4.4 7 | -e opentelemetry-api 8 | -e tests/opentelemetry-test-utils 9 | -e exporter/opentelemetry-exporter-otlp-proto-common 10 | -e opentelemetry-proto 11 | -e opentelemetry-sdk 12 | -e opentelemetry-semantic-conventions 13 | -e exporter/opentelemetry-exporter-otlp-proto-grpc 14 | -------------------------------------------------------------------------------- /opentelemetry-sdk/test-requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.7.2 2 | flaky==3.7.0 3 | importlib-metadata==6.11.0 4 | iniconfig==2.0.0 5 | packaging==24.0 6 | pluggy==1.5.0 7 | psutil==5.9.6; sys_platform != 'win32' 8 | py-cpuinfo==9.0.0 9 | pytest==7.4.4 10 | tomli==2.0.1 11 | typing_extensions==4.10.0 12 | wrapt==1.16.0 13 | zipp==3.19.2 14 | -e tests/opentelemetry-test-utils 15 | -e opentelemetry-api 16 | -e opentelemetry-semantic-conventions 17 | -e opentelemetry-sdk -------------------------------------------------------------------------------- /propagator/opentelemetry-propagator-jaeger/test-requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.7.2 2 | importlib-metadata==6.11.0 3 | iniconfig==2.0.0 4 | packaging==24.0 5 | pluggy==1.5.0 6 | py-cpuinfo==9.0.0 7 | pytest==7.4.4 8 | tomli==2.0.1 9 | typing_extensions==4.10.0 10 | wrapt==1.16.0 11 | zipp==3.19.2 12 | -e opentelemetry-api 13 | -e opentelemetry-sdk 14 | -e opentelemetry-semantic-conventions 15 | -e tests/opentelemetry-test-utils 16 | -e propagator/opentelemetry-propagator-jaeger 17 | -------------------------------------------------------------------------------- /docs/examples/opencensus-exporter-tracer/docker/collector-config.yaml: -------------------------------------------------------------------------------- 1 | receivers: 2 | opencensus: 3 | endpoint: "0.0.0.0:55678" 4 | 5 | exporters: 6 | jaeger_grpc: 7 | endpoint: jaeger-all-in-one:14250 8 | sending_queue: 9 | batch: 10 | debug: 11 | 12 | processors: 13 | queued_retry: 14 | 15 | service: 16 | pipelines: 17 | traces: 18 | receivers: [opencensus] 19 | exporters: [jaeger_grpc, debug] 20 | processors: [queued_retry] 21 | -------------------------------------------------------------------------------- /opentelemetry-api/test-requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.7.2 2 | importlib-metadata==8.5.0 ; python_version < "3.9" 3 | importlib-metadata==8.7.0 ; python_version >= "3.9" 4 | iniconfig==2.0.0 5 | packaging==24.0 6 | pluggy==1.5.0 7 | py-cpuinfo==9.0.0 8 | pytest==7.4.4 9 | tomli==2.0.1 10 | typing_extensions==4.10.0 11 | wrapt==1.16.0 12 | zipp==3.20.2 13 | -e opentelemetry-sdk 14 | -e opentelemetry-semantic-conventions 15 | -e tests/opentelemetry-test-utils 16 | -e opentelemetry-api 17 | -------------------------------------------------------------------------------- /opentelemetry-api/README.rst: -------------------------------------------------------------------------------- 1 | OpenTelemetry Python API 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opentelemetry-api.svg 7 | :target: https://pypi.org/project/opentelemetry-api/ 8 | 9 | Installation 10 | ------------ 11 | 12 | :: 13 | 14 | pip install opentelemetry-api 15 | 16 | References 17 | ---------- 18 | 19 | * `OpenTelemetry Project `_ 20 | -------------------------------------------------------------------------------- /opentelemetry-sdk/README.rst: -------------------------------------------------------------------------------- 1 | OpenTelemetry Python SDK 2 | ============================================================================ 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opentelemetry-sdk.svg 7 | :target: https://pypi.org/project/opentelemetry-sdk/ 8 | 9 | Installation 10 | ------------ 11 | 12 | :: 13 | 14 | pip install opentelemetry-sdk 15 | 16 | References 17 | ---------- 18 | 19 | * `OpenTelemetry Project `_ 20 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/test-requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.7.2 2 | importlib-metadata==6.11.0 3 | iniconfig==2.0.0 4 | opentracing==2.4.0 5 | packaging==24.0 6 | pluggy==1.5.0 7 | py-cpuinfo==9.0.0 8 | pytest==7.4.4 9 | tomli==2.0.1 10 | typing_extensions==4.10.0 11 | wrapt==1.16.0 12 | zipp==3.19.2 13 | -e opentelemetry-api 14 | -e opentelemetry-sdk 15 | -e tests/opentelemetry-test-utils 16 | -e opentelemetry-semantic-conventions 17 | -e shim/opentelemetry-opentracing-shim 18 | -------------------------------------------------------------------------------- /docs/exporter/zipkin/zipkin.rst: -------------------------------------------------------------------------------- 1 | OpenTelemetry Zipkin Exporters 2 | ============================== 3 | 4 | .. automodule:: opentelemetry.exporter.zipkin 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | 9 | .. automodule:: opentelemetry.exporter.zipkin.json 10 | :members: 11 | :undoc-members: 12 | :show-inheritance: 13 | 14 | .. automodule:: opentelemetry.exporter.zipkin.proto.http 15 | :members: 16 | :undoc-members: 17 | :show-inheritance: 18 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-prometheus/test-requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.7.2 2 | importlib-metadata==6.11.0 3 | iniconfig==2.0.0 4 | packaging==24.0 5 | pluggy==1.5.0 6 | prometheus_client==0.20.0 7 | py-cpuinfo==9.0.0 8 | pytest==7.4.4 9 | tomli==2.0.1 10 | typing_extensions==4.10.0 11 | wrapt==1.16.0 12 | zipp==3.19.2 13 | -e opentelemetry-api 14 | -e opentelemetry-sdk 15 | -e tests/opentelemetry-test-utils 16 | -e opentelemetry-semantic-conventions 17 | -e exporter/opentelemetry-exporter-prometheus 18 | -------------------------------------------------------------------------------- /tests/opentelemetry-test-utils/README.rst: -------------------------------------------------------------------------------- 1 | OpenTelemetry Test Utilities 2 | ============================ 3 | 4 | This package provides internal testing utilities for the OpenTelemetry Python project and provides no stability or quality guarantees. 5 | Please do not use it for anything other than writing or running tests for the OpenTelemetry Python project (github.com/open-telemetry/opentelemetry-python). 6 | 7 | 8 | References 9 | ---------- 10 | * `OpenTelemetry Project `_ 11 | -------------------------------------------------------------------------------- /.github/workflows/fossa.yml: -------------------------------------------------------------------------------- 1 | name: FOSSA scanning 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | permissions: 9 | contents: read 10 | 11 | jobs: 12 | fossa: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 16 | 17 | - uses: fossas/fossa-action@3ebcea1862c6ffbd5cf1b4d0bd6b3fe7bd6f2cac # v1.7.0 18 | with: 19 | api-key: ${{secrets.FOSSA_API_KEY}} 20 | team: OpenTelemetry 21 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-common/test-requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.7.2 2 | importlib-metadata==6.11.0 3 | iniconfig==2.0.0 4 | packaging==24.0 5 | pluggy==1.5.0 6 | protobuf==6.31.1 7 | py-cpuinfo==9.0.0 8 | pytest==7.4.4 9 | tomli==2.0.1 10 | typing_extensions==4.12.0 11 | wrapt==1.16.0 12 | zipp==3.19.2 13 | -e opentelemetry-api 14 | -e opentelemetry-sdk 15 | -e opentelemetry-semantic-conventions 16 | -e tests/opentelemetry-test-utils 17 | -e opentelemetry-proto 18 | -e exporter/opentelemetry-exporter-otlp-proto-common 19 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin/test-requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.7.2 2 | importlib-metadata==6.11.0 3 | iniconfig==2.0.0 4 | packaging==24.0 5 | pluggy==1.5.0 6 | py-cpuinfo==9.0.0 7 | pytest==7.4.4 8 | tomli==2.0.1 9 | typing_extensions==4.10.0 10 | wrapt==1.16.0 11 | zipp==3.19.2 12 | -e opentelemetry-api 13 | -e exporter/opentelemetry-exporter-zipkin-json 14 | -e exporter/opentelemetry-exporter-zipkin-proto-http 15 | -e opentelemetry-sdk 16 | -e opentelemetry-semantic-conventions 17 | -e exporter/opentelemetry-exporter-zipkin 18 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-opencensus/test-requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.7.2 2 | grpcio==1.75.1 3 | importlib-metadata==6.11.0 4 | iniconfig==2.0.0 5 | opencensus-proto==0.1.0 6 | packaging==24.0 7 | pluggy==1.5.0 8 | protobuf==3.20.3 9 | py-cpuinfo==9.0.0 10 | pytest==7.4.4 11 | tomli==2.0.1 12 | typing_extensions==4.12.0 13 | wrapt==1.16.0 14 | zipp==3.19.2 15 | -e opentelemetry-api 16 | -e opentelemetry-sdk 17 | -e tests/opentelemetry-test-utils 18 | -e opentelemetry-semantic-conventions 19 | -e exporter/opentelemetry-exporter-opencensus 20 | -------------------------------------------------------------------------------- /dev-requirements.txt: -------------------------------------------------------------------------------- 1 | pylint==3.3.4 2 | httpretty==1.1.4 3 | pyright==1.1.405 4 | sphinx==7.1.2 5 | sphinx-rtd-theme==2.0.0rc4 6 | sphinx-autodoc-typehints==1.25.2 7 | pytest==7.4.4 8 | pytest-cov==4.1.0 9 | readme-renderer==42.0 10 | markupsafe==2.1.3 11 | bleach==4.1.0 # This dependency was updated to a breaking version. 12 | codespell==2.1.0 13 | requests==2.32.3 14 | ruamel.yaml==0.17.21 15 | asgiref==3.7.2 16 | psutil==5.9.6 17 | GitPython==3.1.41 18 | pre-commit==3.7.0; python_version >= '3.9' 19 | pre-commit==3.5.0; python_version < '3.9' 20 | ruff==0.14.1 21 | -------------------------------------------------------------------------------- /docs/examples/fork-process-model/flask-uwsgi/requirements.txt: -------------------------------------------------------------------------------- 1 | click==8.1.7 2 | Flask==2.3.3 3 | googleapis-common-protos==1.52.0 4 | grpcio==1.56.2 5 | itsdangerous==2.1.2 6 | Jinja2==3.1.6 7 | MarkupSafe==2.1.3 8 | opentelemetry-api==1.20.0 9 | opentelemetry-exporter-otlp==1.20.0 10 | opentelemetry-instrumentation==0.41b0 11 | opentelemetry-instrumentation-flask==0.41b0 12 | opentelemetry-instrumentation-wsgi==0.41b0 13 | opentelemetry-sdk==1.20.0 14 | protobuf==3.20.3 15 | six==1.15.0 16 | thrift==0.13.0 17 | uWSGI==2.0.22 18 | Werkzeug==3.0.6 19 | wrapt==1.16.0 20 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin-json/test-requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.7.2 2 | certifi==2024.7.4 3 | charset-normalizer==3.3.2 4 | idna==3.7 5 | importlib-metadata==6.11.0 6 | iniconfig==2.0.0 7 | packaging==24.0 8 | pluggy==1.5.0 9 | py-cpuinfo==9.0.0 10 | pytest==7.4.4 11 | requests==2.32.3 12 | tomli==2.0.1 13 | typing_extensions==4.10.0 14 | urllib3==2.2.2 15 | wrapt==1.16.0 16 | zipp==3.19.2 17 | -e opentelemetry-api 18 | -e opentelemetry-sdk 19 | -e opentelemetry-semantic-conventions 20 | -e tests/opentelemetry-test-utils 21 | -e exporter/opentelemetry-exporter-zipkin-json 22 | -------------------------------------------------------------------------------- /docs/examples/fork-process-model/flask-gunicorn/requirements.txt: -------------------------------------------------------------------------------- 1 | click==8.1.7 2 | Flask==2.3.3 3 | googleapis-common-protos==1.52.0 4 | grpcio==1.56.2 5 | gunicorn==22.0.0 6 | itsdangerous==2.1.2 7 | Jinja2==3.1.6 8 | MarkupSafe==2.1.3 9 | opentelemetry-api==1.20.0 10 | opentelemetry-exporter-otlp==1.20.0 11 | opentelemetry-instrumentation==0.41b0 12 | opentelemetry-instrumentation-flask==0.41b0 13 | opentelemetry-instrumentation-wsgi==0.41b0 14 | opentelemetry-sdk==1.20.0 15 | protobuf==3.20.3 16 | six==1.15.0 17 | thrift==0.13.0 18 | uWSGI==2.0.22 19 | Werkzeug==3.0.6 20 | wrapt==1.16.0 21 | -------------------------------------------------------------------------------- /docs/examples/opencensus-exporter-tracer/docker/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | services: 3 | 4 | # Collector 5 | collector: 6 | image: omnition/opentelemetry-collector-contrib:latest 7 | command: ["--config=/conf/collector-config.yaml", "--log-level=DEBUG"] 8 | volumes: 9 | - ./collector-config.yaml:/conf/collector-config.yaml 10 | ports: 11 | - "55678:55678" 12 | 13 | jaeger-all-in-one: 14 | image: jaegertracing/all-in-one:latest 15 | ports: 16 | - "16686:16686" 17 | - "6831:6831/udp" 18 | - "6832:6832/udp" 19 | - "14268" 20 | - "14250" 21 | -------------------------------------------------------------------------------- /propagator/opentelemetry-propagator-b3/README.rst: -------------------------------------------------------------------------------- 1 | OpenTelemetry B3 Propagator 2 | =========================== 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opentelemetry-propagator-b3.svg 7 | :target: https://pypi.org/project/opentelemetry-propagator-b3/ 8 | 9 | This library provides a propagator for the B3 format 10 | 11 | Installation 12 | ------------ 13 | 14 | :: 15 | 16 | pip install opentelemetry-propagator-b3 17 | 18 | 19 | References 20 | ---------- 21 | 22 | * `OpenTelemetry `_ 23 | * `B3 format `_ 24 | -------------------------------------------------------------------------------- /shim/opentelemetry-opencensus-shim/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus Shim for OpenTelemetry 2 | ================================== 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opentelemetry-opencensus-shim.svg 7 | :target: https://pypi.org/project/opentelemetry-opencensus-shim/ 8 | 9 | Installation 10 | ------------ 11 | 12 | :: 13 | 14 | pip install opentelemetry-opencensus-shim 15 | 16 | References 17 | ---------- 18 | 19 | * `OpenCensus Shim for OpenTelemetry `_ 20 | * `OpenTelemetry Project `_ 21 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Keep GitHub Actions up to date with GitHub's Dependabot... 2 | # https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot 3 | # https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem 4 | version: 2 5 | updates: 6 | - package-ecosystem: github-actions 7 | directory: / 8 | groups: 9 | github-actions: 10 | patterns: 11 | - "*" # Group all Actions updates into a single larger pull request 12 | schedule: 13 | interval: weekly 14 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/README.rst: -------------------------------------------------------------------------------- 1 | OpenTracing Shim for OpenTelemetry 2 | ================================== 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opentelemetry-opentracing-shim.svg 7 | :target: https://pypi.org/project/opentelemetry-opentracing-shim/ 8 | 9 | Installation 10 | ------------ 11 | 12 | :: 13 | 14 | pip install opentelemetry-opentracing-shim 15 | 16 | References 17 | ---------- 18 | 19 | * `OpenTracing Shim for OpenTelemetry `_ 20 | * `OpenTelemetry Project `_ 21 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp/test-requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.7.2 2 | importlib-metadata==6.11.0 3 | iniconfig==2.0.0 4 | packaging==24.0 5 | pluggy==1.5.0 6 | py-cpuinfo==9.0.0 7 | pytest==7.4.4 8 | tomli==2.0.1 9 | typing_extensions==4.12.0 10 | wrapt==1.16.0 11 | zipp==3.19.2 12 | -e opentelemetry-api 13 | -e tests/opentelemetry-test-utils 14 | -e exporter/opentelemetry-exporter-otlp-proto-common 15 | -e exporter/opentelemetry-exporter-otlp-proto-grpc 16 | -e exporter/opentelemetry-exporter-otlp-proto-http 17 | -e opentelemetry-proto 18 | -e opentelemetry-sdk 19 | -e opentelemetry-semantic-conventions 20 | -e exporter/opentelemetry-exporter-otlp 21 | -------------------------------------------------------------------------------- /docs/getting_started/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /opentelemetry-api/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /opentelemetry-sdk/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SOURCEDIR = . 8 | BUILDDIR = _build 9 | 10 | # Put it first so that "make" without argument is like "make help". 11 | help: 12 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 13 | 14 | .PHONY: help Makefile 15 | 16 | # Catch-all target: route all unknown targets to Sphinx using the new 17 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 18 | %: Makefile 19 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 20 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin-proto-http/test-requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.7.2 2 | certifi==2024.7.4 3 | charset-normalizer==3.3.2 4 | idna==3.7 5 | importlib-metadata==6.11.0 6 | iniconfig==2.0.0 7 | packaging==24.0 8 | pluggy==1.5.0 9 | protobuf==3.20.3 10 | py-cpuinfo==9.0.0 11 | pytest==7.4.4 12 | requests==2.32.3 13 | tomli==2.0.1 14 | typing_extensions==4.10.0 15 | urllib3==2.2.2 16 | wrapt==1.16.0 17 | zipp==3.19.2 18 | -e opentelemetry-api 19 | -e exporter/opentelemetry-exporter-zipkin-json 20 | -e opentelemetry-sdk 21 | -e tests/opentelemetry-test-utils 22 | -e opentelemetry-semantic-conventions 23 | -e exporter/opentelemetry-exporter-zipkin-proto-http 24 | -------------------------------------------------------------------------------- /opentelemetry-api/tests/trace/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /opentelemetry-sdk/tests/events/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /opentelemetry-sdk/tests/logs/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /opentelemetry-sdk/tests/trace/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /opentelemetry-sdk/tests/trace/export/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /tests/opentelemetry-test-utils/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /opentelemetry-sdk/tests/shared_internal/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /propagator/opentelemetry-propagator-jaeger/README.rst: -------------------------------------------------------------------------------- 1 | OpenTelemetry Jaeger Propagator 2 | =============================== 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opentelemetry-propagator-jaeger.svg 7 | :target: https://pypi.org/project/opentelemetry-propagator-jaeger/ 8 | 9 | This library provides a propagator for the Jaeger format 10 | 11 | Installation 12 | ------------ 13 | 14 | :: 15 | 16 | pip install opentelemetry-propagator-jaeger 17 | 18 | 19 | References 20 | ---------- 21 | 22 | * `OpenTelemetry `_ 23 | * `Jaeger format `_ 24 | -------------------------------------------------------------------------------- /opentelemetry-api/tests/distributedcontext/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /propagator/opentelemetry-propagator-b3/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /docs/examples/error_handler/example.py: -------------------------------------------------------------------------------- 1 | from opentelemetry.sdk.error_handler import GlobalErrorHandler 2 | 3 | # ZeroDivisionError to be handled by ErrorHandler0 4 | with GlobalErrorHandler(): 5 | 1 / 0 6 | 7 | print() 8 | 9 | # IndexError to be handled by ErrorHandler1 10 | with GlobalErrorHandler(): 11 | [1][2] 12 | 13 | print() 14 | 15 | # KeyError to be handled by ErrorHandler1 16 | with GlobalErrorHandler(): 17 | {1: 2}[2] 18 | 19 | print() 20 | 21 | # AssertionError to be handled by DefaultErrorHandler 22 | with GlobalErrorHandler(): 23 | assert False 24 | 25 | print() 26 | 27 | # No error raised 28 | with GlobalErrorHandler(): 29 | print("No error raised") 30 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-prometheus/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin-json/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /propagator/opentelemetry-propagator-jaeger/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin-proto-http/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/astral-sh/ruff-pre-commit 3 | # Ruff version. 4 | rev: v0.14.1 5 | hooks: 6 | # Run the linter. 7 | - id: ruff 8 | args: ["--fix", "--show-fixes"] 9 | # Run the formatter. 10 | - id: ruff-format 11 | - repo: https://github.com/astral-sh/uv-pre-commit 12 | # uv version. 13 | rev: 0.6.0 14 | hooks: 15 | - id: uv-lock 16 | - repo: https://github.com/rstcheck/rstcheck 17 | rev: 77490ffa33bfc0928975ae3cf904219903db755d # frozen: v6.2.5 18 | hooks: 19 | - id: rstcheck 20 | additional_dependencies: ['rstcheck[sphinx]'] 21 | args: ["--report-level", "warning"] 22 | -------------------------------------------------------------------------------- /opentelemetry-api/src/opentelemetry/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "1.40.0.dev" 16 | -------------------------------------------------------------------------------- /docs/examples/django/pages/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | default_app_config = "pages.apps.PagesConfig" 16 | -------------------------------------------------------------------------------- /opentelemetry-sdk/src/opentelemetry/sdk/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "1.40.0.dev" 16 | -------------------------------------------------------------------------------- /opentelemetry-proto/src/opentelemetry/proto/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "1.40.0.dev" 16 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "0.61b0.dev" 16 | -------------------------------------------------------------------------------- /docs/examples/error_handler/error_handler_0/src/error_handler_0/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "0.23.dev0" 16 | -------------------------------------------------------------------------------- /docs/examples/error_handler/error_handler_1/src/error_handler_1/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "0.23.dev0" 16 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp/src/opentelemetry/exporter/otlp/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "1.40.0.dev" 16 | -------------------------------------------------------------------------------- /shim/opentelemetry-opencensus-shim/src/opentelemetry/shim/opencensus/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "0.61b0.dev" 16 | -------------------------------------------------------------------------------- /docs/getting_started/tests/requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.7.2 2 | attrs==23.1.0 3 | certifi==2024.7.4 4 | charset-normalizer==2.0.12 5 | click==8.1.7 6 | Flask==2.3.3 7 | idna==3.7 8 | importlib-metadata==6.8.0 9 | iniconfig==2.0.0 10 | itsdangerous==2.1.2 11 | Jinja2==3.1.5 12 | MarkupSafe==2.1.3 13 | packaging==24.0 14 | pluggy==1.3.0 15 | py-cpuinfo==9.0.0 16 | pytest==7.4.4 17 | requests==2.32.3 18 | tomli==2.0.1 19 | typing_extensions==4.12.0 20 | urllib3==1.26.19 21 | Werkzeug==3.0.6 22 | wrapt==1.15.0 23 | zipp==3.19.2 24 | -e opentelemetry-semantic-conventions 25 | -e opentelemetry-proto 26 | -e exporter/opentelemetry-exporter-otlp-proto-common 27 | -e exporter/opentelemetry-exporter-otlp-proto-grpc 28 | -e opentelemetry-api 29 | -e opentelemetry-sdk 30 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin/src/opentelemetry/exporter/zipkin/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "1.40.0.dev" 16 | -------------------------------------------------------------------------------- /propagator/opentelemetry-propagator-b3/src/opentelemetry/propagators/b3/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "1.40.0.dev" 16 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/src/opentelemetry/shim/opentracing_shim/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "0.61b0.dev" 16 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-opencensus/src/opentelemetry/exporter/opencensus/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "0.61b0.dev" 16 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "0.61b0.dev" 16 | -------------------------------------------------------------------------------- /propagator/opentelemetry-propagator-jaeger/src/opentelemetry/propagators/jaeger/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "1.40.0.dev" 16 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin-json/src/opentelemetry/exporter/zipkin/json/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "1.40.0.dev" 16 | -------------------------------------------------------------------------------- /docs/examples/django/pages/apps.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | from django.apps import AppConfig 15 | 16 | 17 | class PagesConfig(AppConfig): 18 | name = "pages" 19 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-opencensus/README.rst: -------------------------------------------------------------------------------- 1 | OpenCensus Exporter 2 | =================== 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opentelemetry-exporter-opencensus.svg 7 | :target: https://pypi.org/project/opentelemetry-exporter-opencensus/ 8 | 9 | This library allows to export traces using OpenCensus. 10 | 11 | Installation 12 | ------------ 13 | 14 | :: 15 | 16 | pip install opentelemetry-exporter-opencensus 17 | 18 | 19 | References 20 | ---------- 21 | 22 | * `OpenCensus Exporter `_ 23 | * `OpenTelemetry Collector `_ 24 | * `OpenTelemetry `_ 25 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "1.40.0.dev" 16 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "1.40.0.dev" 16 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "1.40.0.dev" 16 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-http/test-requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.7.2 2 | certifi==2024.7.4 3 | charset-normalizer==3.3.2 4 | googleapis-common-protos==1.70.0 5 | idna==3.7 6 | importlib-metadata==6.11.0 7 | iniconfig==2.0.0 8 | packaging==24.0 9 | pluggy==1.5.0 10 | protobuf==6.31.1 11 | py-cpuinfo==9.0.0 12 | pytest==7.4.4 13 | PyYAML==6.0.1 14 | requests==2.32.3 15 | responses==0.24.1 16 | tomli==2.0.1 17 | typing_extensions==4.12.0 18 | urllib3==2.2.2 19 | wrapt==1.16.0 20 | zipp==3.19.2 21 | -e opentelemetry-api 22 | -e tests/opentelemetry-test-utils 23 | -e exporter/opentelemetry-exporter-otlp-proto-common 24 | -e opentelemetry-proto 25 | -e opentelemetry-sdk 26 | -e opentelemetry-semantic-conventions 27 | -e exporter/opentelemetry-exporter-otlp-proto-http 28 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin-proto-http/src/opentelemetry/exporter/zipkin/proto/http/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "1.40.0.dev" 16 | -------------------------------------------------------------------------------- /opentelemetry-sdk/src/opentelemetry/sdk/__init__.pyi: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """ 16 | The OpenTelemetry SDK package is an implementation of the OpenTelemetry 17 | API 18 | """ 19 | -------------------------------------------------------------------------------- /docs/examples/django/pages/urls.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | from django.urls import path 15 | 16 | from .views import home_page_view 17 | 18 | urlpatterns = [path("", home_page_view, name="home")] 19 | -------------------------------------------------------------------------------- /opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | class MetricsTimeoutError(Exception): 17 | """Raised when a metrics function times out""" 18 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin-json/README.rst: -------------------------------------------------------------------------------- 1 | OpenTelemetry Zipkin JSON Exporter 2 | ================================== 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opentelemetry-exporter-zipkin-json.svg 7 | :target: https://pypi.org/project/opentelemetry-exporter-zipkin-json/ 8 | 9 | This library allows export of tracing data to `Zipkin `_ using JSON 10 | for serialization. 11 | 12 | Installation 13 | ------------ 14 | 15 | :: 16 | 17 | pip install opentelemetry-exporter-zipkin-json 18 | 19 | 20 | References 21 | ---------- 22 | 23 | * `OpenTelemetry Zipkin Exporter `_ 24 | * `Zipkin `_ 25 | * `OpenTelemetry Project `_ 26 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-opencensus/src/opentelemetry/exporter/opencensus/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """ 16 | The **OpenCensus Exporter** allows to export traces using OpenCensus. 17 | """ 18 | -------------------------------------------------------------------------------- /opentelemetry-api/tests/mypysmoke.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import opentelemetry.trace 16 | 17 | 18 | def dummy_check_mypy_returntype() -> opentelemetry.trace.TracerProvider: 19 | return opentelemetry.trace.get_tracer_provider() 20 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/tests/testbed/test_active_span_replacement/README.rst: -------------------------------------------------------------------------------- 1 | 2 | Active Span replacement example. 3 | ================================ 4 | 5 | This example shows a ``Span`` being created and then passed to an asynchronous task, which will temporary activate it to finish its processing, and further restore the previously active ``Span``. 6 | 7 | ``threading`` implementation: 8 | 9 | .. code-block:: python 10 | 11 | # Create a new Span for this task 12 | with self.tracer.start_active_span("task"): 13 | 14 | with self.tracer.scope_manager.activate(span, True): 15 | # Simulate work strictly related to the initial Span 16 | pass 17 | 18 | # Use the task span as parent of a new subtask 19 | with self.tracer.start_active_span("subtask"): 20 | pass 21 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin-proto-http/README.rst: -------------------------------------------------------------------------------- 1 | OpenTelemetry Zipkin Protobuf Exporter 2 | ====================================== 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opentelemetry-exporter-zipkin-proto-http.svg 7 | :target: https://pypi.org/project/opentelemetry-exporter-zipkin-proto-http/ 8 | 9 | This library allows export of tracing data to `Zipkin `_ using Protobuf 10 | for serialization. 11 | 12 | Installation 13 | ------------ 14 | 15 | :: 16 | 17 | pip install opentelemetry-exporter-zipkin-proto-http 18 | 19 | 20 | References 21 | ---------- 22 | 23 | * `OpenTelemetry Zipkin Exporter `_ 24 | * `Zipkin `_ 25 | * `OpenTelemetry Project `_ 26 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from opentelemetry.exporter.otlp.proto.common.version import __version__ 17 | 18 | __all__ = ["__version__"] 19 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-common/README.rst: -------------------------------------------------------------------------------- 1 | OpenTelemetry Protobuf Encoding 2 | =============================== 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opentelemetry-exporter-otlp-proto-common.svg 7 | :target: https://pypi.org/project/opentelemetry-exporter-otlp-proto-common/ 8 | 9 | This library is provided as a convenience to encode to Protobuf. Currently used by: 10 | 11 | * opentelemetry-exporter-otlp-proto-grpc 12 | * opentelemetry-exporter-otlp-proto-http 13 | 14 | 15 | Installation 16 | ------------ 17 | 18 | :: 19 | 20 | pip install opentelemetry-exporter-otlp-proto-common 21 | 22 | 23 | References 24 | ---------- 25 | 26 | * `OpenTelemetry `_ 27 | * `OpenTelemetry Protocol Specification `_ 28 | -------------------------------------------------------------------------------- /opentelemetry-api/tests/events/test_event.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from opentelemetry._events import Event 4 | 5 | 6 | class TestEvent(unittest.TestCase): 7 | def test_event(self): 8 | event = Event("example", 123, attributes={"key": "value"}) 9 | self.assertEqual(event.name, "example") 10 | self.assertEqual(event.timestamp, 123) 11 | self.assertEqual( 12 | event.attributes, {"key": "value", "event.name": "example"} 13 | ) 14 | 15 | def test_event_name_copied_in_attributes(self): 16 | event = Event("name", 123) 17 | self.assertEqual(event.attributes, {"event.name": "name"}) 18 | 19 | def test_event_name_has_precedence_over_attributes(self): 20 | event = Event("name", 123, attributes={"event.name": "attr value"}) 21 | self.assertEqual(event.attributes, {"event.name": "name"}) 22 | -------------------------------------------------------------------------------- /shim/opentelemetry-opencensus-shim/test-requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.7.2 2 | cachetools==5.3.3 3 | certifi==2024.7.4 4 | charset-normalizer==3.3.2 5 | google-api-core==2.17.1 6 | google-auth==2.28.1 7 | googleapis-common-protos==1.63.2 8 | grpcio==1.75.1 9 | idna==3.7 10 | importlib-metadata==6.11.0 11 | iniconfig==2.0.0 12 | opencensus==0.11.1 13 | opencensus-context==0.1.3 14 | opencensus-proto==0.1.0 15 | packaging==24.0 16 | pluggy==1.5.0 17 | protobuf==3.20.3 18 | py-cpuinfo==9.0.0 19 | pyasn1==0.5.1 20 | pyasn1-modules==0.3.0 21 | pytest==7.4.4 22 | requests==2.32.3 23 | rsa==4.9 24 | six==1.16.0 25 | tomli==2.0.1 26 | typing_extensions==4.12.0 27 | urllib3==2.2.2 28 | wrapt==1.16.0 29 | zipp==3.19.2 30 | -e opentelemetry-api 31 | -e opentelemetry-sdk 32 | -e tests/opentelemetry-test-utils 33 | -e opentelemetry-semantic-conventions 34 | -e shim/opentelemetry-opencensus-shim 35 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/tests/testbed/test_listener_per_request/README.rst: -------------------------------------------------------------------------------- 1 | 2 | Listener Response example. 3 | ========================== 4 | 5 | This example shows a ``Span`` created upon a message being sent to a ``Client``, and its handling along a related, **not shared** ``ResponseListener`` object with a ``on_response(self, response)`` method to finish it. 6 | 7 | .. code-block:: python 8 | 9 | def _task(self, message, listener): 10 | res = "%s::response" % message 11 | listener.on_response(res) 12 | return res 13 | 14 | def send_sync(self, message): 15 | span = self.tracer.start_span("send") 16 | span.set_tag(tags.SPAN_KIND, tags.SPAN_KIND_RPC_CLIENT) 17 | 18 | listener = ResponseListener(span) 19 | return self.executor.submit(self._task, message, listener).result() 20 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/pool_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | POOL_NAME: Final = "pool.name" 18 | """ 19 | Deprecated: Replaced by `db.client.connection.pool.name`. 20 | """ 21 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_log_encoder.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from opentelemetry.exporter.otlp.proto.common._internal._log_encoder import ( 17 | encode_logs, 18 | ) 19 | 20 | __all__ = ["encode_logs"] 21 | -------------------------------------------------------------------------------- /.github/workflows/contrib.yml: -------------------------------------------------------------------------------- 1 | name: Core Contrib Test 2 | 3 | on: 4 | push: 5 | branches-ignore: 6 | - 'release/*' 7 | - 'otelbot/*' 8 | pull_request: 9 | 10 | permissions: 11 | contents: read 12 | 13 | concurrency: 14 | group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} 15 | cancel-in-progress: true 16 | 17 | jobs: 18 | contrib_0: 19 | uses: open-telemetry/opentelemetry-python-contrib/.github/workflows/core_contrib_test_0.yml@main 20 | with: 21 | CORE_REPO_SHA: ${{ github.sha }} 22 | CONTRIB_REPO_SHA: ${{ github.event_name == 'pull_request' && ( 23 | contains(github.event.pull_request.labels.*.name, 'prepare-release') && github.event.pull_request.head.ref || 24 | contains(github.event.pull_request.labels.*.name, 'backport') && github.event.pull_request.base.ref || 25 | 'main' 26 | ) || 'main' }} 27 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/trace_encoder.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from opentelemetry.exporter.otlp.proto.common._internal.trace_encoder import ( 17 | encode_spans, 18 | ) 19 | 20 | __all__ = ["encode_spans"] 21 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/tests/testbed/test_late_span_finish/README.rst: -------------------------------------------------------------------------------- 1 | 2 | Late Span finish example. 3 | ========================= 4 | 5 | This example shows a ``Span`` for a top-level operation, with independent, unknown lifetime, acting as parent of a few asynchronous subtasks (which must re-activate it but not finish it). 6 | 7 | .. code-block:: python 8 | 9 | # Fire away a few subtasks, passing a parent Span whose lifetime 10 | # is not tied at all to the children. 11 | def submit_subtasks(self, parent_span): 12 | def task(name, interval): 13 | with self.tracer.scope_manager.activate(parent_span, False): 14 | with self.tracer.start_active_span(name): 15 | time.sleep(interval) 16 | 17 | self.executor.submit(task, "task1", 0.1) 18 | self.executor.submit(task, "task2", 0.3) 19 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/metrics_encoder.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from opentelemetry.exporter.otlp.proto.common._internal.metrics_encoder import ( 17 | encode_metrics, 18 | ) 19 | 20 | __all__ = ["encode_metrics"] 21 | -------------------------------------------------------------------------------- /tests/opentelemetry-test-utils/src/opentelemetry/test/mock_test_classes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | class IterEntryPoint: 17 | def __init__(self, name, class_type): 18 | self.name = name 19 | self.class_type = class_type 20 | 21 | def load(self): 22 | return self.class_type 23 | -------------------------------------------------------------------------------- /docs-requirements.txt: -------------------------------------------------------------------------------- 1 | sphinx==7.1.2 2 | sphinx-rtd-theme==2.0.0rc4 3 | sphinx-autodoc-typehints==1.25.2 4 | # used to generate docs for the website 5 | sphinx-jekyll-builder==0.3.0 6 | 7 | # Need to install the api/sdk in the venv for autodoc. Modifying sys.path 8 | # doesn't work for pkg_resources. 9 | ./opentelemetry-api 10 | ./opentelemetry-semantic-conventions 11 | ./opentelemetry-sdk 12 | ./opentelemetry-proto 13 | ./shim/opentelemetry-opencensus-shim 14 | ./shim/opentelemetry-opentracing-shim 15 | ./exporter/opentelemetry-exporter-otlp-proto-common 16 | ./exporter/opentelemetry-exporter-otlp-proto-http 17 | ./exporter/opentelemetry-exporter-otlp-proto-grpc 18 | 19 | # Required by instrumentation and exporter packages 20 | grpcio~=1.27 21 | Deprecated~=1.2 22 | django~=4.2 23 | flask~=2.3 24 | opentracing~=2.2.0 25 | thrift~=0.10 26 | wrapt>=1.0.0,<2.0.0 27 | markupsafe~=2.0 28 | protobuf==5.29.5 29 | prometheus-client~=0.22.1 30 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/mainframe_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | MAINFRAME_LPAR_NAME: Final = "mainframe.lpar.name" 18 | """ 19 | Name of the logical partition that hosts a systems with a mainframe operating system. 20 | """ 21 | -------------------------------------------------------------------------------- /tests/opentelemetry-test-utils/tests/test_base.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from opentelemetry.test.test_base import TestBase 16 | 17 | 18 | class TestBaseTestCase(TestBase): 19 | def test_get_sorted_metrics_works_without_metrics(self): 20 | metrics = self.get_sorted_metrics() 21 | self.assertEqual(metrics, []) 22 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/elasticsearch_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | ELASTICSEARCH_NODE_NAME: Final = "elasticsearch.node.name" 18 | """ 19 | Represents the human-readable identifier of the node/instance to which a request was routed. 20 | """ 21 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/user_agent_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | USER_AGENT_ORIGINAL: Final = "user_agent.original" 18 | """ 19 | Value of the [HTTP User-Agent](https://www.rfc-editor.org/rfc/rfc9110.html#field.user-agent) header sent by the client. 20 | """ 21 | -------------------------------------------------------------------------------- /docs/examples/auto-instrumentation/server_automatic.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from flask import Flask, request 16 | 17 | app = Flask(__name__) 18 | 19 | 20 | @app.route("/server_request") 21 | def server_request(): 22 | print(request.args.get("param")) 23 | return "served" 24 | 25 | 26 | if __name__ == "__main__": 27 | app.run(port=8082) 28 | -------------------------------------------------------------------------------- /docs/examples/basic_tracer/README.rst: -------------------------------------------------------------------------------- 1 | Basic Trace 2 | =========== 3 | 4 | These examples show how to use OpenTelemetry to create and export Spans. There are two different examples: 5 | 6 | * basic_trace: Shows how to configure a SpanProcessor and Exporter, and how to create a tracer and span. 7 | * resources: Shows how to add resource information to a Provider. 8 | 9 | The source files of these examples are available :scm_web:`here `. 10 | 11 | Installation 12 | ------------ 13 | 14 | .. code-block:: sh 15 | 16 | pip install opentelemetry-api 17 | pip install opentelemetry-sdk 18 | 19 | Run the Example 20 | --------------- 21 | 22 | .. code-block:: sh 23 | 24 | python .py 25 | 26 | The output will be shown in the console. 27 | 28 | Useful links 29 | ------------ 30 | 31 | - OpenTelemetry_ 32 | - :doc:`../../api/trace` 33 | 34 | .. _OpenTelemetry: https://github.com/open-telemetry/opentelemetry-python/ 35 | -------------------------------------------------------------------------------- /opentelemetry-proto/tests/test_proto.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # type: ignore 15 | 16 | from importlib.util import find_spec 17 | from unittest import TestCase 18 | 19 | 20 | class TestInstrumentor(TestCase): 21 | def test_proto(self): 22 | if find_spec("opentelemetry.proto") is None: 23 | self.fail("opentelemetry-proto not installed") 24 | -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script builds wheels for the API, SDK, and extension packages in the 4 | # dist/ dir, to be uploaded to PyPI. 5 | 6 | set -ev 7 | 8 | # Get the latest versions of packaging tools 9 | python3 -m pip install --upgrade pip build setuptools wheel 10 | 11 | BASEDIR=$(dirname "$(readlink -f "$(dirname $0)")") 12 | DISTDIR=dist 13 | 14 | ( 15 | cd $BASEDIR 16 | mkdir -p $DISTDIR 17 | rm -rf ${DISTDIR:?}/* 18 | 19 | for d in opentelemetry-api/ opentelemetry-sdk/ opentelemetry-proto/ opentelemetry-semantic-conventions/ exporter/*/ shim/*/ propagator/*/ tests/opentelemetry-test-utils/; do 20 | ( 21 | echo "building $d" 22 | cd "$d" 23 | # Some ext directories (such as docker tests) are not intended to be 24 | # packaged. Verify the intent by looking for a pyproject.toml. 25 | if [ -f pyproject.toml ]; then 26 | python3 -m build --outdir "$BASEDIR/dist/" 27 | fi 28 | ) 29 | done 30 | ) 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[cod] 2 | *.sw[op] 3 | 4 | # C extensions 5 | *.so 6 | 7 | # Packages 8 | *.egg 9 | *.egg-info 10 | dist 11 | build 12 | eggs 13 | parts 14 | bin 15 | include 16 | var 17 | sdist 18 | develop-eggs 19 | .installed.cfg 20 | pyvenv.cfg 21 | lib 22 | share/ 23 | lib64 24 | __pycache__ 25 | venv*/ 26 | .venv*/ 27 | 28 | # Installer logs 29 | pip-log.txt 30 | 31 | # Unit test / coverage reports 32 | coverage.xml 33 | .coverage 34 | .nox 35 | .tox 36 | .cache 37 | htmlcov 38 | 39 | # Translations 40 | *.mo 41 | 42 | # Mac 43 | .DS_Store 44 | 45 | # Mr Developer 46 | .mr.developer.cfg 47 | .project 48 | .pydevproject 49 | 50 | # JetBrains 51 | .idea 52 | 53 | # VSCode 54 | .vscode 55 | 56 | # Sphinx 57 | _build/ 58 | 59 | # mypy 60 | .mypy_cache/ 61 | target 62 | 63 | # Django example 64 | 65 | docs/examples/django/db.sqlite3 66 | 67 | # Semantic conventions 68 | scripts/semconv/semantic-conventions 69 | 70 | # Benchmark result files 71 | *-benchmark.json 72 | -------------------------------------------------------------------------------- /docs/examples/metrics/prometheus-grafana/prometheus-monitor.py: -------------------------------------------------------------------------------- 1 | import random 2 | import time 3 | 4 | from prometheus_client import start_http_server 5 | 6 | from opentelemetry.exporter.prometheus import PrometheusMetricReader 7 | from opentelemetry.metrics import get_meter_provider, set_meter_provider 8 | from opentelemetry.sdk.metrics import MeterProvider 9 | 10 | # Start Prometheus client 11 | start_http_server(port=8000, addr="localhost") 12 | # Exporter to export metrics to Prometheus 13 | prefix = "MyAppPrefix" 14 | reader = PrometheusMetricReader(prefix) 15 | # Meter is responsible for creating and recording metrics 16 | set_meter_provider(MeterProvider(metric_readers=[reader])) 17 | meter = get_meter_provider().get_meter("view-name-change", "0.1.2") 18 | 19 | my_counter = meter.create_counter("my.counter") 20 | 21 | print("Server is running at http://localhost:8000") 22 | 23 | while 1: 24 | my_counter.add(random.randint(1, 10)) 25 | time.sleep(random.random()) 26 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/tests/testbed/test_client_server/README.rst: -------------------------------------------------------------------------------- 1 | 2 | Client-Server example. 3 | ====================== 4 | 5 | This example shows a ``Span`` created by a ``Client``, which will send a ``Message`` / ``SpanContext`` to a ``Server``, which will in turn extract such context and use it as parent of a new (server-side) ``Span``. 6 | 7 | ``Client.send()`` is used to send messages and inject the ``SpanContext`` using the ``TEXT_MAP`` format, and ``Server.process()`` will process received messages and will extract the context used as parent. 8 | 9 | .. code-block:: python 10 | 11 | def send(self): 12 | with self.tracer.start_active_span("send") as scope: 13 | scope.span.set_tag(tags.SPAN_KIND, tags.SPAN_KIND_RPC_CLIENT) 14 | 15 | message = {} 16 | self.tracer.inject(scope.span.context, 17 | opentracing.Format.TEXT_MAP, 18 | message) 19 | self.queue.put(message) 20 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/event_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | EVENT_NAME: Final = "event.name" 18 | """ 19 | Deprecated: The value of this attribute MUST now be set as the value of the EventName field on the LogRecord to indicate that the LogRecord represents an Event. 20 | """ 21 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/metrics/db_metrics.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from typing import Final 17 | 18 | DB_CLIENT_OPERATION_DURATION: Final = "db.client.operation.duration" 19 | """ 20 | Duration of database client operations 21 | Instrument: histogram 22 | Unit: s 23 | Note: Batch operations SHOULD be recorded as a single operation. 24 | """ 25 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/session_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | SESSION_ID: Final = "session.id" 18 | """ 19 | A unique id to identify a session. 20 | """ 21 | 22 | SESSION_PREVIOUS_ID: Final = "session.previous_id" 23 | """ 24 | The previous `session.id` for this user, when known. 25 | """ 26 | -------------------------------------------------------------------------------- /docs/examples/sqlcommenter/books_database/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mysql:8.0 2 | 3 | ENV MYSQL_ROOT_PASSWORD=root 4 | ENV MYSQL_DATABASE=books 5 | 6 | ADD books.sql /docker-entrypoint-initdb.d/ 7 | 8 | RUN echo "CREATE USER IF NOT EXISTS 'books'@'%' IDENTIFIED WITH mysql_native_password BY 'books123';" > /docker-entrypoint-initdb.d/01-create-user.sql && \ 9 | echo "GRANT ALL PRIVILEGES ON books.* TO 'books'@'%';" >> /docker-entrypoint-initdb.d/01-create-user.sql && \ 10 | echo "FLUSH PRIVILEGES;" >> /docker-entrypoint-initdb.d/01-create-user.sql 11 | 12 | # Prepare general logs 13 | RUN mkdir -p /var/log && \ 14 | touch /var/log/general.log && \ 15 | chown mysql:mysql /var/log/general.log 16 | 17 | EXPOSE 3306 18 | 19 | HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \ 20 | CMD mysqladmin ping -p${MYSQL_ROOT_PASSWORD} || exit 1 21 | 22 | # Start MySQL with general logging enabled and compatible authentication 23 | CMD ["mysqld", "--general-log=1", "--general-log-file=/var/log/general.log"] -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/tests/test_semconv.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # type: ignore 15 | 16 | from importlib.util import find_spec 17 | from unittest import TestCase 18 | 19 | 20 | class TestSemanticConventions(TestCase): 21 | def test_semantic_conventions(self): 22 | if find_spec("opentelemetry.semconv") is None: 23 | self.fail("opentelemetry-semantic-conventions not installed") 24 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/openshift_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | OPENSHIFT_CLUSTERQUOTA_NAME: Final = "openshift.clusterquota.name" 18 | """ 19 | The name of the cluster quota. 20 | """ 21 | 22 | OPENSHIFT_CLUSTERQUOTA_UID: Final = "openshift.clusterquota.uid" 23 | """ 24 | The UID of the cluster quota. 25 | """ 26 | -------------------------------------------------------------------------------- /docs/examples/basic_context/README.rst: -------------------------------------------------------------------------------- 1 | Basic Context 2 | ============= 3 | 4 | These examples show how context is propagated through Spans in OpenTelemetry. There are three different 5 | examples: 6 | 7 | * implicit_context: Shows how starting a span implicitly creates context. 8 | * child_context: Shows how context is propagated through child spans. 9 | * async_context: Shows how context can be shared in another coroutine. 10 | 11 | The source files of these examples are available :scm_web:`here `. 12 | 13 | Installation 14 | ------------ 15 | 16 | .. code-block:: sh 17 | 18 | pip install opentelemetry-api 19 | pip install opentelemetry-sdk 20 | 21 | Run the Example 22 | --------------- 23 | 24 | .. code-block:: sh 25 | 26 | python .py 27 | 28 | The output will be shown in the console. 29 | 30 | Useful links 31 | ------------ 32 | 33 | - OpenTelemetry_ 34 | - :doc:`../../api/trace` 35 | 36 | .. _OpenTelemetry: https://github.com/open-telemetry/opentelemetry-python/ 37 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/az_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | AZ_NAMESPACE: Final = "az.namespace" 18 | """ 19 | Deprecated: Replaced by `azure.resource_provider.namespace`. 20 | """ 21 | 22 | AZ_SERVICE_REQUEST_ID: Final = "az.service_request_id" 23 | """ 24 | Deprecated: Replaced by `azure.service.request.id`. 25 | """ 26 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-prometheus/README.rst: -------------------------------------------------------------------------------- 1 | OpenTelemetry Prometheus Exporter 2 | ================================= 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opentelemetry-exporter-prometheus.svg 7 | :target: https://pypi.org/project/opentelemetry-exporter-prometheus/ 8 | 9 | This library allows to export metrics data to `Prometheus `_. 10 | 11 | Installation 12 | ------------ 13 | 14 | :: 15 | 16 | pip install opentelemetry-exporter-prometheus 17 | 18 | Limitations 19 | ----------- 20 | 21 | * No multiprocessing support: The Prometheus exporter is not designed to operate in multiprocessing environments (see `#3747 `_). 22 | 23 | References 24 | ---------- 25 | 26 | * `OpenTelemetry Prometheus Exporter `_ 27 | * `Prometheus `_ 28 | * `OpenTelemetry Project `_ 29 | -------------------------------------------------------------------------------- /opentelemetry-sdk/tests/trace/test_globals.py: -------------------------------------------------------------------------------- 1 | # type:ignore 2 | import unittest 3 | from logging import WARNING 4 | 5 | from opentelemetry import trace 6 | from opentelemetry.sdk.trace import TracerProvider # type:ignore 7 | 8 | 9 | class TestGlobals(unittest.TestCase): 10 | def test_tracer_provider_override_warning(self): 11 | """trace.set_tracer_provider should throw a warning when overridden""" 12 | trace.set_tracer_provider(TracerProvider()) 13 | tracer_provider = trace.get_tracer_provider() 14 | with self.assertLogs(level=WARNING) as test: 15 | trace.set_tracer_provider(TracerProvider()) 16 | self.assertEqual( 17 | test.output, 18 | [ 19 | ( 20 | "WARNING:opentelemetry.trace:Overriding of current " 21 | "TracerProvider is not allowed" 22 | ) 23 | ], 24 | ) 25 | self.assertIs(tracer_provider, trace.get_tracer_provider()) 26 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/disk_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from enum import Enum 16 | from typing import Final 17 | 18 | DISK_IO_DIRECTION: Final = "disk.io.direction" 19 | """ 20 | The disk IO operation direction. 21 | """ 22 | 23 | 24 | class DiskIoDirectionValues(Enum): 25 | READ = "read" 26 | """read.""" 27 | WRITE = "write" 28 | """write.""" 29 | -------------------------------------------------------------------------------- /docs/examples/error_handler/error_handler_0/src/error_handler_0/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from logging import getLogger 16 | 17 | from opentelemetry.sdk.error_handler import ErrorHandler 18 | 19 | logger = getLogger(__name__) 20 | 21 | 22 | class ErrorHandler0(ErrorHandler, ZeroDivisionError): 23 | def _handle(self, error: Exception, *args, **kwargs): 24 | logger.exception("ErrorHandler0 handling a ZeroDivisionError") 25 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-grpc/README.rst: -------------------------------------------------------------------------------- 1 | OpenTelemetry Collector Protobuf over gRPC Exporter 2 | =================================================== 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opentelemetry-exporter-otlp-proto-grpc.svg 7 | :target: https://pypi.org/project/opentelemetry-exporter-otlp-proto-grpc/ 8 | 9 | This library allows to export data to the OpenTelemetry Collector using the OpenTelemetry Protocol using Protobuf over gRPC. 10 | 11 | Installation 12 | ------------ 13 | 14 | :: 15 | 16 | pip install opentelemetry-exporter-otlp-proto-grpc 17 | 18 | 19 | References 20 | ---------- 21 | 22 | * `OpenTelemetry Collector Exporter `_ 23 | * `OpenTelemetry Collector `_ 24 | * `OpenTelemetry `_ 25 | * `OpenTelemetry Protocol Specification `_ 26 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp-proto-http/README.rst: -------------------------------------------------------------------------------- 1 | OpenTelemetry Collector Protobuf over HTTP Exporter 2 | =================================================== 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opentelemetry-exporter-otlp-proto-http.svg 7 | :target: https://pypi.org/project/opentelemetry-exporter-otlp-proto-http/ 8 | 9 | This library allows to export data to the OpenTelemetry Collector using the OpenTelemetry Protocol using Protobuf over HTTP. 10 | 11 | Installation 12 | ------------ 13 | 14 | :: 15 | 16 | pip install opentelemetry-exporter-otlp-proto-http 17 | 18 | 19 | References 20 | ---------- 21 | 22 | * `OpenTelemetry Collector Exporter `_ 23 | * `OpenTelemetry Collector `_ 24 | * `OpenTelemetry `_ 25 | * `OpenTelemetry Protocol Specification `_ 26 | -------------------------------------------------------------------------------- /opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/exponential_histogram/mapping/errors.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | class MappingUnderflowError(Exception): 17 | """ 18 | Raised when computing the lower boundary of an index that maps into a 19 | denormal floating point value. 20 | """ 21 | 22 | 23 | class MappingOverflowError(Exception): 24 | """ 25 | Raised when computing the lower boundary of an index that maps into +inf. 26 | """ 27 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/nfs_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | NFS_OPERATION_NAME: Final = "nfs.operation.name" 18 | """ 19 | NFSv4+ operation name. 20 | """ 21 | 22 | NFS_SERVER_REPCACHE_STATUS: Final = "nfs.server.repcache.status" 23 | """ 24 | Linux: one of "hit" (NFSD_STATS_RC_HITS), "miss" (NFSD_STATS_RC_MISSES), or "nocache" (NFSD_STATS_RC_NOCACHE -- uncacheable). 25 | """ 26 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/tests/testbed/test_common_request_handler/README.rst: -------------------------------------------------------------------------------- 1 | 2 | Common Request Handler example. 3 | =============================== 4 | 5 | This example shows a ``Span`` used with ``RequestHandler``, which is used as a middleware (as in web frameworks) to manage a new ``Span`` per operation through its ``before_request()`` / ``after_response()`` methods. 6 | 7 | Implementation details: 8 | 9 | 10 | * For ``threading``, no active ``Span`` is consumed as the tasks may be run concurrently on different threads, and an explicit ``SpanContext`` has to be saved to be used as parent. 11 | 12 | RequestHandler implementation: 13 | 14 | .. code-block:: python 15 | 16 | def before_request(self, request, request_context): 17 | 18 | # If we should ignore the active Span, use any passed SpanContext 19 | # as the parent. Else, use the active one. 20 | span = self.tracer.start_span("send", 21 | child_of=self.context, 22 | ignore_active_span=True) 23 | 24 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/linux_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from enum import Enum 16 | from typing import Final 17 | 18 | LINUX_MEMORY_SLAB_STATE: Final = "linux.memory.slab.state" 19 | """ 20 | The Linux Slab memory state. 21 | """ 22 | 23 | 24 | class LinuxMemorySlabStateValues(Enum): 25 | RECLAIMABLE = "reclaimable" 26 | """reclaimable.""" 27 | UNRECLAIMABLE = "unreclaimable" 28 | """unreclaimable.""" 29 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/metrics/http_metrics.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from typing import Final 17 | 18 | HTTP_CLIENT_REQUEST_DURATION: Final = "http.client.request.duration" 19 | """ 20 | Duration of HTTP client requests 21 | Instrument: histogram 22 | Unit: s 23 | """ 24 | 25 | 26 | HTTP_SERVER_REQUEST_DURATION: Final = "http.server.request.duration" 27 | """ 28 | Duration of HTTP server requests 29 | Instrument: histogram 30 | Unit: s 31 | """ 32 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/dns_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | DNS_ANSWERS: Final = "dns.answers" 18 | """ 19 | The list of IPv4 or IPv6 addresses resolved during DNS lookup. 20 | """ 21 | 22 | DNS_QUESTION_NAME: Final = "dns.question.name" 23 | """ 24 | The name being queried. 25 | Note: The name represents the queried domain name as it appears in the DNS query without any additional normalization. 26 | """ 27 | -------------------------------------------------------------------------------- /shim/opentelemetry-opentracing-shim/tests/testbed/otel_ot_shim_tracer.py: -------------------------------------------------------------------------------- 1 | import opentelemetry.shim.opentracing_shim as opentracingshim 2 | from opentelemetry.sdk import trace 3 | from opentelemetry.sdk.trace.export import SimpleSpanProcessor 4 | from opentelemetry.sdk.trace.export.in_memory_span_exporter import ( 5 | InMemorySpanExporter, 6 | ) 7 | 8 | 9 | class MockTracer(opentracingshim.TracerShim): 10 | """Wrapper of `opentracingshim.TracerShim`. 11 | 12 | MockTracer extends `opentracingshim.TracerShim` by adding a in memory 13 | span exporter that can be used to get the list of finished spans.""" 14 | 15 | def __init__(self): 16 | tracer_provider = trace.TracerProvider() 17 | oteltracer = tracer_provider.get_tracer(__name__) 18 | super().__init__(oteltracer) 19 | exporter = InMemorySpanExporter() 20 | span_processor = SimpleSpanProcessor(exporter) 21 | tracer_provider.add_span_processor(span_processor) 22 | 23 | self.exporter = exporter 24 | 25 | def finished_spans(self): 26 | return self.exporter.get_finished_spans() 27 | -------------------------------------------------------------------------------- /docs/examples/basic_context/implicit_context.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from opentelemetry import baggage, trace 16 | from opentelemetry.sdk.trace import TracerProvider 17 | 18 | trace.set_tracer_provider(TracerProvider()) 19 | tracer = trace.get_tracer(__name__) 20 | 21 | with tracer.start_span(name="root span") as root_span: 22 | ctx = baggage.set_baggage("foo", "bar") 23 | 24 | print(f"Global context baggage: {baggage.get_all()}") 25 | print(f"Span context baggage: {baggage.get_all(context=ctx)}") 26 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/client_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | CLIENT_ADDRESS: Final = "client.address" 18 | """ 19 | Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.client_attributes.CLIENT_ADDRESS`. 20 | """ 21 | 22 | CLIENT_PORT: Final = "client.port" 23 | """ 24 | Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.client_attributes.CLIENT_PORT`. 25 | """ 26 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/server_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | SERVER_ADDRESS: Final = "server.address" 18 | """ 19 | Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.server_attributes.SERVER_ADDRESS`. 20 | """ 21 | 22 | SERVER_PORT: Final = "server.port" 23 | """ 24 | Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.server_attributes.SERVER_PORT`. 25 | """ 26 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin/tests/test_zipkin.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import unittest 16 | 17 | from opentelemetry.exporter.zipkin import json 18 | from opentelemetry.exporter.zipkin.proto import http 19 | 20 | 21 | class TestZipkinExporter(unittest.TestCase): 22 | def test_constructors(self): 23 | try: 24 | json.ZipkinExporter() 25 | http.ZipkinExporter() 26 | except Exception as exc: # pylint: disable=broad-exception-caught 27 | self.assertIsNone(exc) 28 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/zos_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | ZOS_SMF_ID: Final = "zos.smf.id" 18 | """ 19 | The System Management Facility (SMF) Identifier uniquely identified a z/OS system within a SYSPLEX or mainframe environment and is used for system and performance analysis. 20 | """ 21 | 22 | ZOS_SYSPLEX_NAME: Final = "zos.sysplex.name" 23 | """ 24 | The name of the SYSPLEX to which the z/OS system belongs too. 25 | """ 26 | -------------------------------------------------------------------------------- /docs/exporter/otlp/otlp.rst: -------------------------------------------------------------------------------- 1 | OpenTelemetry OTLP Exporters 2 | ============================ 3 | .. automodule:: opentelemetry.exporter.otlp 4 | :members: 5 | :undoc-members: 6 | :show-inheritance: 7 | 8 | opentelemetry.exporter.otlp.proto.http 9 | --------------------------------------- 10 | 11 | .. automodule:: opentelemetry.exporter.otlp.proto.http 12 | :members: 13 | :undoc-members: 14 | :show-inheritance: 15 | 16 | .. automodule:: opentelemetry.exporter.otlp.proto.http.trace_exporter 17 | 18 | .. automodule:: opentelemetry.exporter.otlp.proto.http.metric_exporter 19 | 20 | .. automodule:: opentelemetry.exporter.otlp.proto.http._log_exporter 21 | 22 | opentelemetry.exporter.otlp.proto.grpc 23 | --------------------------------------- 24 | 25 | .. automodule:: opentelemetry.exporter.otlp.proto.grpc 26 | :members: 27 | :undoc-members: 28 | :show-inheritance: 29 | 30 | .. automodule:: opentelemetry.exporter.otlp.proto.grpc.trace_exporter 31 | 32 | .. automodule:: opentelemetry.exporter.otlp.proto.grpc.metric_exporter 33 | 34 | .. automodule:: opentelemetry.exporter.otlp.proto.grpc._log_exporter 35 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-zipkin/README.rst: -------------------------------------------------------------------------------- 1 | OpenTelemetry Zipkin Exporter 2 | ============================= 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opentelemetry-exporter-zipkin.svg 7 | :target: https://pypi.org/project/opentelemetry-exporter-zipkin/ 8 | 9 | This library is provided as a convenience to install all supported OpenTelemetry Zipkin Exporters. Currently it installs: 10 | * opentelemetry-exporter-zipkin-json 11 | * opentelemetry-exporter-zipkin-proto-http 12 | 13 | In the future, additional packages may be available: 14 | * opentelemetry-exporter-zipkin-thrift 15 | 16 | To avoid unnecessary dependencies, users should install the specific package once they've determined their 17 | preferred serialization method. 18 | 19 | Installation 20 | ------------ 21 | 22 | :: 23 | 24 | pip install opentelemetry-exporter-zipkin 25 | 26 | 27 | References 28 | ---------- 29 | 30 | * `OpenTelemetry Zipkin Exporter `_ 31 | * `Zipkin `_ 32 | * `OpenTelemetry Project `_ 33 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/cpython_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from enum import Enum 16 | from typing import Final 17 | 18 | CPYTHON_GC_GENERATION: Final = "cpython.gc.generation" 19 | """ 20 | Value of the garbage collector collection generation. 21 | """ 22 | 23 | 24 | class CPythonGCGenerationValues(Enum): 25 | GENERATION_0 = 0 26 | """Generation 0.""" 27 | GENERATION_1 = 1 28 | """Generation 1.""" 29 | GENERATION_2 = 2 30 | """Generation 2.""" 31 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/heroku_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | HEROKU_APP_ID: Final = "heroku.app.id" 18 | """ 19 | Unique identifier for the application. 20 | """ 21 | 22 | HEROKU_RELEASE_COMMIT: Final = "heroku.release.commit" 23 | """ 24 | Commit hash for the current release. 25 | """ 26 | 27 | HEROKU_RELEASE_CREATION_TIMESTAMP: Final = "heroku.release.creation_timestamp" 28 | """ 29 | Time and date the release was created. 30 | """ 31 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/webengine_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | WEBENGINE_DESCRIPTION: Final = "webengine.description" 18 | """ 19 | Additional description of the web engine (e.g. detailed version and edition information). 20 | """ 21 | 22 | WEBENGINE_NAME: Final = "webengine.name" 23 | """ 24 | The name of the web engine. 25 | """ 26 | 27 | WEBENGINE_VERSION: Final = "webengine.version" 28 | """ 29 | The version of the web engine. 30 | """ 31 | -------------------------------------------------------------------------------- /docs/examples/basic_tracer/basic_trace.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from opentelemetry import trace 16 | from opentelemetry.sdk.trace import TracerProvider 17 | from opentelemetry.sdk.trace.export import ( 18 | BatchSpanProcessor, 19 | ConsoleSpanExporter, 20 | ) 21 | 22 | trace.set_tracer_provider(TracerProvider()) 23 | trace.get_tracer_provider().add_span_processor( 24 | BatchSpanProcessor(ConsoleSpanExporter()) 25 | ) 26 | tracer = trace.get_tracer(__name__) 27 | with tracer.start_as_current_span("foo"): 28 | print("Hello world!") 29 | -------------------------------------------------------------------------------- /docs/examples/django/pages/views.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | from django.http import HttpResponse 15 | 16 | from opentelemetry import trace 17 | from opentelemetry.sdk.trace import TracerProvider 18 | from opentelemetry.sdk.trace.export import ( 19 | BatchSpanProcessor, 20 | ConsoleSpanExporter, 21 | ) 22 | 23 | trace.set_tracer_provider(TracerProvider()) 24 | 25 | trace.get_tracer_provider().add_span_processor( 26 | BatchSpanProcessor(ConsoleSpanExporter()) 27 | ) 28 | 29 | 30 | def home_page_view(request): 31 | return HttpResponse("Hello, world") 32 | -------------------------------------------------------------------------------- /opentelemetry-api/tests/logs/test_log_record.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import unittest 16 | from unittest.mock import patch 17 | 18 | from opentelemetry._logs import LogRecord 19 | 20 | OBSERVED_TIMESTAMP = "OBSERVED_TIMESTAMP" 21 | 22 | 23 | class TestLogRecord(unittest.TestCase): 24 | @patch("opentelemetry._logs._internal.time_ns") 25 | def test_log_record_observed_timestamp_default(self, time_ns_mock): # type: ignore 26 | time_ns_mock.return_value = OBSERVED_TIMESTAMP 27 | self.assertEqual(LogRecord().observed_timestamp, OBSERVED_TIMESTAMP) 28 | -------------------------------------------------------------------------------- /docs/examples/django/instrumentation_example/asgi.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | ASGI config for instrumentation_example project. 16 | 17 | It exposes the ASGI callable as a module-level variable named ``application``. 18 | 19 | For more information on this file, see 20 | https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/ 21 | """ 22 | 23 | import os 24 | 25 | from django.core.asgi import get_asgi_application 26 | 27 | os.environ.setdefault( 28 | "DJANGO_SETTINGS_MODULE", "instrumentation_example.settings" 29 | ) 30 | 31 | application = get_asgi_application() 32 | -------------------------------------------------------------------------------- /docs/examples/django/instrumentation_example/wsgi.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """ 15 | WSGI config for instrumentation_example project. 16 | 17 | It exposes the WSGI callable as a module-level variable named ``application``. 18 | 19 | For more information on this file, see 20 | https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/ 21 | """ 22 | 23 | import os 24 | 25 | from django.core.wsgi import get_wsgi_application 26 | 27 | os.environ.setdefault( 28 | "DJANGO_SETTINGS_MODULE", "instrumentation_example.settings" 29 | ) 30 | 31 | application = get_wsgi_application() 32 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/other_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from enum import Enum 16 | from typing import Final 17 | 18 | from typing_extensions import deprecated 19 | 20 | STATE: Final = "state" 21 | """ 22 | Deprecated: Replaced by `db.client.connection.state`. 23 | """ 24 | 25 | 26 | @deprecated( 27 | "The attribute state is deprecated - Replaced by `db.client.connection.state`" 28 | ) 29 | class StateValues(Enum): 30 | IDLE = "idle" 31 | """idle.""" 32 | USED = "used" 33 | """used.""" 34 | -------------------------------------------------------------------------------- /opentelemetry-proto/test-requirements.latest.txt: -------------------------------------------------------------------------------- 1 | # This file was autogenerated by uv via the following command: 2 | # uv pip compile --python 3.9 --universal -c dev-requirements.txt opentelemetry-proto/test-requirements.in -o opentelemetry-proto/test-requirements.latest.txt 3 | -e opentelemetry-proto 4 | # via -r opentelemetry-proto/test-requirements.in 5 | colorama==0.4.6 6 | # via 7 | # -r opentelemetry-proto/test-requirements.in 8 | # pytest 9 | exceptiongroup==1.3.0 ; python_full_version < '3.11' 10 | # via pytest 11 | iniconfig==2.1.0 12 | # via 13 | # -r opentelemetry-proto/test-requirements.in 14 | # pytest 15 | packaging==25.0 16 | # via 17 | # -r opentelemetry-proto/test-requirements.in 18 | # pytest 19 | pluggy==1.6.0 20 | # via pytest 21 | protobuf==6.31.1 22 | # via 23 | # -r opentelemetry-proto/test-requirements.in 24 | # opentelemetry-proto 25 | pytest==7.4.4 26 | # via 27 | # -c dev-requirements.txt 28 | # -r opentelemetry-proto/test-requirements.in 29 | tomli==2.2.1 ; python_full_version < '3.11' 30 | # via pytest 31 | typing-extensions==4.14.0 ; python_full_version < '3.11' 32 | # via exceptiongroup 33 | -------------------------------------------------------------------------------- /scripts/coverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | function cov { 6 | if [ ${TOX_ENV_NAME:0:4} == "py34" ] 7 | then 8 | pytest \ 9 | --ignore-glob=instrumentation/opentelemetry-instrumentation-opentracing-shim/tests/testbed/* \ 10 | --cov ${1} \ 11 | --cov-append \ 12 | --cov-branch \ 13 | --cov-report='' \ 14 | ${1} 15 | else 16 | pytest \ 17 | --cov ${1} \ 18 | --cov-append \ 19 | --cov-branch \ 20 | --cov-report='' \ 21 | ${1} 22 | fi 23 | } 24 | 25 | coverage erase 26 | 27 | cov opentelemetry-api 28 | cov opentelemetry-sdk 29 | cov exporter/opentelemetry-exporter-datadog 30 | cov instrumentation/opentelemetry-instrumentation-flask 31 | cov instrumentation/opentelemetry-instrumentation-requests 32 | cov instrumentation/opentelemetry-instrumentation-opentracing-shim 33 | cov util/opentelemetry-util-http 34 | cov exporter/opentelemetry-exporter-zipkin 35 | 36 | 37 | cov instrumentation/opentelemetry-instrumentation-aiohttp-client 38 | cov instrumentation/opentelemetry-instrumentation-asgi 39 | 40 | coverage report --show-missing 41 | coverage xml 42 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/onc_rpc_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | ONC_RPC_PROCEDURE_NAME: Final = "onc_rpc.procedure.name" 18 | """ 19 | ONC/Sun RPC procedure name. 20 | """ 21 | 22 | ONC_RPC_PROCEDURE_NUMBER: Final = "onc_rpc.procedure.number" 23 | """ 24 | ONC/Sun RPC procedure number. 25 | """ 26 | 27 | ONC_RPC_PROGRAM_NAME: Final = "onc_rpc.program.name" 28 | """ 29 | ONC/Sun RPC program name. 30 | """ 31 | 32 | ONC_RPC_VERSION: Final = "onc_rpc.version" 33 | """ 34 | ONC/Sun RPC program version. 35 | """ 36 | -------------------------------------------------------------------------------- /docs/examples/metrics/views/README.rst: -------------------------------------------------------------------------------- 1 | View common scenarios 2 | ===================== 3 | 4 | These examples show how to customize the metrics that are output by the SDK using Views. There are multiple examples: 5 | 6 | * change_aggregation.py: Shows how to configure to change the default aggregation for an instrument. 7 | * change_name.py: Shows how to change the name of a metric. 8 | * limit_num_of_attrs.py: Shows how to limit the number of attributes that are output for a metric. 9 | * drop_metrics_from_instrument.py: Shows how to drop measurements from an instrument. 10 | * change_reservoir_factory.py: Shows how to use your own ``ExemplarReservoir`` 11 | 12 | The source files of these examples are available :scm_web:`here `. 13 | 14 | 15 | Installation 16 | ------------ 17 | 18 | .. code-block:: sh 19 | 20 | pip install -r requirements.txt 21 | 22 | Run the Example 23 | --------------- 24 | 25 | .. code-block:: sh 26 | 27 | python .py 28 | 29 | The output will be shown in the console. 30 | 31 | Useful links 32 | ------------ 33 | 34 | - OpenTelemetry_ 35 | - :doc:`../../../api/metrics` 36 | 37 | .. _OpenTelemetry: https://github.com/open-telemetry/opentelemetry-python/ 38 | -------------------------------------------------------------------------------- /opentelemetry-proto/test-requirements.oldest.txt: -------------------------------------------------------------------------------- 1 | # This file was autogenerated by uv via the following command: 2 | # uv pip compile --python 3.9 --universal --resolution lowest -c dev-requirements.txt opentelemetry-proto/test-requirements.in -o opentelemetry-proto/test-requirements.oldest.txt 3 | -e opentelemetry-proto 4 | # via -r opentelemetry-proto/test-requirements.in 5 | colorama==0.4.6 6 | # via 7 | # -r opentelemetry-proto/test-requirements.in 8 | # pytest 9 | exceptiongroup==1.3.0 ; python_full_version < '3.11' 10 | # via pytest 11 | iniconfig==2.1.0 12 | # via 13 | # -r opentelemetry-proto/test-requirements.in 14 | # pytest 15 | packaging==25.0 16 | # via 17 | # -r opentelemetry-proto/test-requirements.in 18 | # pytest 19 | pluggy==1.6.0 20 | # via pytest 21 | protobuf==5.29.5 22 | # via 23 | # -r opentelemetry-proto/test-requirements.in 24 | # opentelemetry-proto 25 | pytest==7.4.4 26 | # via 27 | # -c dev-requirements.txt 28 | # -r opentelemetry-proto/test-requirements.in 29 | tomli==2.2.1 ; python_full_version < '3.11' 30 | # via pytest 31 | typing-extensions==4.14.0 ; python_full_version < '3.11' 32 | # via exceptiongroup 33 | -------------------------------------------------------------------------------- /docs/getting_started/tests/test_tracing.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | import os 15 | import subprocess 16 | import sys 17 | import unittest 18 | 19 | 20 | class TestBasicTracerExample(unittest.TestCase): 21 | def test_basic_tracer(self): 22 | dirpath = os.path.dirname(os.path.realpath(__file__)) 23 | test_script = f"{dirpath}/../tracing_example.py" 24 | output = subprocess.check_output( 25 | (sys.executable, test_script) 26 | ).decode() 27 | 28 | self.assertIn('"name": "foo"', output) 29 | self.assertIn('"name": "bar"', output) 30 | self.assertIn('"name": "baz"', output) 31 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | name: CodeQL Analysis 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | # ┌───────────── minute (0 - 59) 7 | # │ ┌───────────── hour (0 - 23) 8 | # │ │ ┌───────────── day of the month (1 - 31) 9 | # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) 10 | # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) 11 | # │ │ │ │ │ 12 | # │ │ │ │ │ 13 | # │ │ │ │ │ 14 | # * * * * * 15 | - cron: '30 1 * * *' 16 | 17 | permissions: 18 | contents: read 19 | 20 | jobs: 21 | CodeQL-Build: 22 | permissions: 23 | security-events: write # for github/codeql-action/analyze to upload SARIF results 24 | runs-on: ubuntu-latest 25 | 26 | steps: 27 | - name: Checkout repository 28 | uses: actions/checkout@v4 29 | 30 | # Initializes the CodeQL tools for scanning. 31 | - name: Initialize CodeQL 32 | uses: github/codeql-action/init@v3 33 | with: 34 | languages: python 35 | 36 | - name: Autobuild 37 | uses: github/codeql-action/autobuild@v3 38 | 39 | - name: Perform CodeQL Analysis 40 | uses: github/codeql-action/analyze@v3 41 | -------------------------------------------------------------------------------- /docs/examples/error_handler/error_handler_1/src/error_handler_1/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from logging import getLogger 16 | 17 | from opentelemetry.sdk.error_handler import ErrorHandler 18 | 19 | logger = getLogger(__name__) 20 | 21 | 22 | # pylint: disable=too-many-ancestors 23 | class ErrorHandler1(ErrorHandler, IndexError, KeyError): 24 | def _handle(self, error: Exception, *args, **kwargs): 25 | if isinstance(error, IndexError): 26 | logger.exception("ErrorHandler1 handling an IndexError") 27 | 28 | elif isinstance(error, KeyError): 29 | logger.exception("ErrorHandler1 handling a KeyError") 30 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/source_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | SOURCE_ADDRESS: Final = "source.address" 18 | """ 19 | Source address - domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. 20 | Note: When observed from the destination side, and when communicating through an intermediary, `source.address` SHOULD represent the source address behind any intermediaries, for example proxies, if it's available. 21 | """ 22 | 23 | SOURCE_PORT: Final = "source.port" 24 | """ 25 | Source port number. 26 | """ 27 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/opentracing_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from enum import Enum 16 | from typing import Final 17 | 18 | OPENTRACING_REF_TYPE: Final = "opentracing.ref_type" 19 | """ 20 | Parent-child Reference type. 21 | Note: The causal relationship between a child Span and a parent Span. 22 | """ 23 | 24 | 25 | class OpentracingRefTypeValues(Enum): 26 | CHILD_OF = "child_of" 27 | """The parent Span depends on the child Span in some capacity.""" 28 | FOLLOWS_FROM = "follows_from" 29 | """The parent Span doesn't depend in any way on the result of the child Span.""" 30 | -------------------------------------------------------------------------------- /opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/sdk_configuration.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # pylint: disable=unused-import 16 | 17 | from dataclasses import dataclass 18 | from typing import Sequence 19 | 20 | # This kind of import is needed to avoid Sphinx errors. 21 | import opentelemetry.sdk.metrics 22 | import opentelemetry.sdk.resources 23 | 24 | 25 | @dataclass 26 | class SdkConfiguration: 27 | exemplar_filter: "opentelemetry.sdk.metrics.ExemplarFilter" 28 | resource: "opentelemetry.sdk.resources.Resource" 29 | metric_readers: Sequence["opentelemetry.sdk.metrics.MetricReader"] 30 | views: Sequence["opentelemetry.sdk.metrics.View"] 31 | -------------------------------------------------------------------------------- /opentelemetry-sdk/tests/conftest.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import random 16 | from os import environ 17 | 18 | import pytest 19 | 20 | from opentelemetry.environment_variables import OTEL_PYTHON_CONTEXT 21 | 22 | 23 | def pytest_sessionstart(session): 24 | # pylint: disable=unused-argument 25 | environ[OTEL_PYTHON_CONTEXT] = "contextvars_context" 26 | 27 | 28 | def pytest_sessionfinish(session): 29 | # pylint: disable=unused-argument 30 | environ.pop(OTEL_PYTHON_CONTEXT) 31 | 32 | 33 | @pytest.fixture(autouse=True) 34 | def random_seed(): 35 | # We use random numbers a lot in sampling tests, make sure they are always the same. 36 | random.seed(0) 37 | -------------------------------------------------------------------------------- /docs/examples/basic_context/async_context.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import asyncio 16 | 17 | from opentelemetry import baggage, trace 18 | from opentelemetry.sdk.trace import TracerProvider 19 | 20 | trace.set_tracer_provider(TracerProvider()) 21 | tracer = trace.get_tracer(__name__) 22 | 23 | loop = asyncio.get_event_loop() 24 | 25 | 26 | async def async_span(span): 27 | with trace.use_span(span): 28 | ctx = baggage.set_baggage("foo", "bar") 29 | return ctx 30 | 31 | 32 | async def main(): 33 | span = tracer.start_span(name="span") 34 | ctx = await async_span(span) 35 | print(baggage.get_all(context=ctx)) 36 | 37 | 38 | loop.run_until_complete(main()) 39 | -------------------------------------------------------------------------------- /docs/examples/metrics/reader/README.rst: -------------------------------------------------------------------------------- 1 | MetricReader configuration scenarios 2 | ==================================== 3 | 4 | These examples show how to customize the metrics that are output by the SDK using configuration on metric readers. There are multiple examples: 5 | 6 | * preferred_aggregation.py: Shows how to configure the preferred aggregation for metric instrument types. 7 | * preferred_temporality.py: Shows how to configure the preferred temporality for metric instrument types. 8 | * preferred_exemplarfilter.py: Shows how to configure the exemplar filter. 9 | * synchronous_gauge_read.py: Shows how to use `PeriodicExportingMetricReader` in a synchronous manner to explicitly control the collection of metrics. 10 | 11 | The source files of these examples are available :scm_web:`here `. 12 | 13 | 14 | Installation 15 | ------------ 16 | 17 | .. code-block:: sh 18 | 19 | pip install -r requirements.txt 20 | 21 | Run the Example 22 | --------------- 23 | 24 | .. code-block:: sh 25 | 26 | python .py 27 | 28 | The output will be shown in the console. 29 | 30 | Useful links 31 | ------------ 32 | 33 | - OpenTelemetry_ 34 | - :doc:`../../../api/metrics` 35 | 36 | .. _OpenTelemetry: https://github.com/open-telemetry/opentelemetry-python/ 37 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/destination_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | DESTINATION_ADDRESS: Final = "destination.address" 18 | """ 19 | Destination address - domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. 20 | Note: When observed from the source side, and when communicating through an intermediary, `destination.address` SHOULD represent the destination address behind any intermediaries, for example proxies, if it's available. 21 | """ 22 | 23 | DESTINATION_PORT: Final = "destination.port" 24 | """ 25 | Destination port number. 26 | """ 27 | -------------------------------------------------------------------------------- /docs/examples/basic_context/child_context.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from opentelemetry import baggage, trace 16 | 17 | tracer = trace.get_tracer(__name__) 18 | 19 | global_ctx = baggage.set_baggage("context", "global") 20 | with tracer.start_as_current_span(name="root span") as root_span: 21 | parent_ctx = baggage.set_baggage("context", "parent") 22 | with tracer.start_as_current_span( 23 | name="child span", context=parent_ctx 24 | ) as child_span: 25 | child_ctx = baggage.set_baggage("context", "child") 26 | 27 | print(baggage.get_baggage("context", global_ctx)) 28 | print(baggage.get_baggage("context", parent_ctx)) 29 | print(baggage.get_baggage("context", child_ctx)) 30 | -------------------------------------------------------------------------------- /opentelemetry-sdk/src/opentelemetry/sdk/trace/_sampling_experimental/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __all__ = [ 16 | "ComposableSampler", 17 | "SamplingIntent", 18 | "composable_always_off", 19 | "composable_always_on", 20 | "composable_parent_threshold", 21 | "composable_traceid_ratio_based", 22 | "composite_sampler", 23 | ] 24 | 25 | 26 | from ._always_off import composable_always_off 27 | from ._always_on import composable_always_on 28 | from ._composable import ComposableSampler, SamplingIntent 29 | from ._parent_threshold import composable_parent_threshold 30 | from ._sampler import composite_sampler 31 | from ._traceid_ratio import composable_traceid_ratio_based 32 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/peer_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | PEER_SERVICE: Final = "peer.service" 18 | """ 19 | The [`service.name`](/docs/resource/README.md#service) of the remote service. SHOULD be equal to the actual `service.name` resource attribute of the remote service if any. 20 | Note: Examples of `peer.service` that users may specify: 21 | 22 | - A Redis cache of auth tokens as `peer.service="AuthTokenCache"`. 23 | - A gRPC service `rpc.service="io.opentelemetry.AuthService"` may be hosted in both a gateway, `peer.service="ExternalApiService"` and a backend, `peer.service="AuthService"`. 24 | """ 25 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/dns_metrics.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | from typing import Final 17 | 18 | from opentelemetry.metrics import Histogram, Meter 19 | 20 | DNS_LOOKUP_DURATION: Final = "dns.lookup.duration" 21 | """ 22 | Measures the time taken to perform a DNS lookup 23 | Instrument: histogram 24 | Unit: s 25 | """ 26 | 27 | 28 | def create_dns_lookup_duration(meter: Meter) -> Histogram: 29 | """Measures the time taken to perform a DNS lookup""" 30 | return meter.create_histogram( 31 | name=DNS_LOOKUP_DURATION, 32 | description="Measures the time taken to perform a DNS lookup.", 33 | unit="s", 34 | ) 35 | -------------------------------------------------------------------------------- /opentelemetry-sdk/src/opentelemetry/sdk/metrics/view/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from opentelemetry.sdk.metrics._internal.aggregation import ( 16 | Aggregation, 17 | DefaultAggregation, 18 | DropAggregation, 19 | ExplicitBucketHistogramAggregation, 20 | ExponentialBucketHistogramAggregation, 21 | LastValueAggregation, 22 | SumAggregation, 23 | ) 24 | from opentelemetry.sdk.metrics._internal.view import View 25 | 26 | __all__ = [ 27 | "Aggregation", 28 | "DefaultAggregation", 29 | "DropAggregation", 30 | "ExplicitBucketHistogramAggregation", 31 | "ExponentialBucketHistogramAggregation", 32 | "LastValueAggregation", 33 | "SumAggregation", 34 | "View", 35 | ] 36 | -------------------------------------------------------------------------------- /opentelemetry-sdk/benchmarks/logs/test_benchmark_logging_handler.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | import pytest 4 | 5 | from opentelemetry.sdk._logs import LoggerProvider, LoggingHandler 6 | from opentelemetry.sdk._logs.export import ( 7 | InMemoryLogRecordExporter, 8 | SimpleLogRecordProcessor, 9 | ) 10 | 11 | 12 | def _set_up_logging_handler(level): 13 | logger_provider = LoggerProvider() 14 | exporter = InMemoryLogRecordExporter() 15 | processor = SimpleLogRecordProcessor(exporter=exporter) 16 | logger_provider.add_log_record_processor(processor) 17 | handler = LoggingHandler(level=level, logger_provider=logger_provider) 18 | return handler 19 | 20 | 21 | def _create_logger(handler, name): 22 | logger = logging.getLogger(name) 23 | logger.addHandler(handler) 24 | return logger 25 | 26 | 27 | @pytest.mark.parametrize("num_loggers", [1, 10, 100, 1000]) 28 | def test_simple_get_logger_different_names(benchmark, num_loggers): 29 | handler = _set_up_logging_handler(level=logging.DEBUG) 30 | loggers = [ 31 | _create_logger(handler, str(f"logger_{i}")) for i in range(num_loggers) 32 | ] 33 | 34 | def benchmark_get_logger(): 35 | for index in range(1000): 36 | loggers[index % num_loggers].warning("test message") 37 | 38 | benchmark(benchmark_get_logger) 39 | -------------------------------------------------------------------------------- /docs/getting_started/tracing_example.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # tracing.py 16 | from opentelemetry import trace 17 | from opentelemetry.sdk.trace import TracerProvider 18 | from opentelemetry.sdk.trace.export import ( 19 | BatchSpanProcessor, 20 | ConsoleSpanExporter, 21 | ) 22 | 23 | provider = TracerProvider() 24 | processor = BatchSpanProcessor(ConsoleSpanExporter()) 25 | provider.add_span_processor(processor) 26 | trace.set_tracer_provider(provider) 27 | 28 | 29 | tracer = trace.get_tracer(__name__) 30 | 31 | with tracer.start_as_current_span("foo"): 32 | with tracer.start_as_current_span("bar"): 33 | with tracer.start_as_current_span("baz"): 34 | print("Hello world from OpenTelemetry Python!") 35 | -------------------------------------------------------------------------------- /exporter/opentelemetry-exporter-otlp/README.rst: -------------------------------------------------------------------------------- 1 | OpenTelemetry Collector Exporters 2 | ================================= 3 | 4 | |pypi| 5 | 6 | .. |pypi| image:: https://badge.fury.io/py/opentelemetry-exporter-otlp.svg 7 | :target: https://pypi.org/project/opentelemetry-exporter-otlp/ 8 | 9 | This library is provided as a convenience to install all supported OpenTelemetry Collector Exporters. Currently it installs: 10 | 11 | * opentelemetry-exporter-otlp-proto-grpc 12 | * opentelemetry-exporter-otlp-proto-http 13 | 14 | In the future, additional packages will be available: 15 | * opentelemetry-exporter-otlp-json-http 16 | 17 | To avoid unnecessary dependencies, users should install the specific package once they've determined their 18 | preferred serialization and protocol method. 19 | 20 | Installation 21 | ------------ 22 | 23 | :: 24 | 25 | pip install opentelemetry-exporter-otlp 26 | 27 | 28 | References 29 | ---------- 30 | 31 | * `OpenTelemetry Collector Exporter `_ 32 | * `OpenTelemetry Collector `_ 33 | * `OpenTelemetry `_ 34 | * `OpenTelemetry Protocol Specification `_ 35 | -------------------------------------------------------------------------------- /eachdist.ini: -------------------------------------------------------------------------------- 1 | # These will be sorted first in that order. 2 | # All packages that are depended upon by others should be listed here. 3 | [DEFAULT] 4 | 5 | sortfirst= 6 | opentelemetry-api 7 | opentelemetry-sdk 8 | opentelemetry-proto 9 | opentelemetry-distro 10 | tests/opentelemetry-test-utils 11 | exporter/* 12 | 13 | [stable] 14 | version=1.40.0.dev 15 | 16 | packages= 17 | opentelemetry-sdk 18 | opentelemetry-proto 19 | opentelemetry-propagator-jaeger 20 | opentelemetry-propagator-b3 21 | opentelemetry-exporter-zipkin-proto-http 22 | opentelemetry-exporter-zipkin-json 23 | opentelemetry-exporter-zipkin 24 | opentelemetry-exporter-otlp-proto-grpc 25 | opentelemetry-exporter-otlp-proto-http 26 | opentelemetry-exporter-otlp 27 | opentelemetry-api 28 | 29 | [prerelease] 30 | version=0.61b0.dev 31 | 32 | packages= 33 | opentelemetry-opentracing-shim 34 | opentelemetry-opencensus-shim 35 | opentelemetry-exporter-opencensus 36 | opentelemetry-exporter-prometheus 37 | opentelemetry-distro 38 | opentelemetry-semantic-conventions 39 | opentelemetry-test-utils 40 | tests 41 | 42 | [lintroots] 43 | extraroots=examples/*,scripts/ 44 | subglob=*.py,tests/,test/,src/*,examples/* 45 | 46 | [testroots] 47 | extraroots=examples/*,tests/ 48 | subglob=tests/,test/ 49 | -------------------------------------------------------------------------------- /opentelemetry-sdk/src/opentelemetry/sdk/_logs/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from opentelemetry.sdk._logs._internal import ( 16 | LogDroppedAttributesWarning, 17 | Logger, 18 | LoggerProvider, 19 | LoggingHandler, 20 | LogLimits, 21 | LogRecordDroppedAttributesWarning, 22 | LogRecordLimits, 23 | LogRecordProcessor, 24 | ReadableLogRecord, 25 | ReadWriteLogRecord, 26 | ) 27 | 28 | __all__ = [ 29 | "Logger", 30 | "LoggerProvider", 31 | "LoggingHandler", 32 | "LogLimits", 33 | "LogRecordLimits", 34 | "LogRecordProcessor", 35 | "LogDroppedAttributesWarning", 36 | "LogRecordDroppedAttributesWarning", 37 | "ReadableLogRecord", 38 | "ReadWriteLogRecord", 39 | ] 40 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/oci_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | OCI_MANIFEST_DIGEST: Final = "oci.manifest.digest" 18 | """ 19 | The digest of the OCI image manifest. For container images specifically is the digest by which the container image is known. 20 | Note: Follows [OCI Image Manifest Specification](https://github.com/opencontainers/image-spec/blob/main/manifest.md), and specifically the [Digest property](https://github.com/opencontainers/image-spec/blob/main/descriptor.md#digests). 21 | An example can be found in [Example Image Manifest](https://github.com/opencontainers/image-spec/blob/main/manifest.md#example-image-manifest). 22 | """ 23 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/service_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import Final 16 | 17 | SERVICE_NAME: Final = "service.name" 18 | """ 19 | Logical name of the service. 20 | Note: MUST be the same for all instances of horizontally scaled services. If the value was not specified, SDKs MUST fallback to `unknown_service:` concatenated with [`process.executable.name`](process.md), e.g. `unknown_service:bash`. If `process.executable.name` is not available, the value MUST be set to `unknown_service`. 21 | """ 22 | 23 | SERVICE_VERSION: Final = "service.version" 24 | """ 25 | The version string of the service API or implementation. The format is not defined by these conventions. 26 | """ 27 | -------------------------------------------------------------------------------- /docs/examples/basic_tracer/resources.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from opentelemetry import trace 16 | from opentelemetry.sdk.resources import Resource 17 | from opentelemetry.sdk.trace import TracerProvider 18 | from opentelemetry.sdk.trace.export import ( 19 | BatchSpanProcessor, 20 | ConsoleSpanExporter, 21 | ) 22 | 23 | # Use Resource.create() instead of constructor directly 24 | resource = Resource.create({"service.name": "basic_service"}) 25 | 26 | trace.set_tracer_provider(TracerProvider(resource=resource)) 27 | 28 | trace.get_tracer_provider().add_span_processor( 29 | BatchSpanProcessor(ConsoleSpanExporter()) 30 | ) 31 | tracer = trace.get_tracer(__name__) 32 | with tracer.start_as_current_span("foo"): 33 | print("Hello world!") 34 | -------------------------------------------------------------------------------- /docs/examples/error_handler/error_handler_0/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["hatchling"] 3 | build-backend = "hatchling.build" 4 | 5 | [project] 6 | name = "error-handler-0" 7 | dynamic = ["version"] 8 | description = "This is just an error handler example package" 9 | readme = "README.rst" 10 | license = "Apache-2.0" 11 | requires-python = ">=3.9" 12 | authors = [ 13 | { name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" }, 14 | ] 15 | classifiers = [ 16 | "Development Status :: 4 - Beta", 17 | "Intended Audience :: Developers", 18 | "Programming Language :: Python", 19 | "Programming Language :: Python :: 3", 20 | "Programming Language :: Python :: 3.9", 21 | "Programming Language :: Python :: 3.10", 22 | "Programming Language :: Python :: 3.11", 23 | "Programming Language :: Python :: 3.12", 24 | "Programming Language :: Python :: 3.13", 25 | "Programming Language :: Python :: 3.14", 26 | ] 27 | dependencies = [ 28 | "opentelemetry-sdk ~= 1.3", 29 | ] 30 | 31 | [project.entry-points.opentelemetry_error_handler] 32 | error_handler_0 = "error_handler_0:ErrorHandler0" 33 | 34 | [tool.hatch.version] 35 | path = "src/error_handler_0/version/__init__.py" 36 | 37 | [tool.hatch.build.targets.sdist] 38 | include = [ 39 | "/src", 40 | ] 41 | 42 | [tool.hatch.build.targets.wheel] 43 | packages = ["src/opentelemetry"] 44 | -------------------------------------------------------------------------------- /docs/examples/error_handler/error_handler_1/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["hatchling"] 3 | build-backend = "hatchling.build" 4 | 5 | [project] 6 | name = "error-handler-1" 7 | dynamic = ["version"] 8 | description = "This is just an error handler example package" 9 | readme = "README.rst" 10 | license = "Apache-2.0" 11 | requires-python = ">=3.9" 12 | authors = [ 13 | { name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" }, 14 | ] 15 | classifiers = [ 16 | "Development Status :: 4 - Beta", 17 | "Intended Audience :: Developers", 18 | "Programming Language :: Python", 19 | "Programming Language :: Python :: 3", 20 | "Programming Language :: Python :: 3.9", 21 | "Programming Language :: Python :: 3.10", 22 | "Programming Language :: Python :: 3.11", 23 | "Programming Language :: Python :: 3.12", 24 | "Programming Language :: Python :: 3.13", 25 | "Programming Language :: Python :: 3.14", 26 | ] 27 | dependencies = [ 28 | "opentelemetry-sdk ~= 1.3", 29 | ] 30 | 31 | [project.entry-points.opentelemetry_error_handler] 32 | error_handler_1 = "error_handler_1:ErrorHandler1" 33 | 34 | [tool.hatch.version] 35 | path = "src/error_handler_1/version/__init__.py" 36 | 37 | [tool.hatch.build.targets.sdist] 38 | include = [ 39 | "/src", 40 | ] 41 | 42 | [tool.hatch.build.targets.wheel] 43 | packages = ["src/opentelemetry"] 44 | -------------------------------------------------------------------------------- /opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/cpu_attributes.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from enum import Enum 16 | from typing import Final 17 | 18 | CPU_LOGICAL_NUMBER: Final = "cpu.logical_number" 19 | """ 20 | The logical CPU number [0..n-1]. 21 | """ 22 | 23 | CPU_MODE: Final = "cpu.mode" 24 | """ 25 | The mode of the CPU. 26 | """ 27 | 28 | 29 | class CpuModeValues(Enum): 30 | USER = "user" 31 | """User.""" 32 | SYSTEM = "system" 33 | """System.""" 34 | NICE = "nice" 35 | """Nice.""" 36 | IDLE = "idle" 37 | """Idle.""" 38 | IOWAIT = "iowait" 39 | """IO Wait.""" 40 | INTERRUPT = "interrupt" 41 | """Interrupt.""" 42 | STEAL = "steal" 43 | """Steal.""" 44 | KERNEL = "kernel" 45 | """Kernel.""" 46 | -------------------------------------------------------------------------------- /.github/workflows/changelog.yml: -------------------------------------------------------------------------------- 1 | # This action requires that any PR targeting the main branch should touch at 2 | # least one CHANGELOG file. If a CHANGELOG entry is not required, add the "Skip 3 | # Changelog" label to disable this action. 4 | 5 | name: changelog 6 | 7 | on: 8 | pull_request: 9 | types: [opened, synchronize, reopened, labeled, unlabeled] 10 | branches: 11 | - main 12 | 13 | permissions: 14 | contents: read 15 | 16 | jobs: 17 | changelog: 18 | runs-on: ubuntu-latest 19 | if: | 20 | !contains(github.event.pull_request.labels.*.name, 'Skip Changelog') 21 | && github.actor != 'otelbot[bot]' 22 | 23 | steps: 24 | - uses: actions/checkout@v4 25 | 26 | - name: Check for CHANGELOG changes 27 | run: | 28 | # Only the latest commit of the feature branch is available 29 | # automatically. To diff with the base branch, we need to 30 | # fetch that too (and we only need its latest commit). 31 | git fetch origin ${{ github.base_ref }} --depth=1 32 | if [[ $(git diff --name-only FETCH_HEAD | grep CHANGELOG) ]] 33 | then 34 | echo "A CHANGELOG was modified. Looks good!" 35 | else 36 | echo "No CHANGELOG was modified." 37 | echo "Please add a CHANGELOG entry, or add the \"Skip Changelog\" label if not required." 38 | false 39 | fi 40 | -------------------------------------------------------------------------------- /opentelemetry-api/tests/trace/test_defaultspan.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import unittest 16 | 17 | from opentelemetry import trace 18 | 19 | 20 | class TestNonRecordingSpan(unittest.TestCase): 21 | def test_ctor(self): 22 | context = trace.SpanContext( 23 | 1, 24 | 1, 25 | is_remote=False, 26 | trace_flags=trace.DEFAULT_TRACE_OPTIONS, 27 | trace_state=trace.DEFAULT_TRACE_STATE, 28 | ) 29 | span = trace.NonRecordingSpan(context) 30 | self.assertEqual(context, span.get_span_context()) 31 | 32 | def test_invalid_span(self): 33 | self.assertIsNotNone(trace.INVALID_SPAN) 34 | self.assertIsNotNone(trace.INVALID_SPAN.get_span_context()) 35 | self.assertFalse(trace.INVALID_SPAN.get_span_context().is_valid) 36 | -------------------------------------------------------------------------------- /opentelemetry-sdk/src/opentelemetry/sdk/trace/_sampling_experimental/_util.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | RANDOM_VALUE_BITS = 56 16 | MAX_THRESHOLD = 1 << RANDOM_VALUE_BITS # 0% sampling 17 | MIN_THRESHOLD = 0 # 100% sampling 18 | MAX_RANDOM_VALUE = MAX_THRESHOLD - 1 19 | INVALID_THRESHOLD = -1 20 | INVALID_RANDOM_VALUE = -1 21 | 22 | _probability_threshold_scale = float.fromhex("0x1p56") 23 | 24 | 25 | def calculate_threshold(sampling_probability: float) -> int: 26 | return MAX_THRESHOLD - round( 27 | sampling_probability * _probability_threshold_scale 28 | ) 29 | 30 | 31 | def is_valid_threshold(threshold: int) -> bool: 32 | return MIN_THRESHOLD <= threshold <= MAX_THRESHOLD 33 | 34 | 35 | def is_valid_random_value(random_value: int) -> bool: 36 | return 0 <= random_value <= MAX_RANDOM_VALUE 37 | --------------------------------------------------------------------------------