SuperAPI AI 工具集

observability-edot-python-instrument

编程与开发

查看项目

更新于 10-16 08:36

技能介绍

用途:为 Python 应用接入 EDOT Python 代理,实现自动的追踪、指标与日志采集。

主要能力与用法:先阅读 EDOT Python 安装与配置指南以及 OpenTelemetry Python 自动注入文档。安装 elastic-opentelemetry(pip,写入 requirements.txt 或等价文件);在镜像构建阶段运行 edot-bootstrap --action=install,为检测到的库安装自动注入包。用 opentelemetry-instrument 包装应用入口,例如 opentelemetry-instrument gunicorn app:app 或 opentelemetry-instrument python app.py,否则不会采集到遥测数据。

必要环境变量:OTEL_SERVICE_NAME;OTEL_EXPORTER_OTLP_ENDPOINT,必须使用托管 OTLP 端点或 EDOT Collector 地址,不要使用 APM Server 地址(不得出现 apm-server、:8200、/intake/v2/events);OTEL_EXPORTER_OTLP_HEADERS,格式为 Authorization=ApiKey <key> 或 Authorization=Bearer <token>。

限制:不要设置 OTEL_TRACES_EXPORTER、OTEL_METRICS_EXPORTER、OTEL_LOGS_EXPORTER,默认值已正确;不要添加代码级 SDK 配置(如 TracerProvider、configure_azure_monitor),opentelemetry-instrument 会处理;不要在同一应用同时运行经典 elastic-apm 与 EDOT。完整示例见 EDOT Python 安装指南。