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

middleware comms via context.Context #39

miekg opened this issue Mar 24, 2016 · 2 comments


None yet
1 participant
Copy link

commented Mar 24, 2016

With the added param of context.Context in the middleware we can communicate between them. The first use-case for this would be: monitoring.

I.e. middleware proxy sets some vars in the context and the prometheus middleware picks this up from the context and sets the vars. This way we can get middleware monitoring without meddling with prometheus outside of the prometheus middleware.

This needs a key naming policy, i.e. middleware/proxy/counter-name


This comment has been minimized.

Copy link
Member Author

commented Apr 11, 2016

We also create a lot of middleware.State's. We should just put it in the context and carry it through like that.


This comment has been minimized.

Copy link
Member Author

commented Apr 21, 2016

...But context.Context is a value and only propagates downwards, so you can't add something in a later layer and read it back in the upper one.

A second try by wrapping dns.ResponseWriter and putting metrics in there, also does not work, because it might be wrapped further by other middleware.

In the end for metrics we should maybe just have a function the calls into the metrics and add the metric. Also because even if the above would work, in the end you'll still need a metric to be defined to actually increment it.

@miekg miekg closed this Apr 21, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.