Skip to content

Add OperationID in client request header #1390

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chrisngyn
Copy link

I utilized this library to create a client from an OpenAPI specification, and now I aim to develop an interceptor for monitoring outgoing HTTP requests using Prometheus.
However, the request path varies based on path parameters, making it impractical to use it as a label value for Prometheus metrics.
As a solution, I propose adding an additional header (Operation-Id) to each HTTP request. This adjustment simplifies the process of writing the monitoring interceptor.

It just a naive solution. Feel free to suggest me the better solutions.

@chrisngyn
Copy link
Author

Almost file changes are the result when I ran make generate. I just only a one line at pkg/codegen/templates/client.tmpl

req.Header.Add("Operation-Id", "{{$opid}}")

@jamietanna
Copy link
Member

Hey @chrisngyn thanks for raising this.

Unfortunately this isn't something that we'd like to make the default.

You may be able to do this with a RequestEditorFn that's added into the client - it'll still require the OperationID, so maybe adding a field into the ctx that can be retrieved by a RequestEditorFn would work.

If you were to tweak this and make it an opt-in flag (see #1404 for where we've added an opt-in flag) then that'd be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy