diff --git a/src/OpenTelemetry.Instrumentation.Owin/.publicApi/net462/PublicAPI.Shipped.txt b/src/OpenTelemetry.Instrumentation.Owin/.publicApi/net462/PublicAPI.Shipped.txt index e69de29bb2..7dc5c58110 100644 --- a/src/OpenTelemetry.Instrumentation.Owin/.publicApi/net462/PublicAPI.Shipped.txt +++ b/src/OpenTelemetry.Instrumentation.Owin/.publicApi/net462/PublicAPI.Shipped.txt @@ -0,0 +1 @@ +#nullable enable diff --git a/src/OpenTelemetry.Instrumentation.Owin/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.Owin/.publicApi/net462/PublicAPI.Unshipped.txt index 761ae2d2ff..0d125870ad 100644 --- a/src/OpenTelemetry.Instrumentation.Owin/.publicApi/net462/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Instrumentation.Owin/.publicApi/net462/PublicAPI.Unshipped.txt @@ -2,9 +2,9 @@ OpenTelemetry.Instrumentation.Owin.OwinEnrichEventType OpenTelemetry.Instrumentation.Owin.OwinEnrichEventType.BeginRequest = 0 -> OpenTelemetry.Instrumentation.Owin.OwinEnrichEventType OpenTelemetry.Instrumentation.Owin.OwinEnrichEventType.EndRequest = 1 -> OpenTelemetry.Instrumentation.Owin.OwinEnrichEventType OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions -OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.Enrich.get -> System.Action +OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.Enrich.get -> System.Action? OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.Enrich.set -> void -OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.Filter.get -> System.Func +OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.Filter.get -> System.Func? OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.Filter.set -> void OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.OwinInstrumentationOptions() -> void OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.RecordException.get -> bool @@ -12,7 +12,7 @@ OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.RecordException.se OpenTelemetry.Metrics.OwinInstrumentationMeterProviderBuilderExtensions OpenTelemetry.Trace.TracerProviderBuilderExtensions Owin.AppBuilderExtensions -static OpenTelemetry.Metrics.OwinInstrumentationMeterProviderBuilderExtensions.AddOwinInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddOwinInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder -static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddOwinInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder -static Owin.AppBuilderExtensions.UseOpenTelemetry(this Owin.IAppBuilder appBuilder) -> Owin.IAppBuilder \ No newline at end of file +static OpenTelemetry.Metrics.OwinInstrumentationMeterProviderBuilderExtensions.AddOwinInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder! builder) -> OpenTelemetry.Metrics.MeterProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddOwinInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddOwinInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action? configure) -> OpenTelemetry.Trace.TracerProviderBuilder! +static Owin.AppBuilderExtensions.UseOpenTelemetry(this Owin.IAppBuilder! appBuilder) -> Owin.IAppBuilder! \ No newline at end of file diff --git a/src/OpenTelemetry.Instrumentation.Owin/Implementation/DiagnosticsMiddleware.cs b/src/OpenTelemetry.Instrumentation.Owin/Implementation/DiagnosticsMiddleware.cs index 9c15a7c40c..6b435ef87b 100644 --- a/src/OpenTelemetry.Instrumentation.Owin/Implementation/DiagnosticsMiddleware.cs +++ b/src/OpenTelemetry.Instrumentation.Owin/Implementation/DiagnosticsMiddleware.cs @@ -77,7 +77,7 @@ private static void BeginRequest(IOwinContext owinContext) var textMapPropagator = Propagators.DefaultTextMapPropagator; var ctx = textMapPropagator.Extract(default, owinContext.Request, OwinRequestHeaderValuesGetter); - Activity activity = OwinInstrumentationActivitySource.ActivitySource.StartActivity( + Activity? activity = OwinInstrumentationActivitySource.ActivitySource.StartActivity( OwinInstrumentationActivitySource.IncomingRequestActivityName, ActivityKind.Server, ctx.ActivityContext); @@ -123,7 +123,7 @@ private static void BeginRequest(IOwinContext owinContext) try { - OwinInstrumentationActivitySource.Options.Enrich?.Invoke( + OwinInstrumentationActivitySource.Options?.Enrich?.Invoke( activity, OwinEnrichEventType.BeginRequest, owinContext, @@ -147,7 +147,7 @@ private static void BeginRequest(IOwinContext owinContext) } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static void RequestEnd(IOwinContext owinContext, Exception exception, long startTimestamp) + private static void RequestEnd(IOwinContext owinContext, Exception? exception, long startTimestamp) { if (owinContext.Environment.TryGetValue(ContextKey, out object context) && context is Activity activity) @@ -165,7 +165,7 @@ private static void RequestEnd(IOwinContext owinContext, Exception exception, lo { activity.SetStatus(Status.Error); - if (OwinInstrumentationActivitySource.Options.RecordException) + if (OwinInstrumentationActivitySource.Options != null && OwinInstrumentationActivitySource.Options.RecordException) { activity.RecordException(exception); } @@ -179,7 +179,7 @@ private static void RequestEnd(IOwinContext owinContext, Exception exception, lo try { - OwinInstrumentationActivitySource.Options.Enrich?.Invoke( + OwinInstrumentationActivitySource.Options?.Enrich?.Invoke( activity, OwinEnrichEventType.EndRequest, owinContext, diff --git a/src/OpenTelemetry.Instrumentation.Owin/Implementation/OwinInstrumentationActivitySource.cs b/src/OpenTelemetry.Instrumentation.Owin/Implementation/OwinInstrumentationActivitySource.cs index 7537360628..319d337db7 100644 --- a/src/OpenTelemetry.Instrumentation.Owin/Implementation/OwinInstrumentationActivitySource.cs +++ b/src/OpenTelemetry.Instrumentation.Owin/Implementation/OwinInstrumentationActivitySource.cs @@ -15,7 +15,7 @@ internal static class OwinInstrumentationActivitySource private static readonly Version Version = AssemblyName.Version; - public static ActivitySource ActivitySource { get; } = new ActivitySource(ActivitySourceName, Version.ToString()); + public static ActivitySource ActivitySource { get; } = new(ActivitySourceName, Version.ToString()); - public static OwinInstrumentationOptions Options { get; set; } + public static OwinInstrumentationOptions? Options { get; set; } } diff --git a/src/OpenTelemetry.Instrumentation.Owin/OpenTelemetry.Instrumentation.Owin.csproj b/src/OpenTelemetry.Instrumentation.Owin/OpenTelemetry.Instrumentation.Owin.csproj index 19e66285f7..7e5c9223a6 100644 --- a/src/OpenTelemetry.Instrumentation.Owin/OpenTelemetry.Instrumentation.Owin.csproj +++ b/src/OpenTelemetry.Instrumentation.Owin/OpenTelemetry.Instrumentation.Owin.csproj @@ -4,7 +4,6 @@ OpenTelemetry instrumentation for OWIN $(PackageTags);distributed-tracing;OWIN Instrumentation.Owin- - disable diff --git a/src/OpenTelemetry.Instrumentation.Owin/OwinInstrumentationOptions.cs b/src/OpenTelemetry.Instrumentation.Owin/OwinInstrumentationOptions.cs index 3c1ba76356..57f98e812d 100644 --- a/src/OpenTelemetry.Instrumentation.Owin/OwinInstrumentationOptions.cs +++ b/src/OpenTelemetry.Instrumentation.Owin/OwinInstrumentationOptions.cs @@ -18,12 +18,12 @@ public class OwinInstrumentationOptions /// If Filter returns true, the request is collected. /// If Filter returns false or throw exception, the request is filtered out. /// - public Func Filter { get; set; } + public Func? Filter { get; set; } /// /// Gets or sets an action to enrich the created by the instrumentation. /// - public Action Enrich { get; set; } + public Action? Enrich { get; set; } /// /// Gets or sets a value indicating whether the exception will be recorded as or not. diff --git a/src/OpenTelemetry.Instrumentation.Owin/TracerProviderBuilderExtensions.cs b/src/OpenTelemetry.Instrumentation.Owin/TracerProviderBuilderExtensions.cs index 6fe62ea930..ca55244d23 100644 --- a/src/OpenTelemetry.Instrumentation.Owin/TracerProviderBuilderExtensions.cs +++ b/src/OpenTelemetry.Instrumentation.Owin/TracerProviderBuilderExtensions.cs @@ -28,7 +28,7 @@ public static TracerProviderBuilder AddOwinInstrumentation(this TracerProviderBu /// The instance of to chain the calls. public static TracerProviderBuilder AddOwinInstrumentation( this TracerProviderBuilder builder, - Action configure) + Action? configure) { Guard.ThrowIfNull(builder); diff --git a/test/OpenTelemetry.Instrumentation.Owin.Tests/Controllers/TestController.cs b/test/OpenTelemetry.Instrumentation.Owin.Tests/Controllers/TestController.cs index bf7f20b9ae..d6d9145462 100644 --- a/test/OpenTelemetry.Instrumentation.Owin.Tests/Controllers/TestController.cs +++ b/test/OpenTelemetry.Instrumentation.Owin.Tests/Controllers/TestController.cs @@ -8,7 +8,7 @@ namespace OpenTelemetry.Instrumentation.Owin.Tests.Controllers; public class TestController : ApiController { // GET api/test/{id} - public string Get(string id = null) + public string Get(string? id = null) { return $"id:{id}"; } diff --git a/test/OpenTelemetry.Instrumentation.Owin.Tests/DiagnosticsMiddlewareTests.cs b/test/OpenTelemetry.Instrumentation.Owin.Tests/DiagnosticsMiddlewareTests.cs index fa89a01b00..d2111ab468 100644 --- a/test/OpenTelemetry.Instrumentation.Owin.Tests/DiagnosticsMiddlewareTests.cs +++ b/test/OpenTelemetry.Instrumentation.Owin.Tests/DiagnosticsMiddlewareTests.cs @@ -22,19 +22,18 @@ namespace OpenTelemetry.Instrumentation.Owin.Tests; public class DiagnosticsMiddlewareTests : IDisposable { private readonly Uri serviceBaseUri; - private readonly IDisposable listener; + private readonly IDisposable? listener; private readonly EventWaitHandle requestCompleteHandle = new(false, EventResetMode.AutoReset); public DiagnosticsMiddlewareTests() { Random random = new Random(); var retryCount = 5; - while (retryCount > 0) + do { + this.serviceBaseUri = new Uri($"http://localhost:{random.Next(2000, 5000)}/"); try { - this.serviceBaseUri = new Uri($"http://localhost:{random.Next(2000, 5000)}/"); - this.listener = WebApp.Start( this.serviceBaseUri.ToString(), appBuilder => @@ -81,6 +80,7 @@ public DiagnosticsMiddlewareTests() retryCount--; } } + while (retryCount > 0); if (this.listener == null) { diff --git a/test/OpenTelemetry.Instrumentation.Owin.Tests/OpenTelemetry.Instrumentation.Owin.Tests.csproj b/test/OpenTelemetry.Instrumentation.Owin.Tests/OpenTelemetry.Instrumentation.Owin.Tests.csproj index 1ef3fee142..e61f3950e7 100644 --- a/test/OpenTelemetry.Instrumentation.Owin.Tests/OpenTelemetry.Instrumentation.Owin.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.Owin.Tests/OpenTelemetry.Instrumentation.Owin.Tests.csproj @@ -3,7 +3,6 @@ Unit test project for OpenTelemetry OWIN instrumentation $(NetFrameworkMinimumSupportedVersion) - disable