-
Notifications
You must be signed in to change notification settings - Fork 795
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
feat(http-instrumentation): allow filtering of host name on metrics #3880
feat(http-instrumentation): allow filtering of host name on metrics #3880
Conversation
cb2caa2
to
7c26be0
Compare
I think this should be discussed in the semconv/spec part of OTel as it is not specific to JS. There is a somewhat similar topic ongoing regarding HTTP method (see here). fyi @joaopgrassi |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3880 +/- ##
==========================================
- Coverage 92.98% 92.96% -0.02%
==========================================
Files 300 300
Lines 9104 9109 +5
Branches 1862 1866 +4
==========================================
+ Hits 8465 8468 +3
- Misses 639 641 +2
|
I see that this can be a big problem. The solution we'd adopt would highly depend on the solution that the Semantic Conventions folks come up with. While this is being discussed, would creating a view and passing a list of allowed attributes (leaving out |
@pichlermarc can you provide an example/link? I’m also using Prometheus |
Setting up views works like this (this is applied in the SDK metrics pipeline before the prometheus exporter, so it affects all exporters): https://opentelemetry.io/docs/instrumentation/js/manual/#examples In this specific case you'd do: const view = new View({
instrumentName: 'http.server.duration',
instrumentType: InstrumentType.COUNTER,
// everything not in attributeKeys would be ignored
attributeKeys: [
// 'http.host',
// 'net.host.name',
'http.method',
'http.scheme',
'http.route',
// 'net.host.port',
'http.status_code',
],
}), All items in the list will be allowed to be added to the metric, all the commented out attributes (i.e. attributes that are not in the list) will be dropped. Then add the |
thanks! that makes sense. i'm more than happy to help anyway i can to help make otel better, especially in these scenarios, lmk |
@daniel-white thanks for bringing this concern up, was really relevant for discussions we are having right now in the semantic conventions group. Just FYI this is being tracked now on open-telemetry/semantic-conventions#108. Most likely these attributes will be "opt-in" on http metrics |
Looks like the PR on the semconv repo has now merged with the recommendation to only add these attributes when the user opts-in. @daniel-white would that something you'd be interested in implementing? 🙂 |
Sure! It will likely be closer to this weekend |
@pichlermarc should we fix/remove/swap the usage of i'm guessing this instrumentation was written prior to |
@pichlermarc i've put up a wip at #3948 to see what you think about this strategy pattern. i'll iterate more on it as needed |
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
This PR was closed because it has been stale for 14 days with no activity. |
Which problem is this PR solving?
i discovered that the metrics attribute
net.host.name
could be unbounded if a server on a single IP responds to multiple host headers. This would create additional metrics in various scenarios, such as multi tenant applications.I would like validation on this approach before i write tests, thanks!
For more concrete example
each of these requests would generate new metric values without any mechanism to curtail it. with this change, the consumer of
HttpInstrumentation
can decide whether or not to include thenet.host.name
attribute on their metrics.Short description of the changes
adds
ignoreIncomingRequestHostMetricAttribute
to theHttpInstrumentationConfig
. Then uses that in the utilities for mapping from span to metric attribute.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: