-
Notifications
You must be signed in to change notification settings - Fork 878
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 custom attribute through distro #6209
Comments
Hey @shreya22-1998 , Indeed this is currently not supported by the agent; it's a bug I believe, and to resolve it we would have to get rid of these temporary metric views (and replace them with views? or wait for the hint API?). |
So as given in distro example that one can add custom span attribute to all the spans generated by implementing "SpanProcessor", is there anything similar for metrics attribute as well? |
Oh, good thinking. First, you need to implement a custom public void customize(AutoConfigurationCustomizer autoConfiguration) {
autoConfiguration.addMeterProviderCustomizer((meterProviderBuilder, config) -> {
ViewBuilder viewBuilder = View.builder();
SdkMeterProviderUtil.appendAllBaggageAttributes(viewBuilder);
meterProviderBuilder.registerView(
InstrumentSelector.builder().setName("http.server.duration").build(),
viewBuilder.build());
});
} The new view will select the Now, you'll need to fill Either way, it won't be easy and will require digging deep into the server framework instrumentation. |
how to adding a custom ContextCustomizer ? is there anyway to add a custom ContextCustomizer without modifying the framework instrumentation? |
No, unfortunately there isn't. The bottom line is that, no matter which solution you choose, as it is now you'll have to modify the agent code in some way. |
Any updates on this, I guess this is still needed for client metrics. |
Hey @anuragagarwal561994 , |
@mateuszrzeszutek if we are talking about the hack as mentioned in comment: #6209 (comment) This is not working because of the fact we have This is basically filtering out all the other attributes without taking in consideration of the views established. That is where the main concern is. |
That hack requires you to add extra instrumentation that'd fill Anyway, it's complicated and hacky, and if it does not work for you currently there is no other way, unfortunately. This is a perfect scenario for the hypothetical metric Hint API that was lightly discussed in the spec some time ago; unfortunately no progress has been made on this. |
that way need to fill Baggage, but how can i do if want to use some attributes in span |
@mateuszrzeszutek I am working on a PR to handle this. What I have done is that while aggregating I have passed all the attributes and let the RegisteredViews handle which attributes to select. For TemporaryMetricView, I have renamed this class to HttpMetricView and made custom The only thing I need to be able to figure out is that if there is way to provide a default view to the user or some way to provide the use with the ability to modify the default view. Will need some help in designing the same, else everything else is ready. I will raise a MR once this design discussions are over. |
Is there any plan to add tag support for request body in http? |
@lujian402356848 this has been discussed in another issue. Actually it won't be a great idea to do this, tags are not meant for this purpose. As far as I understand, opentelemetry has 3 models:
Tags are part of trace and metrics, aggregations and filtering are done based on these tags. For request body logging kind of scenario, I believe you will need logging module and then a way to link your traces, metrics and logging together using a span / trace id. So the rationale behind this would be that different kind of data requires different storage mechanisms for efficient retrieval and storage. Like for metrics one would want to use a columnar datastore, while for a trace one would want to use elasticsearch kind of store. For logging as well one can use elastic search but the data storage might be configured differently as compared to elastic search. But since the traces can be linked, it is good to keep them separate. |
also check out open-telemetry/oteps#219 |
@trask Is there any code example for adding custom attributes to HTTP metrics emitted by Java agent auto-instrumentation? Couldn't quite figure out how to do it. |
we are trying to add a custom attribute to "http.server.duration" & "http.server.active_requests" through distro ,
any reference or methodology suggested to do it? as the class which have functions to add attribute is declared as " final class TemporaryMetricsView " .
The text was updated successfully, but these errors were encountered: