observability-edot-dotnet-migrate

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

EDOT .NET Migration

EDOT .NET迁移

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

Guidelines

指南

  1. Remove ALL classic APM references:
    Elastic.Apm.*
    NuGet packages (including
    Elastic.Apm.NetCoreAll
    ),
    UseAllElasticApm()
    /
    AddAllElasticApm()
    calls, the
    ElasticApm
    section from
    appsettings.json
    , and all
    ELASTIC_APM_*
    env vars
  2. Add NuGet packages:
    Elastic.OpenTelemetry
    and
    OpenTelemetry.Instrumentation.AspNetCore
    (for ASP.NET Core apps)
  3. Register EDOT in startup: call
    builder.AddElasticOpenTelemetry()
    on the
    IHostApplicationBuilder
    (in
    Program.cs
    or equivalent). Without this, no telemetry is collected
  4. Set exactly three required environment variables:
    • OTEL_SERVICE_NAME
      (replaces
      ELASTIC_APM_SERVICE_NAME
      /
      ElasticApm:ServiceName
      )
    • OTEL_EXPORTER_OTLP_ENDPOINT
      — must be the managed OTLP endpoint or EDOT Collector URL. Do NOT reuse the old
      ELASTIC_APM_SERVER_URLS
      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
      )
  5. Do NOT set
    OTEL_TRACES_EXPORTER
    ,
    OTEL_METRICS_EXPORTER
    , or
    OTEL_LOGS_EXPORTER
    — the defaults are already correct
  6. Never run both classic Elastic APM agent (
    Elastic.Apm.*
    ) and EDOT on the same application
  1. 移除所有经典APM引用:
    Elastic.Apm.*
    NuGet包(包括
    Elastic.Apm.NetCoreAll
    )、
    UseAllElasticApm()
    /
    AddAllElasticApm()
    调用、
    appsettings.json
    中的
    ElasticApm
    配置段,以及所有
    ELASTIC_APM_*
    环境变量
  2. 添加NuGet包:
    Elastic.OpenTelemetry
    OpenTelemetry.Instrumentation.AspNetCore
    (适用于ASP.NET Core应用)
  3. 在启动时注册EDOT:在
    IHostApplicationBuilder
    上调用
    builder.AddElasticOpenTelemetry()
    (位于
    Program.cs
    或等效文件中)。如果不执行此操作,将不会收集任何遥测数据
  4. 准确设置三个必填环境变量:
    • OTEL_SERVICE_NAME
      (替代
      ELASTIC_APM_SERVICE_NAME
      /
      ElasticApm:ServiceName
    • OTEL_EXPORTER_OTLP_ENDPOINT
      — 必须是托管OTLP端点EDOT Collector的URL。请勿复用旧的
      ELASTIC_APM_SERVER_URLS
      值。切勿使用APM Server URL(不包含
      apm-server
      :8200
      /intake/v2/events
    • OTEL_EXPORTER_OTLP_HEADERS
      "Authorization=ApiKey <key>"
      "Authorization=Bearer <token>"
      (替代
      ELASTIC_APM_SECRET_TOKEN
  5. 请勿设置
    OTEL_TRACES_EXPORTER
    OTEL_METRICS_EXPORTER
    OTEL_LOGS_EXPORTER
    — 默认值已正确配置
  6. 切勿在同一应用中同时运行经典Elastic APM代理(
    Elastic.Apm.*
    )和EDOT

Examples

示例

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