Google-cloud-go: clarification regarding grouping logs by request

Created on 29 Jan 2019  路  2Comments  路  Source: googleapis/google-cloud-go

This comment on godoc is confusing: https://godoc.org/cloud.google.com/go/logging#hdr-Grouping_Logs_by_Request

To group all the log entries written during a single HTTP request, create two Loggers, a "parent" and a "child," with different log IDs. Both should be in the same project, and have the same MonitoredResouce type and labels.

- Parent entries must have HTTPRequest.Request populated. (Strictly speaking, only the URL is necessary.)

- A child entry's timestamp must be within the time interval covered by the parent request (i.e., older than parent.Timestamp, and newer than parent.Timestamp - parent.HTTPRequest.Latency, assuming the parent timestamp marks the end of the request.

- The trace field must be populated in all of the entries and match exactly.

You should observe the child log entries grouped under the parent on the console. The parent entry will not inherit the severity of its children; you must update the parent severity yourself.

Why do I need to create two loggers? Whats the purpose of the parent vs child? Why do they need different log IDs and why do I need to update the parent severity myself? It'd be nice to see how this looks in code.

logging question

All 2 comments

Here is a thread I followed to get it working.
https://github.com/googleapis/google-cloud-go/issues/448

Thank you, that thread cleared it up for me.

Was this page helpful?
0 / 5 - 0 ratings