observability-edot-python-instrument

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

EDOT Python Instrumentation

EDOT Python 插桩

Guidelines

指南

  1. Install
    elastic-opentelemetry
    via pip (add to
    requirements.txt
    or equivalent)
  2. Run
    edot-bootstrap --action=install
    during image build to install auto-instrumentation packages for detected libraries
  3. Wrap the application entrypoint with
    opentelemetry-instrument
    — e.g.
    opentelemetry-instrument gunicorn app:app
    or
    opentelemetry-instrument python app.py
    . Without this, no telemetry is collected
  4. Set exactly three required environment variables:
    • OTEL_SERVICE_NAME
    • OTEL_EXPORTER_OTLP_ENDPOINT
      — must be the managed OTLP endpoint or EDOT Collector URL. Never use an APM Server URL (no
      apm-server
      , no
      :8200
      , no
      /intake/v2/events
      )
    • OTEL_EXPORTER_OTLP_HEADERS
      "Authorization=ApiKey <key>"
      or
      "Authorization=Bearer <token>"
  5. Do NOT set
    OTEL_TRACES_EXPORTER
    ,
    OTEL_METRICS_EXPORTER
    , or
    OTEL_LOGS_EXPORTER
    — the defaults are already correct
  6. Do NOT add code-level SDK setup (no
    TracerProvider
    , no
    configure_azure_monitor
    , etc.) —
    opentelemetry-instrument
    handles everything
  7. Never run both classic
    elastic-apm
    and EDOT on the same application
  1. 通过pip安装
    elastic-opentelemetry
    (添加至
    requirements.txt
    或等效依赖文件中)
  2. 在镜像构建期间运行
    edot-bootstrap --action=install
    ,为检测到的库安装自动插桩包
  3. 使用
    opentelemetry-instrument
    包裹应用程序入口点——例如
    opentelemetry-instrument gunicorn app:app
    opentelemetry-instrument python app.py
    。如果不执行此步骤,将不会收集任何遥测数据
  4. 准确设置三个必填环境变量:
    • 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>"
  5. 请勿设置
    OTEL_TRACES_EXPORTER
    OTEL_METRICS_EXPORTER
    OTEL_LOGS_EXPORTER
    ——默认配置已为正确设置
  6. 请勿添加代码层面的SDK设置(无需
    TracerProvider
    configure_azure_monitor
    等)——
    opentelemetry-instrument
    会处理所有相关操作
  7. 切勿在同一应用程序中同时运行传统
    elastic-apm
    与EDOT

Examples

示例

See the EDOT Python setup guide for complete examples.
请查看EDOT Python setup guide获取完整示例。