apollographql / router

A configurable, high-performance routing runtime for Apollo Federation 🚀
https://www.apollographql.com/docs/router/
Other
783 stars 256 forks source link

Add new metric for the "real" Router processing time #4978

Open smyrick opened 3 months ago

smyrick commented 3 months ago

Is your feature request related to a problem? Please describe. Today the metrics apollo_router_http_request_duration_seconds_bucket includes the total HTTP time that supergraph requests see and apollo_router_processing_time includes the time spent processing a request (but outside of waiting for external or subgraph requests) in seconds.

If we have custom extensions like Rhai, Coprocessor, and/or custom Rust plugins then we don't have a good picture of the "real" router overhead minus subgraph time.

Describe the solution you'd like Add a new metric, something like apollo_router_overhead_time or apollo_router_total_processing_time, that DOES include external and custom plugins.

Describe alternatives you've considered I could do the math of apollo_router_http_request_duration_seconds_bucket - apollo_router_processing_time + apollo_router_operations_coprocessor.duration + a custom metric I make in my Rust plugins, but that is a lot of work for a simple number

Additional context The current situations can also lead to a weird issue where the http duration is smaller than processing time: https://github.com/apollographql/router/issues/2906

xuorig commented 3 months ago

custom Rust plugins

@smyrick are those actually excluded? It didn't look like it to me but let me know if that's really the case 👂

smyrick commented 3 months ago

Those are not excluded today but just calling out that they should continue to be included in the new metric

IceHoppr commented 3 months ago

@smyrick it would be great to have existing metric apollo_router_overhead_time exclude the time spent in custom plugins to call external services. One additional new metrics e.g. apollo_router_processing_time can be apollo_router_overhead_time + time spent in external calls in plugins. While the overall request time 'apollo_router_http_request_duration' should be : apollo_router_overhead_time + time spent in external calls in plugins + co-processor processing time + upstream subgraph request processing time.