Skip to content

Commit

Permalink
Fix Remote IP Address - NULL reference exception (#3481)
Browse files Browse the repository at this point in the history
  • Loading branch information
nayang7 authored Jul 29, 2022
1 parent 82e041c commit 0a4a625
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

* Fix Remote IP Address - NULL reference exception.
([#3481](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3481))
* Metrics instrumentation to correctly populate `http.flavor` tag.
(1.1 instead of HTTP/1.1 etc.)
([#3379](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3379))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,11 @@ private static void AddGrpcAttributes(Activity activity, string grpcMethod, Http
activity.DisplayName = grpcMethod.TrimStart('/');

activity.SetTag(SemanticConventions.AttributeRpcSystem, GrpcTagHelper.RpcSystemGrpc);
activity.SetTag(SemanticConventions.AttributeNetPeerIp, context.Connection.RemoteIpAddress.ToString());
if (context.Connection.RemoteIpAddress != null)
{
activity.SetTag(SemanticConventions.AttributeNetPeerIp, context.Connection.RemoteIpAddress.ToString());
}

activity.SetTag(SemanticConventions.AttributeNetPeerPort, context.Connection.RemotePort);

bool validConversion = GrpcTagHelper.TryGetGrpcStatusCodeFromActivity(activity, out int status);
Expand Down

0 comments on commit 0a4a625

Please sign in to comment.