Skip to content

Commit

Permalink
]Instrumentation.Owin] Nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
Kielek committed Mar 5, 2024
1 parent b3cb1af commit a2689a2
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ 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<System.Diagnostics.Activity, OpenTelemetry.Instrumentation.Owin.OwinEnrichEventType, Microsoft.Owin.IOwinContext, System.Exception>
OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.Enrich.get -> System.Action<System.Diagnostics.Activity!, OpenTelemetry.Instrumentation.Owin.OwinEnrichEventType, Microsoft.Owin.IOwinContext!, System.Exception?>?
OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.Enrich.set -> void
OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.Filter.get -> System.Func<Microsoft.Owin.IOwinContext, bool>
OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.Filter.get -> System.Func<Microsoft.Owin.IOwinContext!, bool>?
OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.Filter.set -> void
OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.OwinInstrumentationOptions() -> void
OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.RecordException.get -> bool
OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.RecordException.set -> void
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<OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions> configure) -> OpenTelemetry.Trace.TracerProviderBuilder
static Owin.AppBuilderExtensions.UseOpenTelemetry(this Owin.IAppBuilder appBuilder) -> Owin.IAppBuilder
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<OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions!>? configure) -> OpenTelemetry.Trace.TracerProviderBuilder!
static Owin.AppBuilderExtensions.UseOpenTelemetry(this Owin.IAppBuilder! appBuilder) -> Owin.IAppBuilder!
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -165,7 +165,7 @@ private static void RequestEnd(IOwinContext owinContext, Exception exception, lo
{
activity.SetStatus(Status.Error);

if (OwinInstrumentationActivitySource.Options.RecordException)
if (OwinInstrumentationActivitySource.Options!.RecordException)
{
activity.RecordException(exception);
}
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<Description>OpenTelemetry instrumentation for OWIN</Description>
<PackageTags>$(PackageTags);distributed-tracing;OWIN</PackageTags>
<MinVerTagPrefix>Instrumentation.Owin-</MinVerTagPrefix>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </summary>
public Func<IOwinContext, bool> Filter { get; set; }
public Func<IOwinContext, bool>? Filter { get; set; }

/// <summary>
/// Gets or sets an action to enrich the <see cref="Activity"/> created by the instrumentation.
/// </summary>
public Action<Activity, OwinEnrichEventType, IOwinContext, Exception> Enrich { get; set; }
public Action<Activity, OwinEnrichEventType, IOwinContext, Exception?>? Enrich { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the exception will be recorded as <see cref="ActivityEvent"/> or not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static TracerProviderBuilder AddOwinInstrumentation(this TracerProviderBu
/// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
public static TracerProviderBuilder AddOwinInstrumentation(
this TracerProviderBuilder builder,
Action<OwinInstrumentationOptions> configure)
Action<OwinInstrumentationOptions>? configure)
{
Guard.ThrowIfNull(builder);

Expand Down

0 comments on commit a2689a2

Please sign in to comment.