Skip to content
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

Replace Temporary Views with Metrics View API #7474

Conversation

anuragagarwal561994
Copy link
Contributor

@anuragagarwal561994 anuragagarwal561994 commented Dec 27, 2022

Closes #6819
Closes #6209
Closes #6818

  • http client
  • http server
  • grpc client
  • grpc server
  • better ways to integrate for end user
  • include view from files

@anuragagarwal561994 anuragagarwal561994 requested a review from a team December 27, 2022 02:33
@anuragagarwal561994 anuragagarwal561994 marked this pull request as draft December 27, 2022 02:33
HttpMetricsViews.registerViews(builder);
RpcMetricsView.registerViews(builder);
return builder;
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be a bad idea. Somewhat surprisingly, doing this prevents a user from using view to drop the instrument or adjust its attributes. This is because when multiple views are registered match a particular instrument, there is no merging of the views. Instead, multiple metrics are produced.

To see what I mean, try configuring the SDK in the test code of this branch to add a view which drops http.server.duration or changes the attributes of http.server.duration. You should multiple metrics named http.server.duration in the logs, each which the configuration of one of the matching views.

Copy link
Contributor Author

@anuragagarwal561994 anuragagarwal561994 Dec 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I suspected the same, hence I am still thinking of how to approach this from the user perspective as I marked in the checklist.

But anyhow I believe that making views instead of hard coded filtering would still be the first step in this direction.

The current solution I have is that the user overrides the SdkMetricProvider completely instead of adding in more views over it.

Another approach I believe would be to allow user to customise and configure these views like a decorator pattern by exposing some sort of APIs.

Third approach which I am exploring is to move these configs to view config files and allows user to override these config files either by merging or replacing the config files. This is a more plausible approach but currently due to some dependency issues I am ending up with NoClassDef error.

May be the first draft won't be a cleaner solution for the user to integrate because I suspect that some changes in the base libraries would be needed as well. But it will still be better than having no solution at all like today.

@trask @mateuszrzeszutek do you have some suggestions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would also introduce a breaking change for the library instrumentation users (including spring sleuth/observability): they'd now have to add views by themselves, and ensure that they views match the OTel metrics spec.

I think this should be resolved on the spec level. I've created a separate issue just for this: open-telemetry/opentelemetry-specification#3061

I think this is one of the two known use cases for the future "hint API", and that it's nearly impossible to resolve this (and not break anything) without the necessary API changes.

Copy link
Member

@mateuszrzeszutek mateuszrzeszutek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that these issues are unresolvable without a "hint API"; we need a spec for the API changes first.

HttpMetricsViews.registerViews(builder);
RpcMetricsView.registerViews(builder);
return builder;
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would also introduce a breaking change for the library instrumentation users (including spring sleuth/observability): they'd now have to add views by themselves, and ensure that they views match the OTel metrics spec.

I think this should be resolved on the spec level. I've created a separate issue just for this: open-telemetry/opentelemetry-specification#3061

I think this is one of the two known use cases for the future "hint API", and that it's nearly impossible to resolve this (and not break anything) without the necessary API changes.

@anuragagarwal561994
Copy link
Contributor Author

anuragagarwal561994 commented Dec 28, 2022

@jack-berg @mateuszrzeszutek I have one more idea for an interim solution.

What if the view user wants to customise he drops that view and instead creates a new view.

Like
Instrument = http.client.duration
View = http.client.duration
Aggregation = drop

Instument = http.client.duration
View = http.client.custom.duration
Attributes
Custom attributes
http.status_code

I haven't tried this, but conceptually it should drop the default view and let the user create custom views with attributes they desire.

This should not produce 2 views and aggregations and of the same name.

@anuragagarwal561994
Copy link
Contributor Author

So I realised that this won't work because we can't drop the view created internally.

But this lead me thinking what is the point of creating 2 storages in same instrumentation scope with same metric name view.

Can we just override the view with the latest registered view that belong to the same scope with the same view name?

That should solve all our problems.

@trask
Copy link
Member

trask commented Feb 24, 2023

hey @anuragagarwal561994 I didn't follow your latest comment, can you explain your latest thoughts in more detail? thx!

@trask
Copy link
Member

trask commented Oct 11, 2023

closing, this is resolved now by #9440

@trask trask closed this Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants