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

Allow non-constant endpoints to opt-in to timings #2366

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ private static EndpointChannelFactory createEndpointChannelFactory(Channel multi
channel = new RangeAcceptsIdentityEncodingChannel(channel);
channel = ContentEncodingChannel.of(channel, endpoint);
channel = TracedChannel.create(cf, channel, endpoint);
if (ChannelToEndpointChannel.isConstant(endpoint)) {
if (ChannelToEndpointChannel.isConstant(endpoint)
|| endpoint.tags().contains("dialogue-enable-endpoint-timing")) {
Comment on lines +256 to +257
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose we could probably update ChannelToEndpointChannel to use a caffeine cache with weak keys, and get rid of the isConstant check altogether once the feign client implementation reuses endpoint values -- worst case is weakref churn and metric fanout, but we don't expect these things to be entirely unbounded. When Endpoints aren't reused, this method is called for every request, so looking up the timers in a large TaggedMetricRegistry can be nontrivial, but code that expects decent performance shouldn't stray far from the standard path.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I'm in favor of this proposal for a couple reasons:

  • Even in the current implementation, a poorly implemented client with unbounded service/endpoint names could blow up this ChannelToEndpointChannel cache. Using a Caffeine cache would allow to avoid this by use weak keys and/or bounding the cache.
  • ChannelToEndpointChannel assumes that non-constant endpoints are uniquely identified by (service, endpoint), but this isn't correct, for the reasons mentioned in Cache Feign endpoints conjure-java-runtime#2973 (comment). It would probably be good to switch to a cache for this reason alone.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've put up #2367. Let me know if this isn't what you were imagining.

// Avoid producing metrics for non-constant endpoints which may produce
// high cardinality.
channel = TimingEndpointChannel.create(cf, channel, endpoint);
Expand Down
Loading