router
router copied to clipboard
Studio Operation Usage Reporting: ability to exclude specific requests
Is your feature request related to a problem? Please describe. In some use cases, particular requests are less valuable to transmit to Studio — for example, particular testing or bot traffic.
Describe the solution you'd like
Today, in Apollo Server, there is an includeRequest
function (see documentation) that can be used to exclude particular requests. This is specified as a function/closure that receives the request context and returns a boolean: (includeRequest: (requestContext): boolean
).
A common case scenario is to check for a particular header, though for other cases, custom logic may be desirable.
cc @garypen
This feels like it may be nice to implement using our upcoming extension functionality. I could imagine a service which processes each request and updates the request context to include/exclude from studio usage reporting. I'll look at this when the extension functionality lands in main.
Following discussion with the team, this is going to be implemented within the apollo telemetry implementation.
I've renamed the title of this issue to include a more specific name, given the introduction of other Studio functionality and to reduce the potential ambiguity.
Marked as in progress because in #898 we check for the presence of a field in the request.context, but we still need to add yml configuration with an excludeList of operationNames for example
I think we should avoid yaml config and rely on Rhai for this one.
Sgtm!
Closing this ticket since it is closed on the project board.
Just FYI, I have some feedback on https://github.com/apollographql/router/pull/898/files related to this unfinished feature — search my comments for STUDIO_EXCLUDE.
This issue wasn't meant to be closed — the work isn't done.
Worth noting that we also have https://github.com/apollographql/router/issues/1359 which touches on tracing aspects of this.
This is implemented already. Users can insert apollo_telemetry::studio::exclude
into context to disable metrics for a particular request. Note that this does not affect operation count.