用途:为 Python 应用接入 Elastic Distribution of OpenTelemetry(EDOT)Python 代理,实现自动的链路追踪、指标与日志采集。
主要能力与用法:
- 通过 pip 安装 elastic-opentelemetry,并加入 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 URL,切勿使用 APM Server URL,即不要出现 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 设置指南。