-
Notifications
You must be signed in to change notification settings - Fork 765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update HttpSemanticConventions for Instrumentation.AspNetCore #4537
Conversation
src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs
Outdated
Show resolved
Hide resolved
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main open-telemetry/opentelemetry-dotnet#4537 +/- ##
==========================================
- Coverage 85.13% 85.06% -0.07%
==========================================
Files 312 312
Lines 12532 12564 +32
==========================================
+ Hits 10669 10688 +19
- Misses 1863 1876 +13
|
src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs
Show resolved
Hide resolved
...Instrumentation.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests_New.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall with minor suggestion.
...nstrumentation.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests_Dupe.cs
Show resolved
Hide resolved
|
||
if (this.httpSemanticConvention.HasFlag(HttpSemanticConvention.New)) | ||
{ | ||
activity.SetTag(SemanticConventions.AttributeClientSocketPort, context.Connection.RemotePort); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we clear on what this tag is meant for? And what does this value context.Connection.RemotePort
represent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed the spec and confirmed this was the wrong attribute. will change to server.port
-
v1.20.0
https://github.com/open-telemetry/opentelemetry-specification/blob/v1.20.0/specification/trace/semantic_conventions/http.md#http-client
-
v1.21.0
https://github.com/open-telemetry/opentelemetry-specification/blob/v1.21.0/specification/trace/semantic_conventions/http.md#http-server-semantic-conventions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the value of context.Connection.RemotePort
, the documentation states:
Gets or sets the port of the remote target
https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.connectioninfo.remoteport?view=aspnetcore-7.0
This is not changed, it was mapped to the former attribute.
opentelemetry-dotnet/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs
Lines 491 to 494 in 2a6d88c
if (this.httpSemanticConvention.HasFlag(HttpSemanticConvention.Old)) | |
{ | |
activity.SetTag(SemanticConventions.AttributeNetPeerPort, context.Connection.RemotePort); | |
} |
tags.Add(new KeyValuePair<string, object>(SemanticConventions.AttributeHttpMethod, context.Request.Method)); | ||
tags.Add(new KeyValuePair<string, object>(SemanticConventions.AttributeHttpStatusCode, TelemetryHelper.GetBoxedStatusCode(context.Response.StatusCode))); | ||
// see the spec https://github.com/open-telemetry/opentelemetry-specification/blob/v1.20.0/specification/trace/semantic_conventions/http.md | ||
if (this.httpSemanticConvention.HasFlag(HttpSemanticConvention.Old)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some thoughts...
-
Just reading this work I found "New" and "Old" pretty confusing. Why not
Legacy
vsStable
or something along those lines? -
This is probably an issue for some users:
opentelemetry-dotnet/src/OpenTelemetry.Api/Internal/HttpSemanticConventionHelper.cs
Line 53 in 5d321ce
var envVarValue = Environment.GetEnvironmentVariable("OTEL_SEMCONV_STABILITY_OPT_IN"); We should be using
IConfiguration
to get the switch. -
Shouldn't the environment key have HTTP in the name like
OTEL_HTTP_SEMCONV_STABILITY_OPT_IN
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Just reading this work I found "New" and "Old" pretty confusing. Why not
Legacy
vsStable
or something along those lines?
+1, I had similar concern here #4538 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Just reading this work I found "New" and "Old" pretty confusing. Why not Legacy vs Stable or something along those lines?
How strongly do you feel about this? :)
We can change the enum, but New
and Old
shipped as part of OpenTelemetry.Api v1.5.0.
It's internal
so we CAN change it.
But this would require re-releasing the Api library. (ie Instrumentation.AspNetCore would require an OpenTelemetry.Api v1.5.1).
Also, this is meant to be short lived. When these instrumentation libraries go stable this enum and helper class will be removed.
-
We should be using IConfiguration to get the switch.
Can you please share an example of this?
-
Shouldn't the environment key have HTTP in the name like OTEL_HTTP_SEMCONV_STABILITY_OPT_IN?
That makes sense to me, but the spec defines OTEL_SEMCONV_STABILITY_OPT_IN
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can change the enum, but New and Old shipped as part of OpenTelemetry.Api v1.5.0.
It's internal so we CAN change it.
But this would require re-releasing the Api library. (ie Instrumentation.AspNetCore would require an OpenTelemetry.Api v1.5.1).
The instrumentation libraries do not use this enum
from OpenTelemetry.Api
. They link to the file so each of the libraries have their own copy of it. You should be able to make the necessary changes without worrying about version of OpenTelemetry.Api
.
Note: This does not have to be done in this PR.
@@ -2,6 +2,11 @@ | |||
|
|||
## Unreleased | |||
|
|||
* Updated [Http Semantic Conventions](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.21.0/specification/trace/semantic_conventions/http.md). | |||
* This library can emit either old, new, or both attributes. Users can control |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need a sub-bullet here. This change is simple enough to be put under the same bullet.
Merging this PR to unblock progress. As discussed in the SIG meeting today. @TimothyMothra would work on using |
public const string AttributeHttpResponseStatusCode = "http.response.status_code"; // replaces: "http.status_code" (AttributeHttpStatusCode) | ||
public const string AttributeNetworkProtocolVersion = "network.protocol.version"; // replaces: "http.flavor" (AttributeHttpFlavor) | ||
public const string AttributeServerAddress = "server.address"; // replaces: "net.host.name" (AttributeNetHostName) | ||
public const string AttributeServerPort = "server.port"; // replaces: "net.host.port" (AttributeNetHostPort) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// replaces: "net.peer.port" and "net.host.port"
Design discussion issue #4484
Http Semantic Convention is introducing breaking changes.
This PR makes the change in the Instrumentation.AspNetCore library.
Changes
SemanticConventions
Instrumentation.AspNetCore
classesHttpInListener
andHttpInMetricsListener
to emit new attributes.Please provide a brief description of the changes here.
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changes@vishweshbankwar please review.