From ea143577631c82bb719ffb9ce36e0568df426db6 Mon Sep 17 00:00:00 2001 From: nayang7 <107023695+nayang7@users.noreply.github.com> Date: Sun, 24 Jul 2022 19:54:20 +0800 Subject: [PATCH 1/7] fix issue#3276 (#1) fix Remote IP Address - NULL reference exception --- .../Implementation/HttpInListener.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs index 1ff80acc8b2..5898678608d 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs @@ -360,7 +360,10 @@ 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); From d30ebe75da333f53b9482b1e75902f0ab2feb2d2 Mon Sep 17 00:00:00 2001 From: nayang7 <107023695+nayang7@users.noreply.github.com> Date: Tue, 26 Jul 2022 09:51:43 +0800 Subject: [PATCH 2/7] Update CHANGELOG.md --- src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md index d2d2fcbd283..2638972b4b1 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +* Fix Remote IP Address - NULL reference exception. + (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)) From 7006ec597c694438e969f4220f468dccdac1016d Mon Sep 17 00:00:00 2001 From: nayang7 <107023695+nayang7@users.noreply.github.com> Date: Tue, 26 Jul 2022 10:47:25 +0800 Subject: [PATCH 3/7] Update src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md Co-authored-by: Reiley Yang --- src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md index 2897dfefb38..f53d3c479cd 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md @@ -3,7 +3,7 @@ ## Unreleased * Fix Remote IP Address - NULL reference exception. - (https://github.com/open-telemetry/opentelemetry-dotnet/pull/3481) + [#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)) From b69175ad21b99df1bc710cc4b19d223d488a9a8a Mon Sep 17 00:00:00 2001 From: nayang7 <107023695+nayang7@users.noreply.github.com> Date: Tue, 26 Jul 2022 10:49:49 +0800 Subject: [PATCH 4/7] Update CHANGELOG.md --- src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md index f53d3c479cd..26788a049ce 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md @@ -3,7 +3,7 @@ ## Unreleased * Fix Remote IP Address - NULL reference exception. - [#3481](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3481)) + ([#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)) From 82b92b50bd784d12b113f682fb0b416398b4b81e Mon Sep 17 00:00:00 2001 From: nayang7 <107023695+nayang7@users.noreply.github.com> Date: Tue, 26 Jul 2022 13:27:29 +0800 Subject: [PATCH 5/7] Update CHANGELOG.md --- src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md index 26788a049ce..40220274211 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -* Fix Remote IP Address - NULL reference exception. +* 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.) From 949e3e11fce8c57310509868bd244bba867aecab Mon Sep 17 00:00:00 2001 From: nayang7 <107023695+nayang7@users.noreply.github.com> Date: Wed, 27 Jul 2022 15:41:07 +0800 Subject: [PATCH 6/7] Update HttpInListener.cs --- .../Implementation/HttpInListener.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs index 5898678608d..0eed57303a9 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs @@ -364,6 +364,7 @@ private static void AddGrpcAttributes(Activity activity, string grpcMethod, Http { activity.SetTag(SemanticConventions.AttributeNetPeerIp, context.Connection.RemoteIpAddress.ToString()); } + activity.SetTag(SemanticConventions.AttributeNetPeerPort, context.Connection.RemotePort); bool validConversion = GrpcTagHelper.TryGetGrpcStatusCodeFromActivity(activity, out int status); From ab0c822d7997bcbe9d07e51a97d14bb2a21d8f09 Mon Sep 17 00:00:00 2001 From: nayang7 <107023695+nayang7@users.noreply.github.com> Date: Thu, 28 Jul 2022 13:14:43 +0800 Subject: [PATCH 7/7] Update HttpInListener.cs --- .../Implementation/HttpInListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs index 0eed57303a9..a37863ad8b9 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs @@ -364,7 +364,7 @@ private static void AddGrpcAttributes(Activity activity, string grpcMethod, Http { activity.SetTag(SemanticConventions.AttributeNetPeerIp, context.Connection.RemoteIpAddress.ToString()); } - + activity.SetTag(SemanticConventions.AttributeNetPeerPort, context.Connection.RemotePort); bool validConversion = GrpcTagHelper.TryGetGrpcStatusCodeFromActivity(activity, out int status);