common icon indicating copy to clipboard operation
common copied to clipboard

HTTP Logging doesn't print user-id

Open gouthamve opened this issue 7 years ago • 4 comments

While I think the idea was to print user/org ids, with http req logging, as seen here: https://github.com/weaveworks/common/blob/master/middleware/logging.go#L40 we don't.

This is because logging is currently the first middleware and auth is usually the last. Which means the context that the logging middleware has access to doesn't have the user/org-ids.

Not sure how to put the auth middleware at the first though....

gouthamve avatar Aug 01 '18 11:08 gouthamve

good spot!

We could prepend the supplied server.Config.HTTPMiddleware instead of appending it. Might need to tweak the opentracing handler.

Or server.Config could have pre- and post- middleware.

bboreham avatar Aug 01 '18 11:08 bboreham

Oh, I am not sure that'll help. Because AFAICS, the auth part comes here: https://github.com/weaveworks/cortex/blob/master/cmd/querier/main.go#L106-L109

gouthamve avatar Aug 02 '18 08:08 gouthamve

I don't see why it needs to be done that way. It is allowing non-authenticated access to /ring, but that doesn't seem essential.

bboreham avatar Aug 02 '18 09:08 bboreham

Looking into this again, https://github.com/weaveworks/common/blob/master/middleware/logging.go#L36 should inject the user-id into the context, not sure why it doesn't.

gouthamve avatar Aug 22 '18 12:08 gouthamve