googleapis / nodejs-logging-bunyan

Node.js client integration between Stackdriver Logging and Bunyan.
https://cloud.google.com/logging/
Apache License 2.0
63 stars 34 forks source link

Attaching labels to Http Request logs middleware #604

Closed matteobucci closed 10 months ago

matteobucci commented 2 years ago

Hello!

We have been using this library since more than one year, by making use of the middleware for request bundling and metadata. Recently we decided to improve our logging capabilities by attaching some extra label on any request log to better filter our log due to the increasing complexity of our product.

If we want to filter by a specific client session, we just send an additional header to the request and we include that header on the labels we attach to the logs.

The problem is that we have not been able to attach the same labels to the log of the Http request, thus severely limiting the usefulness of the labels in this use case.

A possible workaround would be to print an extra log that would be redundant with the main request log, but we will lose most of the benefit of having the request bundled and the extra formatting we get by using the middleware.

image

As you can see in the filter, if I would like to filter the logs by the green label, I wouldn't be able to see the log of the requests.

cindy-peng commented 10 months ago

Hi @matteobucci, do you mind sharing your code how you attach labels and log HTTP Request?

cindy-peng commented 10 months ago

I am closing this issue for now as no code examples were shared to assist further troubleshooting. Please feel free to reopen this issue if you still run into this problem. Thank you!