Rename AspNetCoreInstrumentationOptions (#5108)
This commit is contained in:
parent
94c20c684b
commit
c48c014b50
|
|
@ -63,7 +63,7 @@ appBuilder.Services.AddOpenTelemetry()
|
|||
.AddAspNetCoreInstrumentation();
|
||||
|
||||
// Use IConfiguration binding for AspNetCore instrumentation options.
|
||||
appBuilder.Services.Configure<AspNetCoreInstrumentationOptions>(appBuilder.Configuration.GetSection("AspNetCoreInstrumentation"));
|
||||
appBuilder.Services.Configure<AspNetCoreTraceInstrumentationOptions>(appBuilder.Configuration.GetSection("AspNetCoreInstrumentation"));
|
||||
|
||||
switch (tracingExporter)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.AspNetCoreInstrumentationOptions() -> void
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnrichWithException.get -> System.Action<System.Diagnostics.Activity, System.Exception>
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnrichWithException.set -> void
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnrichWithHttpRequest.get -> System.Action<System.Diagnostics.Activity, Microsoft.AspNetCore.Http.HttpRequest>
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnrichWithHttpRequest.set -> void
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnrichWithHttpResponse.get -> System.Action<System.Diagnostics.Activity, Microsoft.AspNetCore.Http.HttpResponse>
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnrichWithHttpResponse.set -> void
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.Filter.get -> System.Func<Microsoft.AspNetCore.Http.HttpContext, bool>
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.Filter.set -> void
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.RecordException.get -> bool
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.RecordException.set -> void
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.AspNetCoreTraceInstrumentationOptions() -> void
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.EnrichWithException.get -> System.Action<System.Diagnostics.Activity, System.Exception>
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.EnrichWithException.set -> void
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.EnrichWithHttpRequest.get -> System.Action<System.Diagnostics.Activity, Microsoft.AspNetCore.Http.HttpRequest>
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.EnrichWithHttpRequest.set -> void
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.EnrichWithHttpResponse.get -> System.Action<System.Diagnostics.Activity, Microsoft.AspNetCore.Http.HttpResponse>
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.EnrichWithHttpResponse.set -> void
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.Filter.get -> System.Func<Microsoft.AspNetCore.Http.HttpContext, bool>
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.Filter.set -> void
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.RecordException.get -> bool
|
||||
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.RecordException.set -> void
|
||||
OpenTelemetry.Metrics.MeterProviderBuilderExtensions
|
||||
OpenTelemetry.Trace.TracerProviderBuilderExtensions
|
||||
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder
|
||||
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder
|
||||
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, string name, System.Action<OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions> configureAspNetCoreInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder
|
||||
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action<OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions> configureAspNetCoreInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder
|
||||
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, string name, System.Action<OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions> configureAspNetCoreTraceInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder
|
||||
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action<OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions> configureAspNetCoreTraceInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// <copyright file="AspNetCoreInstrumentationOptions.cs" company="OpenTelemetry Authors">
|
||||
// <copyright file="AspNetCoreTraceInstrumentationOptions.cs" company="OpenTelemetry Authors">
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
|
@ -22,7 +22,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore;
|
|||
/// <summary>
|
||||
/// Options for requests instrumentation.
|
||||
/// </summary>
|
||||
public class AspNetCoreInstrumentationOptions
|
||||
public class AspNetCoreTraceInstrumentationOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets a filter function that determines whether or not to
|
||||
|
|
@ -16,6 +16,10 @@
|
|||
[#5098](https://github.com/open-telemetry/opentelemetry-dotnet/issues/5098)
|
||||
([#5097](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5097))
|
||||
|
||||
* **Breaking Change** : Renamed `AspNetCoreInstrumentationOptions` to
|
||||
`AspNetCoreTraceInstrumentationOptions`.
|
||||
([#5108](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5108))
|
||||
|
||||
## 1.6.0-beta.3
|
||||
|
||||
Released 2023-Nov-17
|
||||
|
|
|
|||
|
|
@ -64,9 +64,9 @@ internal class HttpInListener : ListenerHandler
|
|||
private readonly PropertyFetcher<object> beforeActionAttributeRouteInfoFetcher = new("AttributeRouteInfo");
|
||||
private readonly PropertyFetcher<string> beforeActionTemplateFetcher = new("Template");
|
||||
#endif
|
||||
private readonly AspNetCoreInstrumentationOptions options;
|
||||
private readonly AspNetCoreTraceInstrumentationOptions options;
|
||||
|
||||
public HttpInListener(AspNetCoreInstrumentationOptions options)
|
||||
public HttpInListener(AspNetCoreTraceInstrumentationOptions options)
|
||||
: base(DiagnosticSourceName)
|
||||
{
|
||||
Guard.ThrowIfNull(options);
|
||||
|
|
|
|||
|
|
@ -139,17 +139,19 @@ newer versions.
|
|||
## Advanced configuration
|
||||
|
||||
This instrumentation can be configured to change the default behavior by using
|
||||
`AspNetCoreInstrumentationOptions`, which allows adding [`Filter`](#filter),
|
||||
`AspNetCoreTraceInstrumentationOptions`, which allows adding [`Filter`](#filter),
|
||||
[`Enrich`](#enrich) as explained below.
|
||||
|
||||
// TODO: This section could be refined.
|
||||
When used with [`OpenTelemetry.Extensions.Hosting`](../OpenTelemetry.Extensions.Hosting/README.md),
|
||||
all configurations to `AspNetCoreInstrumentationOptions` can be done in the `ConfigureServices`
|
||||
When used with
|
||||
[`OpenTelemetry.Extensions.Hosting`](../OpenTelemetry.Extensions.Hosting/README.md),
|
||||
all configurations to `AspNetCoreTraceInstrumentationOptions` can be done in the
|
||||
`ConfigureServices`
|
||||
method of you applications `Startup` class as shown below.
|
||||
|
||||
```csharp
|
||||
// Configure
|
||||
services.Configure<AspNetCoreInstrumentationOptions>(options =>
|
||||
services.Configure<AspNetCoreTraceInstrumentationOptions>(options =>
|
||||
{
|
||||
options.Filter = (httpContext) =>
|
||||
{
|
||||
|
|
@ -168,7 +170,7 @@ services.AddOpenTelemetry()
|
|||
|
||||
This instrumentation by default collects all the incoming http requests. It
|
||||
allows filtering of requests by using the `Filter` function in
|
||||
`AspNetCoreInstrumentationOptions`. This defines the condition for allowable
|
||||
`AspNetCoreTraceInstrumentationOptions`. This defines the condition for allowable
|
||||
requests. The Filter receives the `HttpContext` of the incoming
|
||||
request, and does not collect telemetry about the request if the Filter
|
||||
returns false or throws exception.
|
||||
|
|
|
|||
|
|
@ -36,30 +36,30 @@ public static class TracerProviderBuilderExtensions
|
|||
/// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
|
||||
/// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
|
||||
public static TracerProviderBuilder AddAspNetCoreInstrumentation(this TracerProviderBuilder builder)
|
||||
=> AddAspNetCoreInstrumentation(builder, name: null, configureAspNetCoreInstrumentationOptions: null);
|
||||
=> AddAspNetCoreInstrumentation(builder, name: null, configureAspNetCoreTraceInstrumentationOptions: null);
|
||||
|
||||
/// <summary>
|
||||
/// Enables the incoming requests automatic data collection for ASP.NET Core.
|
||||
/// </summary>
|
||||
/// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
|
||||
/// <param name="configureAspNetCoreInstrumentationOptions">Callback action for configuring <see cref="AspNetCoreInstrumentationOptions"/>.</param>
|
||||
/// <param name="configureAspNetCoreTraceInstrumentationOptions">Callback action for configuring <see cref="AspNetCoreTraceInstrumentationOptions"/>.</param>
|
||||
/// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
|
||||
public static TracerProviderBuilder AddAspNetCoreInstrumentation(
|
||||
this TracerProviderBuilder builder,
|
||||
Action<AspNetCoreInstrumentationOptions> configureAspNetCoreInstrumentationOptions)
|
||||
=> AddAspNetCoreInstrumentation(builder, name: null, configureAspNetCoreInstrumentationOptions);
|
||||
Action<AspNetCoreTraceInstrumentationOptions> configureAspNetCoreTraceInstrumentationOptions)
|
||||
=> AddAspNetCoreInstrumentation(builder, name: null, configureAspNetCoreTraceInstrumentationOptions);
|
||||
|
||||
/// <summary>
|
||||
/// Enables the incoming requests automatic data collection for ASP.NET Core.
|
||||
/// </summary>
|
||||
/// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
|
||||
/// <param name="name">Name which is used when retrieving options.</param>
|
||||
/// <param name="configureAspNetCoreInstrumentationOptions">Callback action for configuring <see cref="AspNetCoreInstrumentationOptions"/>.</param>
|
||||
/// <param name="configureAspNetCoreTraceInstrumentationOptions">Callback action for configuring <see cref="AspNetCoreTraceInstrumentationOptions"/>.</param>
|
||||
/// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
|
||||
public static TracerProviderBuilder AddAspNetCoreInstrumentation(
|
||||
this TracerProviderBuilder builder,
|
||||
string name,
|
||||
Action<AspNetCoreInstrumentationOptions> configureAspNetCoreInstrumentationOptions)
|
||||
Action<AspNetCoreTraceInstrumentationOptions> configureAspNetCoreTraceInstrumentationOptions)
|
||||
{
|
||||
Guard.ThrowIfNull(builder);
|
||||
|
||||
|
|
@ -71,9 +71,9 @@ public static class TracerProviderBuilderExtensions
|
|||
|
||||
builder.ConfigureServices(services =>
|
||||
{
|
||||
if (configureAspNetCoreInstrumentationOptions != null)
|
||||
if (configureAspNetCoreTraceInstrumentationOptions != null)
|
||||
{
|
||||
services.Configure(name, configureAspNetCoreInstrumentationOptions);
|
||||
services.Configure(name, configureAspNetCoreTraceInstrumentationOptions);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ public static class TracerProviderBuilderExtensions
|
|||
|
||||
return builder.AddInstrumentation(sp =>
|
||||
{
|
||||
var options = sp.GetRequiredService<IOptionsMonitor<AspNetCoreInstrumentationOptions>>().Get(name);
|
||||
var options = sp.GetRequiredService<IOptionsMonitor<AspNetCoreTraceInstrumentationOptions>>().Get(name);
|
||||
|
||||
return new AspNetCoreInstrumentation(
|
||||
new HttpInListener(options));
|
||||
|
|
|
|||
|
|
@ -496,7 +496,7 @@ public sealed class BasicTests
|
|||
{
|
||||
this.tracerProvider = Sdk.CreateTracerProviderBuilder()
|
||||
.AddAspNetCoreInstrumentation(
|
||||
new TestHttpInListener(new AspNetCoreInstrumentationOptions())
|
||||
new TestHttpInListener(new AspNetCoreTraceInstrumentationOptions())
|
||||
{
|
||||
OnEventWrittenCallback = (name, payload) =>
|
||||
{
|
||||
|
|
@ -836,7 +836,7 @@ public sealed class BasicTests
|
|||
|
||||
this.tracerProvider = Sdk.CreateTracerProviderBuilder()
|
||||
.AddAspNetCoreInstrumentation(
|
||||
new TestHttpInListener(new AspNetCoreInstrumentationOptions())
|
||||
new TestHttpInListener(new AspNetCoreTraceInstrumentationOptions())
|
||||
{
|
||||
OnEventWrittenCallback = (name, payload) =>
|
||||
{
|
||||
|
|
@ -892,7 +892,7 @@ public sealed class BasicTests
|
|||
|
||||
this.tracerProvider = Sdk.CreateTracerProviderBuilder()
|
||||
.AddAspNetCoreInstrumentation(
|
||||
new TestHttpInListener(new AspNetCoreInstrumentationOptions())
|
||||
new TestHttpInListener(new AspNetCoreTraceInstrumentationOptions())
|
||||
{
|
||||
OnEventWrittenCallback = (name, payload) =>
|
||||
{
|
||||
|
|
@ -968,7 +968,7 @@ public sealed class BasicTests
|
|||
// configure SDK
|
||||
this.tracerProvider = Sdk.CreateTracerProviderBuilder()
|
||||
.AddAspNetCoreInstrumentation(
|
||||
new TestHttpInListener(new AspNetCoreInstrumentationOptions())
|
||||
new TestHttpInListener(new AspNetCoreTraceInstrumentationOptions())
|
||||
{
|
||||
OnEventWrittenCallback = (name, payload) =>
|
||||
{
|
||||
|
|
@ -1134,7 +1134,7 @@ public sealed class BasicTests
|
|||
}
|
||||
}
|
||||
|
||||
private class TestHttpInListener(AspNetCoreInstrumentationOptions options) : HttpInListener(options)
|
||||
private class TestHttpInListener(AspNetCoreTraceInstrumentationOptions options) : HttpInListener(options)
|
||||
{
|
||||
public Action<string, object> OnEventWrittenCallback;
|
||||
|
||||
|
|
|
|||
|
|
@ -46,9 +46,9 @@ public class DependencyInjectionConfigTests
|
|||
{
|
||||
services.AddOpenTelemetry()
|
||||
.WithTracing(builder => builder
|
||||
.AddAspNetCoreInstrumentation(name, configureAspNetCoreInstrumentationOptions: null));
|
||||
.AddAspNetCoreInstrumentation(name, configureAspNetCoreTraceInstrumentationOptions: null));
|
||||
|
||||
services.Configure<AspNetCoreInstrumentationOptions>(name, options =>
|
||||
services.Configure<AspNetCoreTraceInstrumentationOptions>(name, options =>
|
||||
{
|
||||
optionsPickedFromDI = true;
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue