Skip to content

Commit

Permalink
Revert changes for metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Kielek committed Mar 8, 2024
1 parent b4b2905 commit 446a701
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

## Unreleased

* Fixed an issue when `server.port` attribute was not set with `server.address`
when it has default values (`80` for `HTTP` and `443` for `HTTPS` protocol).
* Fixed an issue for spans when `server.port` attribute was not set with
`server.address` when it has default values (`80` for `HTTP` and
`443` for `HTTPS` protocol).
([#5419](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5419))

## 1.7.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ public static void OnStopEventWritten(Activity activity, object payload)
tags.Add(new KeyValuePair<string, object>(SemanticConventions.AttributeHttpRequestMethod, httpMethod));

tags.Add(new KeyValuePair<string, object>(SemanticConventions.AttributeServerAddress, request.RequestUri.Host));
tags.Add(new KeyValuePair<string, object>(SemanticConventions.AttributeServerPort, request.RequestUri.Port));

tags.Add(new KeyValuePair<string, object>(SemanticConventions.AttributeUrlScheme, request.RequestUri.Scheme));

if (!request.RequestUri.IsDefaultPort)
{
tags.Add(new KeyValuePair<string, object>(SemanticConventions.AttributeServerPort, request.RequestUri.Port));
}

if (TryFetchResponse(payload, out HttpResponseMessage response))
{
tags.Add(new KeyValuePair<string, object>(SemanticConventions.AttributeNetworkProtocolVersion, HttpTagHelper.GetProtocolVersionString(response.Version)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,14 +426,17 @@ private static void ProcessResult(IAsyncResult asyncResult, AsyncCallback asyncC
tags.Add(new KeyValuePair<string, object>(SemanticConventions.AttributeHttpRequestMethod, httpMethod));

tags.Add(SemanticConventions.AttributeServerAddress, request.RequestUri.Host);
tags.Add(SemanticConventions.AttributeServerPort, request.RequestUri.Port);

tags.Add(SemanticConventions.AttributeUrlScheme, request.RequestUri.Scheme);
if (protocolVersion != null)
{
tags.Add(SemanticConventions.AttributeNetworkProtocolVersion, HttpTagHelper.GetProtocolVersionString(protocolVersion));
}

if (!request.RequestUri.IsDefaultPort)
{
tags.Add(SemanticConventions.AttributeServerPort, request.RequestUri.Port);
}

if (httpStatusCode.HasValue)
{
tags.Add(SemanticConventions.AttributeHttpResponseStatusCode, (int)httpStatusCode.Value);
Expand Down

0 comments on commit 446a701

Please sign in to comment.