Skip to content

Commit 508849f

Browse files
committed
check of null
1 parent 5b1dc46 commit 508849f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/OpenTelemetry.Instrumentation.Digma/Diagnostic/HttpEndpointDiagnosticObserver.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ public void OnNext(KeyValuePair<string, object?> pair)
2929
{
3030
if (pair.Key != "Microsoft.AspNetCore.Routing.EndpointMatched")
3131
return;
32-
33-
HttpContext httpContext = (HttpContext) pair.Value;
32+
33+
var httpContext = (HttpContext) pair.Value;
3434
if(httpContext == null)return;
35-
var endpointFeature = httpContext.Features.Get<IEndpointFeature>();
36-
var descriptor = endpointFeature.Endpoint.Metadata.GetMetadata<ControllerActionDescriptor>();
37-
if (descriptor == null)
38-
return;
35+
var endpointFeature = httpContext.Features?.Get<IEndpointFeature>();
36+
var descriptor = endpointFeature?.Endpoint.Metadata.GetMetadata<ControllerActionDescriptor>();
37+
if (descriptor == null) return;
3938
SpanUtils.AddCommonTags(descriptor.ControllerTypeInfo, descriptor.MethodInfo, Activity.Current);
4039
}
4140

0 commit comments

Comments
 (0)