-
Notifications
You must be signed in to change notification settings - Fork 772
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
Add support for OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS #5197
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main open-telemetry/opentelemetry-dotnet#5197 +/- ##
==========================================
- Coverage 83.38% 83.11% -0.28%
==========================================
Files 297 271 -26
Lines 12531 11987 -544
==========================================
- Hits 10449 9963 -486
+ Misses 2082 2024 -58
Flags with carried forward coverage won't be shown. Click here to find out more.
|
This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day. |
src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInMetricsListener.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreTraceInstrumentationOptions.cs
Outdated
Show resolved
Hide resolved
@@ -125,6 +125,9 @@ public class HttpClientTraceInstrumentationOptions | |||
/// </remarks> | |||
public bool RecordException { get; set; } | |||
|
|||
internal List<string> KnownHttpMethods { get; set; } = |
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.
Is this being set from OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS
anywhere? I don't see a ctor accepting IConfiguration
on this class so it is possible some prep works needs to be done to hook that up. LMK if you would like some help with that.
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.
Correct, that was still a to do.
I now made some changes to read from env variables as well and added a unit test for it.
Can you review?
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.
A question I had:
When OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS
is set to an empty string or something illogical like fooBar
, http.request.method
is still set to GET
for example and not to _OTHER
.
Do you think this is correct behaviour?
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 pushed some changes to the branch. Sorry about that I needed to see how the code was working and then I just started messing around with it 😓
-
Refactored everything into
RequestMethodHelper
(instead of options classes). Reason for that isOTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS
should also apply to metrics. I didn't want to introduce metrics options classes where we don't have them and also didn't want the same code in 4 options classes 🤣 I think now it has better separation of concerns. -
Your question above about
fooBar
. I took a look at the spec and it seems likeOTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS
should fully override the default list. The way it was coded you could only pair down the list of known things. I switched it up so we respect whatever is specified byOTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS
. I would like @vishweshbankwar to sound off on this. He has more expertise in the area. But he is out until 1/15 so we'll have to wait a bit to get his review.
…opentelemetry-dotnet into 5013-http-known-methods
src/Shared/RequestMethodHelper.cs
Outdated
#if NET8_0_OR_GREATER | ||
public void SetHttpClientActivityDisplayName(Activity activity, string method) | ||
#else | ||
public void SetHttpClientActivityDisplayName(Activity activity, string method) | ||
#endif |
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.
Why is the #if needed here? Maybe an earlier change that was removed?
<Compile Include="$(RepoRoot)\src\Shared\Guard.cs" Link="Includes\Guard.cs" /> | ||
<Compile Include="$(RepoRoot)\src\Shared\Shims\NullableAttributes.cs" Link="Includes\Shims\NullableAttributes.cs" /> | ||
<Compile Include="$(RepoRoot)\src\Shared\Options\*.cs" Link="Includes\Options\%(Filename).cs" /> |
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.
nit: this could be simplified
<Compile Include="$(RepoRoot)\src\Shared\Options\*.cs" Link="Includes\Options\%(Filename).cs" /> | |
<Compile Include="$(RepoRoot)\src\Shared\Options\*.cs" LinkBase="Includes\Options" /> |
I think we should not add this for now. |
Not at the moment. No one has asked for it yet. If |
If a config option would be added to .NET (assuming |
This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day. |
Closing this PR: See #5197 (comment) |
Fixes open-telemetry/opentelemetry-dotnet-contrib#1731
If the HTTP request method is not known to instrumentation, it MUST set the
http.request.method
attribute to _OTHER.Changes
KnownHttpMethods
property to options classes. Populated from environment variables or programmatically.KnownHttpMethods
in AspnetCore and Http instrumentation