You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to pass custom options (such as metadata) to the openapi-fetch middleware? I need to collect HTTP status metrics for each fetch call, and for that, every defined method should be able to pass a custom option like meta.metricPrefix. My instrumentation middleware should then be able to access this meta option in order to record the status code using our OpenTelemetry backend.
Here’s an example of how the client and middleware would look:
// Example client callconst{ data }=awaitclient.GET('/users',{meta: {metricPrefix: 'http.client.api.users',},});// Instrumentation middlewareexportfunctioninstrumentationMiddleware(): Middleware{constinstrumentationService=newInstrumentationService();return{onResponse: ({ options, response })=>{if(typeofoptions.meta?.metricPrefix!=='string')return;// skip if not setinstrumentationService.countHttpStatus(options.meta.metricPrefix,response.status);}};}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Is it possible to pass custom options (such as metadata) to the
openapi-fetch
middleware? I need to collect HTTP status metrics for each fetch call, and for that, every defined method should be able to pass a custom option likemeta.metricPrefix
. My instrumentation middleware should then be able to access thismeta
option in order to record the status code using our OpenTelemetry backend.Here’s an example of how the client and middleware would look:
Beta Was this translation helpful? Give feedback.
All reactions