### Setup Virtual Environment and Install Dependencies Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-botocore/examples/bedrock-runtime/zero-code/README.rst Commands to set up a virtual environment, activate it, install python-dotenv, and install project requirements. ```bash python3 -m venv .venv source .venv/bin/activate pip install "python-dotenv[cli]" pip install -r requirements.txt ``` -------------------------------- ### Setup Virtual Environment and Install Dependencies Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation-genai/opentelemetry-instrumentation-langchain/examples/manual/README.rst Commands to set up a virtual environment, install necessary packages, and the OpenTelemetry Langchain instrumentation. ```bash python3 -m venv .venv source .venv/bin/activate pip install "python-dotenv[cli]" pip install -r requirements.txt pip install opentelemetry-instrumentation-langchain pip install util/opentelemetry-util-genai (once opentelemetry-util-genai package is released remove it from here and add dependency in opentelemetry-instrumentation-langchain) ``` -------------------------------- ### Setup Virtual Environment and Install Dependencies Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation-genai/opentelemetry-instrumentation-google-genai/examples/zero-code/README.rst Commands to set up a virtual environment, activate it, install Python dotenv, install requirements, and bootstrap OpenTelemetry. ```bash python3 -m venv .venv source .venv/bin/activate pip install "python-dotenv[cli]" pip install -r requirements.txt opentelemetry-bootstrap -a install ``` -------------------------------- ### Setup Virtual Environment and Install Dependencies Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation-genai/opentelemetry-instrumentation-anthropic/examples/zero-code/README.rst Commands to set up a Python virtual environment, activate it, install python-dotenv and other requirements, and set the Anthropic API key. ```bash python3 -m venv .venv source .venv/bin/activate pip install "python-dotenv[cli]" pip install -r requirements.txt export ANTHROPIC_API_KEY=your_api_key_here ``` -------------------------------- ### Install dependencies Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation-genai/opentelemetry-instrumentation-openai-agents-v2/examples/manual/README.rst Create a virtual environment and install the dependencies. ```bash python3 -m venv .venv source .venv/bin/activate pip install "python-dotenv[cli]" uv pip install -r requirements.txt --prerelease=allow ``` -------------------------------- ### Run the example Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation-genai/opentelemetry-instrumentation-anthropic/examples/manual/README.rst This snippet shows the command to run the example using dotenv to load environment variables. ```bash dotenv run -- python main.py ``` -------------------------------- ### Run the Custom Completion Hook Example Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation-genai/opentelemetry-instrumentation-openai-v2/examples/manual/README.rst Command to execute the custom completion hook example script. ```bash dotenv run -- python custom_hook.py ``` -------------------------------- ### Run the Example Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation-genai/opentelemetry-instrumentation-google-genai/examples/zero-code/README.rst Commands to set the PROMPT environment variable and run the example using dotenv and opentelemetry-instrument. ```bash export PROMPT="Your prompt here" dotenv run -- opentelemetry-instrument python main.py ``` -------------------------------- ### Install OpenTelemetry Instrumentation Package Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/README.md Installs a specific OpenTelemetry instrumentation package for a given integration. Use this for standard installations. ```sh pip install opentelemetry-instrumentation-{integration} ``` -------------------------------- ### Installation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/util/opentelemetry-util-genai/README.rst Install the opentelemetry-util-genai package. ```bash pip install opentelemetry-util-genai ``` -------------------------------- ### Docker Compose Commands Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/exporter/opentelemetry-exporter-prometheus-remote-write/example/README.md Commands to start and stop the Docker services for the Prometheus Remote Write exporter example. ```bash docker-compose up -d ``` ```bash docker logs ${CONTAINER_ID} --follow ``` ```bash docker-compose down ``` -------------------------------- ### Installation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/opamp/opentelemetry-opamp-client/README.rst Install the opentelemetry-opamp-client package using pip. ```bash pip install opentelemetry-opamp-client ``` -------------------------------- ### Install opentelemetry-instrumentation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/opentelemetry-instrumentation/README.rst Installs the core opentelemetry-instrumentation package. ```bash pip install opentelemetry-instrumentation ``` -------------------------------- ### Installation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-asyncpg/README.rst Install the opentelemetry-instrumentation-asyncpg package. ```bash pip install opentelemetry-instrumentation-asyncpg ``` -------------------------------- ### Installation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/util/opentelemetry-util-http/README.rst Install the opentelemetry-util-http library using pip. ```bash pip install opentelemetry-util-http ``` -------------------------------- ### Installation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-mysqlclient/README.rst Install the opentelemetry-instrumentation-mysqlclient package using pip. ```bash pip install opentelemetry-instrumentation-mysqlclient ``` -------------------------------- ### Installation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-mysql/README.rst Install the opentelemetry-instrumentation-mysql package using pip. ```bash pip install opentelemetry-instrumentation-mysql ``` -------------------------------- ### Installation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-kafka-python/README.rst Install the opentelemetry-instrumentation-kafka-python package using pip. ```bash pip install opentelemetry-instrumentation-kafka-python ``` -------------------------------- ### Installation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-logging/README.rst Install the opentelemetry-instrumentation-logging package using pip. ```bash pip install opentelemetry-instrumentation-logging ``` -------------------------------- ### Run the example server Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/opamp/opentelemetry-opamp-client/tests/opamp/README.md Run the example server from the opentelemetry-go project. ```bash ./internal/examples/server/bin/server ``` -------------------------------- ### Run the example Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation-genai/opentelemetry-instrumentation-google-genai/examples/manual/README.rst This snippet shows how to set the PROMPT environment variable and run the main Python script. ```bash export PROMPT="Your prompt here" dotenv run -- python main.py ``` -------------------------------- ### BaggageLogProcessor: Custom baggage key predicate (starts with) Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/processor/opentelemetry-processor-baggage/README.rst Provide a custom baggage key predicate to select which baggage keys you want to copy, for example, to only copy baggage entries that start with 'my-key'. ```python starts_with_predicate = lambda baggage_key: baggage_key.startswith("my-key") logger_provider.add_log_record_processor(BaggageLogProcessor(starts_with_predicate)) ``` -------------------------------- ### Usage: Custom baggage key predicate (starts with) Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/processor/opentelemetry-processor-baggage/README.rst Provide a custom baggage key predicate to select which baggage keys you want to copy, for example, to only copy baggage entries that start with 'my-key'. ```python starts_with_predicate = lambda baggage_key: baggage_key.startswith("my-key") tracer_provider.add_span_processor(BaggageSpanProcessor(starts_with_predicate)) ``` -------------------------------- ### Install cutting-edge packages from the repository Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/docs/index.rst Install packages directly from the repository by cloning and doing an editable install. ```sh git clone https://github.com/open-telemetry/opentelemetry-python-contrib.git cd opentelemetry-python-contrib pip install -e ./instrumentation/opentelemetry-instrumentation-flask pip install -e ./instrumentation/opentelemetry-instrumentation-botocore pip install -e ./instrumentation-genai/opentelemetry-instrumentation-openai-v2 pip install -e ./sdk-extension/opentelemetry-sdk-extension-aws pip install -e ./resource/opentelemetry-resource-detector-containerid ``` -------------------------------- ### Manual Publish Steps Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/RELEASING.md Steps to manually build and publish distributions to PyPI. ```bash ./scripts/build.sh twine upload --skip-existing --verbose dist/* ``` -------------------------------- ### Run Bedrock Zero-Code Instrumentation Example Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-botocore/examples/bedrock-runtime/zero-code/README.rst Command to run the converse.py example using dotenv to load environment variables and opentelemetry-instrument to instrument the Python script. ```bash dotenv run -- opentelemetry-instrument python converse.py ``` -------------------------------- ### Install Development Version of Instrumentation Package Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/README.md Installs the development version of an OpenTelemetry instrumentation package using an editable install. Clone or fork the repository first. ```sh pip install -e ./instrumentation/opentelemetry-instrumentation-{integration} ``` -------------------------------- ### Install Unhandled Exceptions Instrumentation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-exceptions/README.rst Install the instrumentation package using pip. This is the first step to enable exception tracking. ```bash pip install opentelemetry-instrumentation-exceptions ``` -------------------------------- ### Installation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation-genai/opentelemetry-instrumentation-anthropic/README.rst Install the opentelemetry-instrumentation-anthropic package. ```bash pip install opentelemetry-instrumentation-anthropic ``` -------------------------------- ### Installation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-urllib/README.rst Install the opentelemetry-instrumentation-urllib package. ```bash pip install opentelemetry-instrumentation-urllib ``` -------------------------------- ### Example Entry Point for New Instrumentation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/CONTRIBUTING.md Illustrates how to add an entry point for a new instrumentation package in pyproject.toml. ```toml https://github.com/open-telemetry/opentelemetry-python-contrib/blob/2518a4ac07cb62ad6587dd8f6cbb5f8663a7e179/instrumentation/opentelemetry-instrumentation-requests/pyproject.toml#L44 ``` -------------------------------- ### Build opentelemetry-go Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/opamp/opentelemetry-opamp-client/tests/opamp/README.md Build the opentelemetry-go project. ```bash make ``` -------------------------------- ### Usage example Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/resource/opentelemetry-resource-detector-containerid/README.rst Example demonstrating how to use the ContainerResourceDetector to set the tracer provider. ```python from opentelemetry import trace from opentelemetry.sdk.trace import TracerProvider from opentelemetry.resource.detector.containerid import \ ContainerResourceDetector from opentelemetry.sdk.resources import get_aggregated_resources trace.set_tracer_provider( TracerProvider( resource=get_aggregated_resources( [ ContainerResourceDetector(), ] ), ) ) ``` -------------------------------- ### Installation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/processor/opentelemetry-processor-baggage/README.rst Install the opentelemetry-processor-baggage package. ```bash pip install opentelemetry-processor-baggage ``` -------------------------------- ### Installation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/resource/opentelemetry-resource-detector-azure/README.rst Install the opentelemetry-resource-detector-azure package using pip. ```bash pip install opentelemetry-resource-detector-azure ``` -------------------------------- ### Installation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/opentelemetry-distro/README.rst Install the opentelemetry-distro package using pip. ```bash pip install opentelemetry-distro ``` -------------------------------- ### Installation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/resource/opentelemetry-resource-detector-containerid/README.rst Install the opentelemetry-resource-detector-containerid library using pip. ```bash pip install opentelemetry-resource-detector-containerid ``` -------------------------------- ### Installation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-wsgi/README.rst Command to install the opentelemetry-instrumentation-wsgi package. ```bash pip install opentelemetry-instrumentation-wsgi ``` -------------------------------- ### Installation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/_template/README.rst Install the opentelemetry-instrumentation- package using pip. ```bash pip install opentelemetry-instrumentation- ``` -------------------------------- ### Installation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-urllib3/README.rst Install the urllib3 instrumentation package. ```bash pip install opentelemetry-instrumentation-urllib3 ``` -------------------------------- ### Run Example with Zero-Code Instrumentation Source: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation-genai/opentelemetry-instrumentation-anthropic/examples/zero-code/README.rst Command to run the main Python script with zero-code instrumentation using dotenv. ```bash dotenv run -- opentelemetry-instrument python main.py ```