### Create virtual environment and install dependencies Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-genai/opentelemetry-instrumentation-openai-agents-v2/examples/manual/README.rst Sets up a Python virtual environment and installs the required dependencies, including python-dotenv and the project requirements with prerelease packages allowed. ```bash python3 -m venv .venv source .venv/bin/activate pip install "python-dotenv[cli]" uv pip install -r requirements.txt --prerelease=allow ``` -------------------------------- ### Install dependencies Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/examples/ecommerce-customer-service/README.md Create a virtual environment and install requirements. Requires Python 3.10 or later. ```bash python -m venv .venv source .venv/bin/activate python -m pip install -r requirements.txt ``` -------------------------------- ### Install AgentScope instrumentation from source Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/README.md Install the loongsuite-instrumentation-agentscope package in editable mode from the local source checkout. This is an example of installing an instrumentation package needed for development. ```bash pip install -e ./instrumentation-loongsuite/loongsuite-instrumentation-agentscope ``` -------------------------------- ### Set up virtual environment for Bedrock zero-code example Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-botocore/examples/bedrock-runtime/zero-code/README.rst Creates a Python virtual environment, activates it, and installs dependencies including python-dotenv CLI and requirements.txt. ```bash python3 -m venv .venv source .venv/bin/activate pip install "python-dotenv[cli]" pip install -r requirements.txt ``` -------------------------------- ### Set up virtual environment and install dependencies Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-genai/opentelemetry-instrumentation-google-genai/examples/zero-code/README.rst Create a virtual environment, activate it, install python-dotenv and requirements, then run opentelemetry-bootstrap to install instrumentation packages. Requires an OTLP endpoint at http://localhost:4317. ```bash python3 -m venv .venv source .venv/bin/activate pip install "python-dotenv[cli]" pip install -r requirements.txt opentelemetry-bootstrap -a install ``` -------------------------------- ### Run setup and command scripts Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-vita/examples/vitabench-dashscope/README.md Execute the setup and command scripts to run the VitaBench delivery task. setup.sh writes models.yaml with the full /chat/completions endpoint and injects the API key via the Authorization header at runtime; do not commit a rendered models.yaml containing a real key. ```bash ./setup.sh ./cmd.sh ``` -------------------------------- ### Set required environment variables Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-vita/examples/vitabench-dashscope/README.md Export the DashScope API key and enable OpenTelemetry semantic conventions and message content capture before running the example. ```bash export OPENAI_API_KEY= export OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=SPAN_ONLY ``` -------------------------------- ### Set up virtual environment for Langchain instrumentation example Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-genai/opentelemetry-instrumentation-langchain/examples/manual/README.rst Creates a Python virtual environment, activates it, and installs required packages including python-dotenv, requirements, opentelemetry-instrumentation-langchain, and util/opentelemetry-util-genai. Note that the util package is temporary until opentelemetry-util-genai is released and added as a dependency. ```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) ``` -------------------------------- ### Install and run AgentScope Studio Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/README.md Installs the agentscope-studio package and starts the Studio web UI, which provides a web interface for traces and metrics. The Studio prints an OTLP endpoint (often http://127.0.0.1:31415) to use with the instrument command. ```shell pip install agentscope-studio as_studio ``` -------------------------------- ### Auto-detect instrumentations with loongsuite-bootstrap Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/README.md Installs only instrumentations for libraries already present in the environment, useful for lean setups. ```bash loongsuite-bootstrap -a install --latest --auto-detect ``` -------------------------------- ### Install loongsuite-instrumentation-llama-index via pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-llama-index/README.md Install the package with pip. This is the required setup step before using the instrumentation. ```bash pip install loongsuite-instrumentation-llama-index ``` -------------------------------- ### Run offline tests Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/examples/ecommerce-customer-service/README.md Install dev requirements and run the offline test suite. Tests do not call an external model. ```bash python -m pip install -r requirements-dev.txt python -m pytest tests -q ``` -------------------------------- ### Install loongsuite-distro Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/README.md Installs the loongsuite-distro package, which includes loongsuite-instrument and loongsuite-bootstrap. Optionally install with [otlp] extras for OTLP support. ```bash pip install loongsuite-distro ``` -------------------------------- ### Install opentelemetry-instrumentation-sqlite3 via pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-sqlite3/README.rst Install the OpenTelemetry SQLite3 instrumentation package using pip. This is the required setup step before using the instrumentation. ```shell pip install opentelemetry-instrumentation-sqlite3 ``` -------------------------------- ### Install opentelemetry-instrumentation-cassandra Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-cassandra/README.rst Install the Cassandra instrumentation package via pip. This is the required setup step before using the instrumentation. ```bash pip install opentelemetry-instrumentation-cassandra ``` -------------------------------- ### Install QwenPaw Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-qwenpaw/README.md Install the QwenPaw package via pip. ```bash pip install qwenpaw ``` -------------------------------- ### Install instrumentations including this package Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-qwenpaw/README.md Install the QwenPaw and AgentScope instrumentation packages. ```bash pip install loongsuite-instrumentation-qwenpaw loongsuite-instrumentation-agentscope ``` -------------------------------- ### Install tox and run tests Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/CONTRIBUTING.md Install tox and tox-uv (only first time) and run all tox environments from the repository root. ```sh pip install tox tox-uv ``` ```sh tox ``` -------------------------------- ### Install loongsuite-site-bootstrap Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/README.md Install the LoongSuite site-bootstrap package via pip. ```bash pip install loongsuite-site-bootstrap ``` -------------------------------- ### Install opentelemetry-instrumentation-pyramid via pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-pyramid/README.rst Use pip to install the OpenTelemetry Pyramid instrumentation package. This is the required setup step before using the instrumentation. ```shell pip install opentelemetry-instrumentation-pyramid ``` -------------------------------- ### Install AgentScope Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/README.md Install the AgentScope package using pip. ```bash pip install agentscope ``` -------------------------------- ### Run Docker Compose services in detached mode Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/exporter/opentelemetry-exporter-prometheus-remote-write/example/README.md Starts all services defined in the example's docker-compose.yml in detached mode, freeing the terminal. No logs are shown; attach to logs with `docker logs ${CONTAINER_ID} --follow`. ```bash docker-compose up -d ``` -------------------------------- ### Run with LoongSuite (aftersales example) Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/examples/ecommerce-customer-service/README.md Run the app with an after-sales question about order DEMO-1001. ```bash loongsuite-instrument python app.py \ --question "订单 DEMO-1001 昨天签收,鞋底有问题,应该怎么处理?" ``` -------------------------------- ### Run Bedrock zero-code example with opentelemetry-instrument Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-botocore/examples/bedrock-runtime/zero-code/README.rst Executes the converse.py example using dotenv and opentelemetry-instrument, exporting traces and logs to an OTLP endpoint. ```bash dotenv run -- opentelemetry-instrument python converse.py ``` -------------------------------- ### Install Jaeger with Helm Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/deploy/deploy-Jaeger&Elasticsearch-en.md Installs the Jaeger Helm chart into the jaeger-system namespace using the jaeger-values.yaml file. ```bash helm install jaeger jaegertracing/jaeger \ --namespace jaeger-system \ -f jaeger-values.yaml ``` -------------------------------- ### Install opentelemetry-resource-detector-containerid via pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/resource/opentelemetry-resource-detector-containerid/README.rst Install the library with pip. This is the required setup step before using the detector. ```shell pip install opentelemetry-resource-detector-containerid ``` -------------------------------- ### Install loongsuite-instrumentation-minisweagent Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-minisweagent/README.md Install the package via pip. ```bash pip install loongsuite-instrumentation-minisweagent ``` -------------------------------- ### Install opentelemetry-util-genai Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/util/opentelemetry-util-genai/README.rst Install the package using pip. This is the only installation command provided. ```shell pip install opentelemetry-util-genai ``` -------------------------------- ### Install opentelemetry-instrumentation-boto3sqs Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/docs/instrumentation/boto3sqs/boto3sqs.rst Install the OpenTelemetry Boto3 SQS instrumentation package via pip. This is the required setup step before using the library to trace Boto3 SQS requests. ```default pip install opentelemetry-instrumentation-boto3sqs ``` -------------------------------- ### Install opentelemetry-instrumentation-claude-agent-sdk Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-genai/opentelemetry-instrumentation-claude-agent-sdk/README.rst Install the package via pip. Requires a valid Anthropic API key for the examples. ```shell pip install opentelemetry-instrumentation-claude-agent-sdk ``` -------------------------------- ### Install opentelemetry-exporter-richconsole Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/exporter/opentelemetry-exporter-richconsole/README.rst Install the package via pip. This is the required setup step before using the Rich console exporter. ```shell pip install opentelemetry-exporter-richconsole ``` -------------------------------- ### Install loongsuite-instrumentation-webarena Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-webarena/README.md Install the package via pip. ```bash pip install loongsuite-instrumentation-webarena ``` -------------------------------- ### Install tox-uv with pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/CONTRIBUTING.md Optionally install tox-uv at the host level. By default, tox.ini automatically creates a provisioned tox environment with tox-uv, but this command installs it explicitly. ```sh pip install tox-uv ``` -------------------------------- ### Install LoongSuite distro and LangChain instrumentation Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-langchain/README.md Install the LoongSuite distribution and the LangChain instrumentation package from PyPI. This is the recommended Option C installation path. ```bash # Step 1: install LoongSuite distro pip install loongsuite-distro # Step 2 (Option C): install this instrumentation from PyPI pip install loongsuite-instrumentation-langchain ``` -------------------------------- ### Install opentelemetry-instrumentation-wsgi Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-wsgi/README.rst Install the WSGI middleware package via pip. This is the required setup step before using the middleware in any WSGI framework. ```bash pip install opentelemetry-instrumentation-wsgi ``` -------------------------------- ### Install upstream OpenTelemetry and local LoongSuite components Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/README.md Install upstream OpenTelemetry Python core packages and local LoongSuite components from a Git checkout. Use a single pip install command so the resolver sees all constraints together; splitting installs can downgrade or replace api+semconv when local editable deps are installed later. ```bash cd loongsuite-python GIT_ROOT="git+https://github.com/open-telemetry/opentelemetry-python.git" # Use ONE pip install command so resolver sees all constraints together; # split installs can downgrade/replace api+semconv when local editable deps are installed later. pip install \ "${GIT_ROOT}#subdirectory=opentelemetry-api" \ "${GIT_ROOT}#subdirectory=opentelemetry-semantic-conventions" \ "${GIT_ROOT}#subdirectory=opentelemetry-sdk" \ -e ./util/opentelemetry-util-genai \ -e ./opentelemetry-instrumentation \ -e ./loongsuite-distro ``` -------------------------------- ### Run the example with opentelemetry-instrument Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-genai/opentelemetry-instrumentation-google-genai/examples/zero-code/README.rst Set the PROMPT environment variable and run the example using dotenv and opentelemetry-instrument. Exports traces, logs, and metrics to an OTLP endpoint. ```bash export PROMPT="Your prompt here" dotenv run -- opentelemetry-instrument python main.py ``` -------------------------------- ### Installing Google ADK Instrumentation Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-google-adk/README.md Install the LoongSuite distro, the Google ADK instrumentation package, and required dependencies. The google-adk version must be at least 0.1.0. Optional demo dependencies (fastapi, uvicorn, pydantic) are only needed when running examples. ```shell # Step 1: install LoongSuite distro pip install loongsuite-distro # Step 2 (Option C): install this instrumentation from PyPI pip install loongsuite-instrumentation-google-adk # Google ADK and LLM Dependencies pip install google-adk>=0.1.0 pip install litellm # Demo Application Dependencies (optional, only if running examples) pip install fastapi uvicorn pydantic ``` -------------------------------- ### Quick Start: Install and Run with Auto Instrumentation Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-google-adk/README.md Install the LoongSuite distro and Google ADK instrumentation, set the DASHSCOPE_API_KEY environment variable, and run your app with the loongsuite-instrument CLI. The command uses --traces_exporter console and --service_name my-adk-app. ```bash # Step 1: install LoongSuite distro pip install loongsuite-distro # Step 2 (Option C): install instrumentation from PyPI pip install loongsuite-instrumentation-google-adk # App dependencies pip install google-adk litellm # Configure export DASHSCOPE_API_KEY=your-api-key # Run with auto instrumentation loongsuite-instrument \ --traces_exporter console \ --service_name my-adk-app \ python your_app.py ``` -------------------------------- ### Install opentelemetry-exporter-otlp Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/README.md Installs the OTLP exporter package required for remote/production telemetry export. ```bash pip install opentelemetry-exporter-otlp ``` -------------------------------- ### Start, view logs, and destroy services with docker compose Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/deploy/deploy-Jaeger&Elasticsearch-en.md Commands to start all services in detached mode, follow logs, and tear down the stack. Use 'docker compose up -d' to start, 'docker compose logs -f' to view logs, and 'docker compose down' to destroy. ```plaintext # Start docker compose up -d # View logs docker compose logs -f # Destroy docker compose down ``` -------------------------------- ### Run the example with dotenv Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-genai/opentelemetry-instrumentation-anthropic/examples/manual/README.rst Runs main.py using dotenv to load environment variables from the .env file. The example generates a poem with Claude and exports traces and logs to the configured OTLP endpoint. ```shell dotenv run -- python main.py ``` -------------------------------- ### Create virtual environment with uv sync Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/CONTRIBUTING.md After installing uv, run this command to create a virtual environment in the .venv directory and install all necessary dependencies. ```sh uv sync ``` -------------------------------- ### Installation via git clone and pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-litellm/README.rst Clone the repository and install the instrumentation package from the local directory. ```console git clone https://github.com/alibaba/loongsuite-python.git cd loongsuite-python pip install ./instrumentation-loongsuite/loongsuite-instrumentation-litellm ``` -------------------------------- ### Install loongsuite-instrumentation-slop-code Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-slop-code/README.md Install the package via pip. ```bash pip install loongsuite-instrumentation-slop-code ``` -------------------------------- ### Install pre-commit with pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/CONTRIBUTING.md Install pre-commit to run ruff and rstcheck automatically before each commit. Use the dev-requirements.txt constraint file. ```console pip install pre-commit -c dev-requirements.txt ``` -------------------------------- ### Install loongsuite-instrumentation-vita Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-vita/README.md Install the package via pip. ```bash pip install loongsuite-instrumentation-vita ``` -------------------------------- ### Install LoongSuite distro and MCP instrumentation Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-mcp/README.md Install the LoongSuite distro, then use loongsuite-bootstrap to install instrumentations from the LoongSuite release. Optionally specify a version with --version. Also install the MCP dependency mcp==1.13.1. ```shell # Step 1: install LoongSuite distro pip install loongsuite-distro # Step 2 (Option A): install instrumentations from LoongSuite release loongsuite-bootstrap -a install --latest # for specific version: loongsuite-bootstrap -a install --version X.Y.Z # MCP dependency pip install mcp==1.13.1 ``` -------------------------------- ### Install loongsuite-distro and bootstrap Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-agno/README.md Install the LoongSuite distribution and automatically install the latest instrumentation packages, including the Agno instrumentation. ```shell pip install loongsuite-distro loongsuite-bootstrap -a install --latest ``` -------------------------------- ### Install opentelemetry-instrumentation-system-metrics Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-system-metrics/README.rst Install the package to collect system performance metrics. ```shell pip install opentelemetry-instrumentation-system-metrics ``` -------------------------------- ### Install opentelemetry-resource-detector-container Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/resource/opentelemetry-resource-detector-container/README.rst Install the package using pip. ```bash pip install opentelemetry-resource-detector-container ``` -------------------------------- ### Run QwenPaw app Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-qwenpaw/README.md Start QwenPaw with Site-bootstrap enabled in the same shell/session. ```bash qwenpaw app ``` -------------------------------- ### Start LoongCollector in background Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/README.md Launches LoongCollector in the background, redirecting stdout and stderr to log files. This is the third step after installing LoongCollector and adding the OTLP configuration. ```plaintext nohup ./loongcollector > stdout.log 2> stderr.log & ``` -------------------------------- ### Install loongsuite-instrumentation-claw-eval Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-claw-eval/README.md Install the package via pip. ```bash pip install loongsuite-instrumentation-claw-eval ``` -------------------------------- ### Install WildToolBench and LoongSuite instrumentation Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-wildtool/README.md Install the WildToolBench framework from source and the LoongSuite instrumentation package. WildToolBench is not available on PyPI. ```bash pip install -e /path/to/WildToolBench/wild-tool-bench pip install loongsuite-instrumentation-wildtool ``` -------------------------------- ### Example instruments and instruments-any entries in pyproject.toml Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/CONTRIBUTING.md Shows how to configure the `instruments` and `instruments-any` optional dependencies in `pyproject.toml`. `instruments` lists all required dependencies, while `instruments-any` lists alternatives where at least one must be present. This example requires both `util` and `common` plus either `foo` or `bar`. ```TOML [project.optional-dependencies] instruments = [ "util ~= 1.0" "common ~= 2.0" ] instruments-any = [ "foo ~= 3.0" "bar ~= 4.0" ] ``` -------------------------------- ### Install loongsuite-instrumentation-dashscope via pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-dashscope/README.rst Install the package using pip. This is the first step before using the instrumentation. ```bash pip install loongsuite-instrumentation-dashscope ``` -------------------------------- ### Install opentelemetry-instrumentation-psycopg via pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-psycopg/README.rst Use this command to install the OpenTelemetry Psycopg instrumentation package. It is the required setup step before using the instrumentation. ```shell pip install opentelemetry-instrumentation-psycopg ``` -------------------------------- ### Install LoongSuite distro and instrumentations Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-dify/README.md Install the LoongSuite distro and optionally install instrumentations from the LoongSuite release. Use --version to specify a particular version. ```shell # Step 1: install LoongSuite distro pip install loongsuite-distro # Step 2 (Option A): install instrumentations from LoongSuite release loongsuite-bootstrap -a install --latest # for specific version: loongsuite-bootstrap -a install --version X.Y.Z ``` -------------------------------- ### Install opentelemetry-instrumentation-logging via pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-logging/README.rst Install the OpenTelemetry logging instrumentation package using pip. This is the required setup step before using the integration. ```shell pip install opentelemetry-instrumentation-logging ``` -------------------------------- ### Install opentelemetry-propagator-ot-trace Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/propagator/opentelemetry-propagator-ot-trace/README.rst Install the package via pip. ```shell pip install opentelemetry-propagator-ot-trace ``` -------------------------------- ### Install opentelemetry-instrumentation-jinja2 via pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-jinja2/README.rst Install the OpenTelemetry jinja2 integration package using pip. This is the required setup step before using the instrumentation. ```shell pip install opentelemetry-instrumentation-jinja2 ``` -------------------------------- ### Install pre-commit git hooks Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/CONTRIBUTING.md Run this command inside the git repository to install pre-commit as git hooks, enabling automatic checks before commits. ```console pre-commit install ``` -------------------------------- ### Install opentelemetry-instrumentation-mysqlclient Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-mysqlclient/README.rst Install the OpenTelemetry mysqlclient instrumentation package via pip. ```bash pip install opentelemetry-instrumentation-mysqlclient ``` -------------------------------- ### Install from local source for validation Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-agno/README.md Install the instrumentation and utility packages from local source for development or validation. ```shell pip install -e ./opentelemetry-instrumentation \ -e ./util/opentelemetry-util-genai \ -e ./instrumentation-loongsuite/loongsuite-instrumentation-agno ``` -------------------------------- ### Run with LoongSuite (presales example) Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/examples/ecommerce-customer-service/README.md Run the app with LoongSuite instrumentation and console span export for a local smoke test. The question is in Chinese. ```bash export OTEL_SERVICE_NAME="ecommerce-customer-service" export OTEL_TRACES_EXPORTER="console" export OTEL_METRICS_EXPORTER="none" export OTEL_LOGS_EXPORTER="none" export OTEL_SEMCONV_STABILITY_OPT_IN="gen_ai_latest_experimental" loongsuite-instrument python app.py \ --question "云步通勤鞋适合日常步行吗?42 码有货吗?" ``` -------------------------------- ### Run the example with dotenv Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-genai/opentelemetry-instrumentation-google-genai/examples/manual/README.rst Set the PROMPT environment variable and run main.py using dotenv to load .env configuration. ```bash export PROMPT="Your prompt here" dotenv run -- python main.py ``` -------------------------------- ### Install opentelemetry-instrumentation-tortoiseorm Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/docs/instrumentation/tortoiseorm/tortoiseorm.rst Install the instrumentation package via pip. This is the required setup step before using the library. ```default pip install opentelemetry-instrumentation-tortoiseorm ``` -------------------------------- ### Install opentelemetry-util-http via pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/util/opentelemetry-util-http/README.rst Install the library using pip. ```bash pip install opentelemetry-util-http ``` -------------------------------- ### Install LoongSuite distro and LangGraph instrumentation Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-langgraph/README.md Install the LoongSuite distribution and the LangGraph instrumentation package from PyPI. ```bash # Step 1: install LoongSuite distro pip install loongsuite-distro # Step 2 (Option C): install this instrumentation from PyPI pip install loongsuite-instrumentation-langgraph ``` -------------------------------- ### Install Elasticsearch with Helm Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/deploy/deploy-Jaeger&Elasticsearch-en.md Installs the Elasticsearch Helm chart into the jaeger-system namespace using the elasticsearch-values.yaml file. ```bash helm install elasticsearch elastic/elasticsearch \ --namespace jaeger-system \ -f elasticsearch-values.yaml ``` -------------------------------- ### Configure DashScope model Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/examples/ecommerce-customer-service/README.md Set the DashScope API key for the default qwen-plus model. DASHSCOPE_API_KEY takes precedence over OPENAI_API_KEY. ```bash export DASHSCOPE_API_KEY="your-api-key" ``` -------------------------------- ### Install opentelemetry-instrumentation-asyncio Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-asyncio/README.rst Install the package using pip. ```bash pip install opentelemetry-instrumentation-asyncio ``` -------------------------------- ### Run app with loongsuite-instrument (console exporters) Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/README.md Starts the application under loongsuite-instrument, exporting traces and metrics to the console. Replace python demo.py with your actual command. ```bash loongsuite-instrument \ --traces_exporter console \ --metrics_exporter console \ --service_name demo \ python demo.py ``` -------------------------------- ### Installation commands for LoongSuite Claude Agent SDK instrumentation Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-claude-agent-sdk/README.rst Install required OpenTelemetry packages, the Claude Agent SDK, the instrumentation package, and the opentelemetry-util-genai dependency. The package is in development and must be installed from source. ```bash pip install opentelemetry-distro opentelemetry-exporter-otlp opentelemetry-bootstrap -a install pip install claude-agent-sdk # Install this instrumentation pip install ./instrumentation-loongsuite/loongsuite-instrumentation-claude-agent-sdk # Note: This instrumentation uses ExtendedTelemetryHandler from opentelemetry-util-genai pip install ./util/opentelemetry-util-genai ``` -------------------------------- ### Install opentelemetry-instrumentation-boto Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-boto/README.rst Install the OpenTelemetry Boto instrumentation library via pip. ```bash pip install opentelemetry-instrumentation-boto ``` -------------------------------- ### Install opentelemetry-instrumentation-asyncpg Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-asyncpg/README.rst Install the library to enable tracing of PostgreSQL queries made by the asyncpg library. ```shell pip install opentelemetry-instrumentation-asyncpg ``` -------------------------------- ### Install opentelemetry-instrumentation-aiohttp-server Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/docs/instrumentation/aiohttp_server/aiohttp_server.rst Install the instrumentation package via pip. ```default pip install opentelemetry-instrumentation-aiohttp-server ``` -------------------------------- ### Create bootstrap-config.json Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/README.md Create ~/.loongsuite/bootstrap-config.json with OpenTelemetry environment keys. This example sets service name, OTLP protocol, endpoint, and exporters. ```json { "OTEL_SERVICE_NAME": "demo", "OTEL_EXPORTER_OTLP_PROTOCOL": "grpc", "OTEL_EXPORTER_OTLP_ENDPOINT": "http://127.0.0.1:4317", "OTEL_TRACES_EXPORTER": "otlp", "OTEL_METRICS_EXPORTER": "otlp" } ``` -------------------------------- ### Install cutting-edge packages from repository Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/docs/index.rst Clone the repository and perform editable installs for pre-1.0 packages not yet on PyPI. Includes Flask, Botocore, OpenAI v2, AWS SDK extension, and container ID resource detector. ```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 ``` -------------------------------- ### Install opentelemetry-instrumentation-pymysql Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-pymysql/README.rst Install the OpenTelemetry PyMySQL instrumentation package via pip. ```bash pip install opentelemetry-instrumentation-pymysql ``` -------------------------------- ### Install opentelemetry-instrumentation- Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/_template/README.rst Install the instrumentation package via pip. Replace with the actual library name before use. ```shell pip install opentelemetry-instrumentation- ``` -------------------------------- ### Install opentelemetry-instrumentation-asyncclick Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/docs/instrumentation/asyncclick/asyncclick.rst Install the asyncclick instrumentation package via pip. ```default pip install opentelemetry-instrumentation-asyncclick ``` -------------------------------- ### Install opentelemetry-instrumentation-falcon Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-falcon/README.rst Install the Falcon instrumentation package via pip. ```bash pip install opentelemetry-instrumentation-falcon ``` -------------------------------- ### Install opentelemetry-instrumentation-aiohttp-client Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-aiohttp-client/README.rst Install the OpenTelemetry aiohttp client instrumentation package via pip. ```bash pip install opentelemetry-instrumentation-aiohttp-client ``` -------------------------------- ### Install all instrumentations via loongsuite-bootstrap Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/README.md Uses loongsuite-bootstrap to install all LoongSuite instrumentations from a GitHub Release tarball and compatible OpenTelemetry instrumentation packages. Use --version to specify a release version. ```bash loongsuite-bootstrap -a install --latest # for specific version: loongsuite-bootstrap -a install --version X.Y.Z ``` -------------------------------- ### Install loongsuite-instrumentation-algotune via pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-algotune/README.md Install the AlgoTune OpenTelemetry instrumentation package using pip. ```bash pip install loongsuite-instrumentation-algotune ``` -------------------------------- ### Install loongsuite-instrumentation-widesearch via pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-widesearch/README.md Install the package with pip. Run this before using the instrumentation. ```bash pip install loongsuite-instrumentation-widesearch ``` -------------------------------- ### Install with pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-bfclv4/README.md Install the LoongSuite BFCL v4 instrumentation package via pip. ```bash pip install loongsuite-instrumentation-bfclv4 ``` -------------------------------- ### Install tox with pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/CONTRIBUTING.md Install tox to automate development tasks such as testing against multiple Python versions. Run this command in your environment before using tox. ```sh pip install tox ``` -------------------------------- ### Install google-adk Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-google-adk/README.md Install the required google-adk package version to avoid module import errors. ```bash pip install google-adk>=0.1.0 ``` -------------------------------- ### Install opentelemetry-distro with OTLP extras Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/opentelemetry-instrumentation/README.rst Install the default distro and configurator package with OTLP support. Required for auto instrumentation. ```bash pip install "opentelemetry-distro[otlp]" ``` -------------------------------- ### Install opentelemetry-instrumentation-dbapi Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-dbapi/README.rst Install the OpenTelemetry Database API instrumentation package via pip. ```bash pip install opentelemetry-instrumentation-dbapi ``` -------------------------------- ### Shutdown Docker Compose services Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/exporter/opentelemetry-exporter-prometheus-remote-write/example/README.md Stops and removes the services started by `docker-compose up -d`. ```bash docker-compose down ``` -------------------------------- ### Installation commands Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-genai/opentelemetry-instrumentation-openai-agents-v2/README.rst Install the instrumentation package and the openai-agents SDK. Requires an existing OpenTelemetry configuration. ```console pip install opentelemetry-instrumentation-openai-agents-v2 pip install openai-agents ``` -------------------------------- ### Install opentelemetry-instrumentation-kafka-python Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/docs/instrumentation/kafka_python/kafka_python.rst Install the OpenTelemetry kafka-python instrumentation package via pip. ```default pip install opentelemetry-instrumentation-kafka-python ``` -------------------------------- ### Install opentelemetry-propagator-aws-xray Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/propagator/opentelemetry-propagator-aws-xray/README.rst Install the AWS X-Ray propagator package via pip. ```shell pip install opentelemetry-propagator-aws-xray ``` -------------------------------- ### Verify Jaeger Installation Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/deploy/deploy-Jaeger&Elasticsearch-en.md Commands to check that all pods, services, and ingresses are running correctly in the jaeger-system namespace. ```bash # Check if all pods are running normally kubectl get pods -n jaeger-system # Check services kubectl get svc -n jaeger-system # Check ingress kubectl get ingress -n jaeger-system ``` -------------------------------- ### Install opentelemetry-sdk Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/sdk-extension/opentelemetry-sdk-extension-aws/README.rst Install the base OpenTelemetry SDK package required for tracing. ```bash pip install opentelemetry-sdk ``` -------------------------------- ### Install opentelemetry-instrumentation-confluent-kafka Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/docs/instrumentation/confluent_kafka/confluent_kafka.rst Install the library via pip to enable tracing of confluent-kafka requests. ```default pip install opentelemetry-instrumentation-confluent-kafka ``` -------------------------------- ### Enable the Site-bootstrap hook Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-qwenpaw/README.md Set the environment variable to enable the Site-bootstrap hook in every shell or service manager that starts QwenPaw. ```bash export LOONGSUITE_PYTHON_SITE_BOOTSTRAP=True ``` -------------------------------- ### Install opentelemetry-resource-detector-azure via pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/resource/opentelemetry-resource-detector-azure/README.rst Install the package with pip before using the resource detectors. ```shell pip install opentelemetry-resource-detector-azure ``` -------------------------------- ### List storage classes with kubectl get sc Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/deploy/deploy-Jaeger&Elasticsearch-en.md Lists available storage classes to determine the storageClassName for the Elasticsearch PersistentVolumeClaim. ```yaml kubectl get sc ``` -------------------------------- ### Install opentelemetry-instrumentation package Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/opentelemetry-instrumentation/README.md Install the package that provides the auto-instrumentation command. Use this before running the opentelemetry-instrument command. ```bash pip install opentelemetry-instrumentation ``` -------------------------------- ### Install LoongSuite Mem0 Instrumentation Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-mem0/README.md Install the LoongSuite distro, the Mem0 instrumentation package, and an optional threading context propagation dependency. ```bash # Step 1: install LoongSuite distro pip install loongsuite-distro # Step 2 (Option C): install this instrumentation from PyPI pip install loongsuite-instrumentation-mem0 # Optional dependency for threading context propagation pip install opentelemetry-instrumentation-threading ``` -------------------------------- ### Initialize OpenTelemetry SDK with console exporters Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/README.md Set up the OpenTelemetry SDK with console exporters for traces and metrics. This must be done before any telemetry is emitted. It configures a TracerProvider with a BatchSpanProcessor and a MeterProvider with a PeriodicExportingMetricReader. ```python from opentelemetry import metrics, trace from opentelemetry.sdk.metrics import MeterProvider from opentelemetry.sdk.metrics.export import ConsoleMetricExporter, PeriodicExportingMetricReader from opentelemetry.sdk.resources import Resource from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter resource = Resource.create({"service.name": "demo"}) tracer_provider = TracerProvider(resource=resource) tracer_provider.add_span_processor(BatchSpanProcessor(ConsoleSpanExporter())) trace.set_tracer_provider(tracer_provider) metric_reader = PeriodicExportingMetricReader(ConsoleMetricExporter()) metrics.set_meter_provider( MeterProvider(resource=resource, metric_readers=[metric_reader]) ) ``` -------------------------------- ### Install development version with editable install Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/README-upstream.md Install the development version of an instrumentation package by cloning or forking the repository and performing an editable install. Replace {integration} with the library name. ```sh pip install -e ./instrumentation/opentelemetry-instrumentation-{integration} ``` -------------------------------- ### Install with instruments extra Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-microsoft-agent-framework/README.rst Install the instrumentation package together with Microsoft Agent Framework in the target application environment. ```console pip install "loongsuite-instrumentation-microsoft-agent-framework[instruments]" ``` -------------------------------- ### Install opentelemetry-contrib-instrumentations Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/opentelemetry-contrib-instrumentations/README.rst Use pip to install the opentelemetry-contrib-instrumentations package, which installs all instrumentation packages hosted by the OpenTelemetry Python Contrib repository. ```shell pip install opentelemetry-contrib-instrumentations ``` -------------------------------- ### Install LoongSuite distro and CrewAI instrumentation Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-crewai/README.md Install the LoongSuite distro and the CrewAI instrumentation package from PyPI. Requires Python and pip. ```bash # Step 1: install LoongSuite distro pip install loongsuite-distro # Step 2 (Option C): install this instrumentation from PyPI pip install loongsuite-instrumentation-crewai ``` -------------------------------- ### Run loongsuite-instrument with OTLP exporters to AgentScope Studio Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/README.md Instruments a Python script (demo.py) to export traces and metrics via OTLP to the AgentScope Studio endpoint. Uses the http/protobuf protocol and sets the service name to 'demo'. Alternatively, set OTEL_EXPORTER_OTLP_TRACES_ENDPOINT and OTEL_EXPORTER_OTLP_METRICS_ENDPOINT environment variables. ```shell loongsuite-instrument \ --traces_exporter otlp \ --metrics_exporter otlp \ --exporter_otlp_protocol http/protobuf \ --exporter_otlp_endpoint http://127.0.0.1:31415 \ --service_name demo \ python demo.py ``` -------------------------------- ### Configure OTLP/gRPC export via bootstrap-config.json Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-qwenpaw/README.md Example JSON configuration for OTLP/gRPC export. Adjust host, port, and service name as needed. ```json { "OTEL_SERVICE_NAME": "qwenpaw", "OTEL_EXPORTER_OTLP_PROTOCOL": "grpc", "OTEL_EXPORTER_OTLP_ENDPOINT": "http://127.0.0.1:4317", "OTEL_TRACES_EXPORTER": "otlp", "OTEL_METRICS_EXPORTER": "otlp" } ``` -------------------------------- ### Install opentelemetry-instrumentation-flask with pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-flask/README.rst Install the OpenTelemetry Flask instrumentation library to track web requests in Flask applications. ```bash pip install opentelemetry-instrumentation-flask ``` -------------------------------- ### Create branch, stage changes, and commit Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/CONTRIBUTING.md Create a new branch, stage all changes, commit, and push the branch to your fork. ```sh git checkout -b feature ``` ```sh git add . ``` ```sh git commit git push fork feature ``` -------------------------------- ### opentelemetry-bootstrap command usage Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/opentelemetry-instrumentation/README.rst Command to install or list default and detected instrumentation packages. Use --action=install or -a install to install them. ```bash opentelemetry-bootstrap [-a |--action=][install|requirements] ``` -------------------------------- ### Installation commands for Qwen-Agent instrumentation Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-qwen-agent/README.md Install the required OpenTelemetry packages, Qwen-Agent, and the instrumentation from the LoongSuite repo. The published package name is also provided. ```bash pip install opentelemetry-distro opentelemetry-exporter-otlp opentelemetry-bootstrap -a install pip install "qwen-agent >= 0.0.20" pip install ./util/opentelemetry-util-genai # Install this instrumentation (from the LoongSuite repo) pip install ./instrumentation-loongsuite/loongsuite-instrumentation-qwen-agent ``` ```bash pip install loongsuite-instrumentation-qwen-agent ``` -------------------------------- ### Install opentelemetry-distro via pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/opentelemetry-distro/README.rst Install the OpenTelemetry Distro package using pip. This package provides entrypoints to configure OpenTelemetry. ```bash pip install opentelemetry-distro ``` -------------------------------- ### Enable the site-bootstrap hook Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/README.md Set environment variables to enable the .pth hook. Optionally suppress the success line and specify a status file. ```bash export LOONGSUITE_PYTHON_SITE_BOOTSTRAP=True # Optional for interactive CLIs/apps: suppress the generic success line on stdout. export LOONGSUITE_PYTHON_SITE_BOOTSTRAP_LOG_SUCCESS=False export LOONGSUITE_PYTHON_SITE_BOOTSTRAP_STATUS_FILE=/tmp/loongsuite-site-bootstrap-status.json ``` -------------------------------- ### Create demo.py with Agno agent Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-agno/README.md Example Agno agent using DashScope model with a weather tool, demonstrating non-streaming and streaming runs. Requires DASHSCOPE_API_KEY environment variable. ```python import os from agno.agent import Agent from agno.models.dashscope import DashScope def get_weather(city: str) -> str: return f"{city}: sunny, 24C" agent = Agent( name="AgnoDashScopeDemo", model=DashScope( id=os.getenv("DASHSCOPE_MODEL", "qwen-plus"), api_key=os.environ["DASHSCOPE_API_KEY"], base_url=os.getenv( "DASHSCOPE_BASE_URL", "https://dashscope.aliyuncs.com/compatible-mode/v1", ), ), tools=[get_weather], instructions=["When weather is requested, use the get_weather tool."], ) response = agent.run("What is the weather in Hangzhou?") print(response.content) for event in agent.run("Stream a short answer.", stream=True): if getattr(event, "content", None): print(event.content, end="") ``` -------------------------------- ### Run demo.py with loongsuite-instrument Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-mem0/README.md Start the application with the recommended loongsuite-instrument command, exporting traces to the console. Requires the environment variables set as shown. ```bash export OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=SPAN_ONLY export OTEL_INSTRUMENTATION_GENAI_EMIT_EVENT=true loongsuite-instrument \ --traces_exporter console \ python demo.py ``` -------------------------------- ### Configure console exporters via bootstrap-config.json Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-qwenpaw/README.md Example JSON configuration for quick local debugging with console exporters. ```json { "OTEL_SERVICE_NAME": "qwenpaw", "OTEL_TRACES_EXPORTER": "console", "OTEL_METRICS_EXPORTER": "console" } ``` -------------------------------- ### Install OpenTelemetry packages via pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/docs/index.rst Install complimentary OpenTelemetry packages from PyPI using pip. Replace placeholders with actual package names. ```sh pip install opentelemetry-exporter-{exporter} pip install opentelemetry-instrumentation-{instrumentation} pip install opentelemetry-sdk-extension-{sdk-extension} ``` -------------------------------- ### Install instrumentation package with pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/README-upstream.md Install an OpenTelemetry instrumentation package for a specific integration using pip. Replace {integration} with the library name. ```sh pip install opentelemetry-instrumentation-{integration} ``` -------------------------------- ### Mem0 demo.py example Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-mem0/README.md A minimal Mem0 application that adds a memory entry and searches for it. Requires the Mem0 library. ```python from mem0 import Memory memory = Memory() memory.add("User likes Python programming", user_id="user123") results = memory.search("What does the user like?", user_id="user123") print(results) ``` -------------------------------- ### Install opentelemetry-instrumentation-click Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/docs/instrumentation/click/click.rst Install the OpenTelemetry click instrumentation package via pip. Required before using the library to trace requests made by the click library. ```default pip install opentelemetry-instrumentation-click ``` -------------------------------- ### Clone upstream repo and add fork as origin Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/CONTRIBUTING.md Initial setup for contributing: clone the upstream repository and add your fork as a remote named 'fork'. ```sh git clone https://github.com/open-telemetry/opentelemetry-python-contrib.git cd opentelemetry-python-contrib ``` ```sh git remote add fork https://github.com/YOUR_GITHUB_USERNAME/opentelemetry-python-contrib.git ``` -------------------------------- ### Override endpoint or model Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/examples/ecommerce-customer-service/README.md Override the compatible endpoint or model when needed. DASHSCOPE_API_KEY takes precedence over OPENAI_API_KEY. ```bash export OPENAI_API_KEY="your-api-key" export OPENAI_BASE_URL="https://your-compatible-endpoint/v1" export MODEL_NAME="your-model" ``` -------------------------------- ### Install LoongSuite AgentScope instrumentation Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-agentscope/README.md Install the LoongSuite distro, the AgentScope instrumentation package, and optionally the agentscope dependency. Use these commands in sequence to set up the environment. ```bash # Step 1: install LoongSuite distro pip install loongsuite-distro # Step 2 (Option C): install this instrumentation from PyPI pip install loongsuite-instrumentation-agentscope # Optional app dependency pip install agentscope ``` -------------------------------- ### Install opentelemetry-instrumentation-urllib3 Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-urllib3/README.rst Install the package via pip. ```shell pip install opentelemetry-instrumentation-urllib3 ``` -------------------------------- ### Install opentelemetry-instrumentation-urllib Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation/opentelemetry-instrumentation-urllib/README.rst Install the package via pip. ```bash pip install opentelemetry-instrumentation-urllib ``` -------------------------------- ### Install loongsuite-instrumentation-a2a via pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-a2a/README.md Install the package. The opentelemetry-util-genai runtime dependency is declared, so ExtendedTelemetryHandler support is available in a clean environment without an editable test install. ```bash pip install loongsuite-instrumentation-a2a ``` -------------------------------- ### Run tox for a specific instrumentation package (e.g., opentelemetry-instrumentation-aiopg) Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/CONTRIBUTING.md First-time run of tox for a specific package, which includes pre-steps that install dependencies. Use this command to run tests for the opentelemetry-instrumentation-aiopg package. ```console tox -e py314-test-instrumentation-aiopg ``` -------------------------------- ### Install opentelemetry-processor-baggage Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/processor/opentelemetry-processor-baggage/README.rst Install the package via pip. ```bash pip install opentelemetry-processor-baggage ``` -------------------------------- ### Manually install loongsuite-instrumentation-agentscope Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/README.md Installs a specific instrumentation package via pip. Note: for packages under instrumentation-genai, use Option A or B to avoid dependency conflicts with opentelemetry-util-genai. ```bash pip install loongsuite-instrumentation-agentscope ``` -------------------------------- ### Start Dify with loongsuite-instrument Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-dify/README.md Modify the startup script (entrypoint.sh) to use loongsuite-instrument for application startup, wrapping the gunicorn command. ```shell loongsuite-instrument gunicorn \ --bind "${DIFY_BIND_ADDRESS:-0.0.0.0}:${DIFY_PORT:-5001}" \ --workers ${SERVER_WORKER_AMOUNT:-1} \ --worker-class ${SERVER_WORKER_CLASS:-gevent} \ --worker-connections ${SERVER_WORKER_CONNECTIONS:-10} \ --timeout ${GUNICORN_TIMEOUT:-200} \ app:app ``` -------------------------------- ### Run loongsuite-otelgui-plugin-verify helper Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-google-adk/README.md Runs the plugin smoke helper to verify the GenAI util agent trace, selecting the trace explicitly because Google ADK also emits an 'invocation' trace. Requires setting the repo root, base URL, service name, and various environment variables. ```bash python /path/to/run_loongsuite_plugin_smoke.py \ --repo-root /path/to/loongsuite-python \ --base-url http://127.0.0.1:5173 \ --service-name loongsuite-google-adk-non-stream \ --root-span-contains invoke_agent \ --capture-message-content SPAN_ONLY \ --expect-span-kind AGENT \ --expect-span-kind LLM \ --expect-span-kind TOOL \ --expect-content \ --env GOOGLE_ADK_SMOKE_CONFIGURE_OTLP=1 \ --env GOOGLE_ADK_SMOKE_DISABLE_NATIVE_AGENT_SPAN=1 \ --env OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://127.0.0.1:5173/v1/traces \ --run "python examples/otelgui_smoke.py --scenario non-stream" ``` -------------------------------- ### Install loongsuite-instrumentation-terminus2 via pip Source: https://github.com/alibaba/loongsuite-python-agent/blob/main/instrumentation-loongsuite/loongsuite-instrumentation-terminus2/README.md Install the package with pip. ```bash pip install loongsuite-instrumentation-terminus2 ```