From fe8916469c1695c383c4dc989728ab87561d899e Mon Sep 17 00:00:00 2001 From: YuChia Date: Mon, 27 Nov 2023 22:19:34 +0800 Subject: [PATCH] update plugin memo --- .../OptionsPlugin.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/OpenTelemetry.AutoInstrumentation.AspNetCore.Plugins/OptionsPlugin.cs b/src/OpenTelemetry.AutoInstrumentation.AspNetCore.Plugins/OptionsPlugin.cs index c8722f1..243f544 100644 --- a/src/OpenTelemetry.AutoInstrumentation.AspNetCore.Plugins/OptionsPlugin.cs +++ b/src/OpenTelemetry.AutoInstrumentation.AspNetCore.Plugins/OptionsPlugin.cs @@ -2,12 +2,24 @@ using OpenTelemetry.Instrumentation.AspNetCore; using OpenTelemetry.Instrumentation.Http; using OpenTelemetry.Instrumentation.SqlClient; +using OpenTelemetry.Metrics; using OpenTelemetry.Resources; namespace OpenTelemetry.AutoInstrumentation.AspNetCore.Plugins; public class OptionsPlugin { + // To configure metrics SDK after Auto Instrumentation configured SDK + public MeterProviderBuilder AfterConfigureMeterProvider(MeterProviderBuilder builder) + { + //dotnet 8 metrics + // 在 open telemetry auto instrumentation 1.2.0 中,不用手動注入,已經被包含在以下位置 + // https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/blob/v1.2.0/src/OpenTelemetry.AutoInstrumentation/Configurations/EnvironmentConfigurationMetricHelper.cs#L97C56-L97C56 + // builder.AddMeter("Microsoft.AspNetCore.Hosting", + // "Microsoft.AspNetCore.Server.Kestrel"); + return builder; + } + /// /// 自訂資料標籤,補上一些可能需要的資料 /// @@ -50,7 +62,6 @@ public void ConfigureTracesOptions(AspNetCoreInstrumentationOptions options) //如果在服務中有使用 UseExceptionHandling() 或是在 ActionFilter 的時候把 Exception 處理過的話,可能會導致 otel 無法正確輸出例外資料 //所以這邊另外檢查回應內容並另外打包給 AspNetCoreInstrumentation 工具 - //TODO: 需要多測試效果 options.EnrichWithHttpResponse = ActivitySourceExtenstion.EnrichHttpResponse(); }