observability-edot-python-migrate

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

EDOT Python Migration

EDOT Python迁移

Read the migration guide before making changes:
在进行更改前,请先阅读迁移指南:

Guidelines

操作准则

  1. Remove ALL classic APM references:
    elastic-apm
    from requirements,
    ElasticAPM(app)
    /
    elasticapm.contrib.*
    from application code,
    app.config['ELASTIC_APM']
    blocks, and all
    ELASTIC_APM_*
    env vars
  2. Install
    elastic-opentelemetry
    via pip (add to
    requirements.txt
    or equivalent)
  3. Run
    edot-bootstrap --action=install
    during image build to install auto-instrumentation packages for detected libraries
  4. Wrap the application entrypoint with
    opentelemetry-instrument
    — e.g.
    opentelemetry-instrument gunicorn app:app
    . Without this, no telemetry is collected
  5. Set exactly three required environment variables:
    • OTEL_SERVICE_NAME
      (replaces
      ELASTIC_APM_SERVICE_NAME
      )
    • OTEL_EXPORTER_OTLP_ENDPOINT
      — must be the managed OTLP endpoint or EDOT Collector URL. Do NOT reuse the old
      ELASTIC_APM_SERVER_URL
      value. 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>"
      (replaces
      ELASTIC_APM_SECRET_TOKEN
      )
  6. Do NOT set
    OTEL_TRACES_EXPORTER
    ,
    OTEL_METRICS_EXPORTER
    , or
    OTEL_LOGS_EXPORTER
    — the defaults are already correct
  7. Never run both classic
    elastic-apm
    and EDOT on the same application
  1. 移除所有经典APM相关引用:从requirements中移除
    elastic-apm
    ,从应用代码中移除
    ElasticAPM(app)
    /
    elasticapm.contrib.*
    ,删除
    app.config['ELASTIC_APM']
    配置块,以及所有
    ELASTIC_APM_*
    环境变量
  2. 通过pip安装
    elastic-opentelemetry
    (添加至
    requirements.txt
    或等效文件中)
  3. 在镜像构建期间运行
    edot-bootstrap --action=install
    ,为检测到的库安装自动插装包
  4. 使用
    opentelemetry-instrument
    包裹应用入口点 —— 例如
    opentelemetry-instrument gunicorn app:app
    。如果不执行此步骤,将不会收集任何遥测数据
  5. 准确设置三个必填环境变量:
    • OTEL_SERVICE_NAME
      (替代
      ELASTIC_APM_SERVICE_NAME
    • OTEL_EXPORTER_OTLP_ENDPOINT
      —— 必须是托管式OTLP端点EDOT Collector的URL。请勿复用旧的
      ELASTIC_APM_SERVER_URL
      值。绝对不要使用APM Server URL(不包含
      apm-server
      :8200
      /intake/v2/events
    • OTEL_EXPORTER_OTLP_HEADERS
      ——
      "Authorization=ApiKey <key>"
      "Authorization=Bearer <token>"
      (替代
      ELASTIC_APM_SECRET_TOKEN
  6. 请勿设置
    OTEL_TRACES_EXPORTER
    OTEL_METRICS_EXPORTER
    OTEL_LOGS_EXPORTER
    —— 默认值已为正确配置
  7. 切勿在同一应用中同时运行经典的
    elastic-apm
    和EDOT

Examples

示例

See the EDOT Python migration guide for complete examples.
完整示例请查看EDOT Python迁移指南