Skip to content

Commit c48c014

Browse files
Rename AspNetCoreInstrumentationOptions (#5108)
1 parent 94c20c6 commit c48c014

File tree

9 files changed

+46
-40
lines changed

9 files changed

+46
-40
lines changed

examples/AspNetCore/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
.AddAspNetCoreInstrumentation();
6464

6565
// Use IConfiguration binding for AspNetCore instrumentation options.
66-
appBuilder.Services.Configure<AspNetCoreInstrumentationOptions>(appBuilder.Configuration.GetSection("AspNetCoreInstrumentation"));
66+
appBuilder.Services.Configure<AspNetCoreTraceInstrumentationOptions>(appBuilder.Configuration.GetSection("AspNetCoreInstrumentation"));
6767

6868
switch (tracingExporter)
6969
{
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions
2-
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.AspNetCoreInstrumentationOptions() -> void
3-
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnrichWithException.get -> System.Action<System.Diagnostics.Activity, System.Exception>
4-
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnrichWithException.set -> void
5-
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnrichWithHttpRequest.get -> System.Action<System.Diagnostics.Activity, Microsoft.AspNetCore.Http.HttpRequest>
6-
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnrichWithHttpRequest.set -> void
7-
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnrichWithHttpResponse.get -> System.Action<System.Diagnostics.Activity, Microsoft.AspNetCore.Http.HttpResponse>
8-
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnrichWithHttpResponse.set -> void
9-
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.Filter.get -> System.Func<Microsoft.AspNetCore.Http.HttpContext, bool>
10-
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.Filter.set -> void
11-
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.RecordException.get -> bool
12-
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.RecordException.set -> void
1+
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions
2+
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.AspNetCoreTraceInstrumentationOptions() -> void
3+
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.EnrichWithException.get -> System.Action<System.Diagnostics.Activity, System.Exception>
4+
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.EnrichWithException.set -> void
5+
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.EnrichWithHttpRequest.get -> System.Action<System.Diagnostics.Activity, Microsoft.AspNetCore.Http.HttpRequest>
6+
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.EnrichWithHttpRequest.set -> void
7+
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.EnrichWithHttpResponse.get -> System.Action<System.Diagnostics.Activity, Microsoft.AspNetCore.Http.HttpResponse>
8+
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.EnrichWithHttpResponse.set -> void
9+
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.Filter.get -> System.Func<Microsoft.AspNetCore.Http.HttpContext, bool>
10+
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.Filter.set -> void
11+
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.RecordException.get -> bool
12+
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions.RecordException.set -> void
1313
OpenTelemetry.Metrics.MeterProviderBuilderExtensions
1414
OpenTelemetry.Trace.TracerProviderBuilderExtensions
1515
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder
1616
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder
17-
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, string name, System.Action<OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions> configureAspNetCoreInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder
18-
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action<OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions> configureAspNetCoreInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder
17+
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, string name, System.Action<OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions> configureAspNetCoreTraceInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder
18+
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action<OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreTraceInstrumentationOptions> configureAspNetCoreTraceInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder

src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreInstrumentationOptions.cs renamed to src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreTraceInstrumentationOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// <copyright file="AspNetCoreInstrumentationOptions.cs" company="OpenTelemetry Authors">
1+
// <copyright file="AspNetCoreTraceInstrumentationOptions.cs" company="OpenTelemetry Authors">
22
// Copyright The OpenTelemetry Authors
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,7 +22,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore;
2222
/// <summary>
2323
/// Options for requests instrumentation.
2424
/// </summary>
25-
public class AspNetCoreInstrumentationOptions
25+
public class AspNetCoreTraceInstrumentationOptions
2626
{
2727
/// <summary>
2828
/// Gets or sets a filter function that determines whether or not to

src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
[#5098](https://github.com/open-telemetry/opentelemetry-dotnet/issues/5098)
1717
([#5097](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5097))
1818

19+
* **Breaking Change** : Renamed `AspNetCoreInstrumentationOptions` to
20+
`AspNetCoreTraceInstrumentationOptions`.
21+
([#5108](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5108))
22+
1923
## 1.6.0-beta.3
2024

2125
Released 2023-Nov-17

src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ internal class HttpInListener : ListenerHandler
6464
private readonly PropertyFetcher<object> beforeActionAttributeRouteInfoFetcher = new("AttributeRouteInfo");
6565
private readonly PropertyFetcher<string> beforeActionTemplateFetcher = new("Template");
6666
#endif
67-
private readonly AspNetCoreInstrumentationOptions options;
67+
private readonly AspNetCoreTraceInstrumentationOptions options;
6868

69-
public HttpInListener(AspNetCoreInstrumentationOptions options)
69+
public HttpInListener(AspNetCoreTraceInstrumentationOptions options)
7070
: base(DiagnosticSourceName)
7171
{
7272
Guard.ThrowIfNull(options);

src/OpenTelemetry.Instrumentation.AspNetCore/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,19 @@ newer versions.
139139
## Advanced configuration
140140

141141
This instrumentation can be configured to change the default behavior by using
142-
`AspNetCoreInstrumentationOptions`, which allows adding [`Filter`](#filter),
142+
`AspNetCoreTraceInstrumentationOptions`, which allows adding [`Filter`](#filter),
143143
[`Enrich`](#enrich) as explained below.
144144

145145
// TODO: This section could be refined.
146-
When used with [`OpenTelemetry.Extensions.Hosting`](../OpenTelemetry.Extensions.Hosting/README.md),
147-
all configurations to `AspNetCoreInstrumentationOptions` can be done in the `ConfigureServices`
146+
When used with
147+
[`OpenTelemetry.Extensions.Hosting`](../OpenTelemetry.Extensions.Hosting/README.md),
148+
all configurations to `AspNetCoreTraceInstrumentationOptions` can be done in the
149+
`ConfigureServices`
148150
method of you applications `Startup` class as shown below.
149151

150152
```csharp
151153
// Configure
152-
services.Configure<AspNetCoreInstrumentationOptions>(options =>
154+
services.Configure<AspNetCoreTraceInstrumentationOptions>(options =>
153155
{
154156
options.Filter = (httpContext) =>
155157
{
@@ -168,7 +170,7 @@ services.AddOpenTelemetry()
168170

169171
This instrumentation by default collects all the incoming http requests. It
170172
allows filtering of requests by using the `Filter` function in
171-
`AspNetCoreInstrumentationOptions`. This defines the condition for allowable
173+
`AspNetCoreTraceInstrumentationOptions`. This defines the condition for allowable
172174
requests. The Filter receives the `HttpContext` of the incoming
173175
request, and does not collect telemetry about the request if the Filter
174176
returns false or throws exception.

src/OpenTelemetry.Instrumentation.AspNetCore/TracerProviderBuilderExtensions.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,30 @@ public static class TracerProviderBuilderExtensions
3636
/// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
3737
/// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
3838
public static TracerProviderBuilder AddAspNetCoreInstrumentation(this TracerProviderBuilder builder)
39-
=> AddAspNetCoreInstrumentation(builder, name: null, configureAspNetCoreInstrumentationOptions: null);
39+
=> AddAspNetCoreInstrumentation(builder, name: null, configureAspNetCoreTraceInstrumentationOptions: null);
4040

4141
/// <summary>
4242
/// Enables the incoming requests automatic data collection for ASP.NET Core.
4343
/// </summary>
4444
/// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
45-
/// <param name="configureAspNetCoreInstrumentationOptions">Callback action for configuring <see cref="AspNetCoreInstrumentationOptions"/>.</param>
45+
/// <param name="configureAspNetCoreTraceInstrumentationOptions">Callback action for configuring <see cref="AspNetCoreTraceInstrumentationOptions"/>.</param>
4646
/// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
4747
public static TracerProviderBuilder AddAspNetCoreInstrumentation(
4848
this TracerProviderBuilder builder,
49-
Action<AspNetCoreInstrumentationOptions> configureAspNetCoreInstrumentationOptions)
50-
=> AddAspNetCoreInstrumentation(builder, name: null, configureAspNetCoreInstrumentationOptions);
49+
Action<AspNetCoreTraceInstrumentationOptions> configureAspNetCoreTraceInstrumentationOptions)
50+
=> AddAspNetCoreInstrumentation(builder, name: null, configureAspNetCoreTraceInstrumentationOptions);
5151

5252
/// <summary>
5353
/// Enables the incoming requests automatic data collection for ASP.NET Core.
5454
/// </summary>
5555
/// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
5656
/// <param name="name">Name which is used when retrieving options.</param>
57-
/// <param name="configureAspNetCoreInstrumentationOptions">Callback action for configuring <see cref="AspNetCoreInstrumentationOptions"/>.</param>
57+
/// <param name="configureAspNetCoreTraceInstrumentationOptions">Callback action for configuring <see cref="AspNetCoreTraceInstrumentationOptions"/>.</param>
5858
/// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
5959
public static TracerProviderBuilder AddAspNetCoreInstrumentation(
6060
this TracerProviderBuilder builder,
6161
string name,
62-
Action<AspNetCoreInstrumentationOptions> configureAspNetCoreInstrumentationOptions)
62+
Action<AspNetCoreTraceInstrumentationOptions> configureAspNetCoreTraceInstrumentationOptions)
6363
{
6464
Guard.ThrowIfNull(builder);
6565

@@ -71,9 +71,9 @@ public static TracerProviderBuilder AddAspNetCoreInstrumentation(
7171

7272
builder.ConfigureServices(services =>
7373
{
74-
if (configureAspNetCoreInstrumentationOptions != null)
74+
if (configureAspNetCoreTraceInstrumentationOptions != null)
7575
{
76-
services.Configure(name, configureAspNetCoreInstrumentationOptions);
76+
services.Configure(name, configureAspNetCoreTraceInstrumentationOptions);
7777
}
7878
});
7979

@@ -87,7 +87,7 @@ public static TracerProviderBuilder AddAspNetCoreInstrumentation(
8787

8888
return builder.AddInstrumentation(sp =>
8989
{
90-
var options = sp.GetRequiredService<IOptionsMonitor<AspNetCoreInstrumentationOptions>>().Get(name);
90+
var options = sp.GetRequiredService<IOptionsMonitor<AspNetCoreTraceInstrumentationOptions>>().Get(name);
9191

9292
return new AspNetCoreInstrumentation(
9393
new HttpInListener(options));

test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ void ConfigureTestServices(IServiceCollection services)
496496
{
497497
this.tracerProvider = Sdk.CreateTracerProviderBuilder()
498498
.AddAspNetCoreInstrumentation(
499-
new TestHttpInListener(new AspNetCoreInstrumentationOptions())
499+
new TestHttpInListener(new AspNetCoreTraceInstrumentationOptions())
500500
{
501501
OnEventWrittenCallback = (name, payload) =>
502502
{
@@ -836,7 +836,7 @@ public async Task DiagnosticSourceCallbacksAreReceivedOnlyForSubscribedEvents()
836836

837837
this.tracerProvider = Sdk.CreateTracerProviderBuilder()
838838
.AddAspNetCoreInstrumentation(
839-
new TestHttpInListener(new AspNetCoreInstrumentationOptions())
839+
new TestHttpInListener(new AspNetCoreTraceInstrumentationOptions())
840840
{
841841
OnEventWrittenCallback = (name, payload) =>
842842
{
@@ -892,7 +892,7 @@ public async Task DiagnosticSourceExceptionCallbackIsReceivedForUnHandledExcepti
892892

893893
this.tracerProvider = Sdk.CreateTracerProviderBuilder()
894894
.AddAspNetCoreInstrumentation(
895-
new TestHttpInListener(new AspNetCoreInstrumentationOptions())
895+
new TestHttpInListener(new AspNetCoreTraceInstrumentationOptions())
896896
{
897897
OnEventWrittenCallback = (name, payload) =>
898898
{
@@ -968,7 +968,7 @@ public async Task DiagnosticSourceExceptionCallBackIsNotReceivedForExceptionsHan
968968
// configure SDK
969969
this.tracerProvider = Sdk.CreateTracerProviderBuilder()
970970
.AddAspNetCoreInstrumentation(
971-
new TestHttpInListener(new AspNetCoreInstrumentationOptions())
971+
new TestHttpInListener(new AspNetCoreTraceInstrumentationOptions())
972972
{
973973
OnEventWrittenCallback = (name, payload) =>
974974
{
@@ -1134,7 +1134,7 @@ public override SamplingResult ShouldSample(in SamplingParameters samplingParame
11341134
}
11351135
}
11361136

1137-
private class TestHttpInListener(AspNetCoreInstrumentationOptions options) : HttpInListener(options)
1137+
private class TestHttpInListener(AspNetCoreTraceInstrumentationOptions options) : HttpInListener(options)
11381138
{
11391139
public Action<string, object> OnEventWrittenCallback;
11401140

test/OpenTelemetry.Instrumentation.AspNetCore.Tests/DependencyInjectionConfigTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ void ConfigureTestServices(IServiceCollection services)
4646
{
4747
services.AddOpenTelemetry()
4848
.WithTracing(builder => builder
49-
.AddAspNetCoreInstrumentation(name, configureAspNetCoreInstrumentationOptions: null));
49+
.AddAspNetCoreInstrumentation(name, configureAspNetCoreTraceInstrumentationOptions: null));
5050

51-
services.Configure<AspNetCoreInstrumentationOptions>(name, options =>
51+
services.Configure<AspNetCoreTraceInstrumentationOptions>(name, options =>
5252
{
5353
optionsPickedFromDI = true;
5454
});

0 commit comments

Comments
 (0)