observability-edot-dotnet-migrate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseEDOT .NET Migration
EDOT .NET迁移
Read the migration guide before making changes:
在进行更改前,请阅读迁移指南:
Guidelines
指南
- Remove ALL classic APM references: NuGet packages (including
Elastic.Apm.*),Elastic.Apm.NetCoreAll/UseAllElasticApm()calls, theAddAllElasticApm()section fromElasticApm, and allappsettings.jsonenv varsELASTIC_APM_* - Add NuGet packages: and
Elastic.OpenTelemetry(for ASP.NET Core apps)OpenTelemetry.Instrumentation.AspNetCore - Register EDOT in startup: call on the
builder.AddElasticOpenTelemetry()(inIHostApplicationBuilderor equivalent). Without this, no telemetry is collectedProgram.cs - Set exactly three required environment variables:
- (replaces
OTEL_SERVICE_NAME/ELASTIC_APM_SERVICE_NAME)ElasticApm:ServiceName - — must be the managed OTLP endpoint or EDOT Collector URL. Do NOT reuse the old
OTEL_EXPORTER_OTLP_ENDPOINTvalue. Never use an APM Server URL (noELASTIC_APM_SERVER_URLS, noapm-server, no:8200)/intake/v2/events - —
OTEL_EXPORTER_OTLP_HEADERSor"Authorization=ApiKey <key>"(replaces"Authorization=Bearer <token>")ELASTIC_APM_SECRET_TOKEN
- Do NOT set ,
OTEL_TRACES_EXPORTER, orOTEL_METRICS_EXPORTER— the defaults are already correctOTEL_LOGS_EXPORTER - Never run both classic Elastic APM agent () and EDOT on the same application
Elastic.Apm.*
- 移除所有经典APM引用:NuGet包(包括
Elastic.Apm.*)、Elastic.Apm.NetCoreAll/UseAllElasticApm()调用、AddAllElasticApm()中的appsettings.json配置段,以及所有ElasticApm环境变量ELASTIC_APM_* - 添加NuGet包:和
Elastic.OpenTelemetry(适用于ASP.NET Core应用)OpenTelemetry.Instrumentation.AspNetCore - 在启动时注册EDOT:在上调用
IHostApplicationBuilder(位于builder.AddElasticOpenTelemetry()或等效文件中)。如果不执行此操作,将不会收集任何遥测数据Program.cs - 准确设置三个必填环境变量:
- (替代
OTEL_SERVICE_NAME/ELASTIC_APM_SERVICE_NAME)ElasticApm:ServiceName - — 必须是托管OTLP端点或EDOT Collector的URL。请勿复用旧的
OTEL_EXPORTER_OTLP_ENDPOINT值。切勿使用APM Server URL(不包含ELASTIC_APM_SERVER_URLS、apm-server或:8200)/intake/v2/events - —
OTEL_EXPORTER_OTLP_HEADERS或"Authorization=ApiKey <key>"(替代"Authorization=Bearer <token>")ELASTIC_APM_SECRET_TOKEN
- 请勿设置、
OTEL_TRACES_EXPORTER或OTEL_METRICS_EXPORTER— 默认值已正确配置OTEL_LOGS_EXPORTER - 切勿在同一应用中同时运行经典Elastic APM代理()和EDOT
Elastic.Apm.*
Examples
示例
See the EDOT .NET migration guide for
complete examples.
完整示例请查看EDOT .NET迁移指南。