-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
docs(logging): Documentation for automatic trace/span ID extraction #10536
Changes from 1 commit
8476951
86ddf93
3bceeef
035232e
001cb1e
607d328
ccbf15e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,5 +146,32 @@ parent.Timestamp marks the end of the request.) | |
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. | ||
|
||
# Automatic Metadata Extraction | ||
|
||
You can automatically populate the Trace, SpanID, and TraceSampled fields of an Entry object by providing an [http.Request] object | ||
within the Entry's HTTPRequest field: | ||
|
||
logging.Entry{ | ||
HTTPRequest: &logging.HTTPRequest{ | ||
Request: // Reference to your http.Request here | ||
} | ||
} | ||
|
||
When Entry with an [http.Request] is logged, its Trace, SpanID, and TraceSampled fields may be automatically populated as follows: | ||
|
||
1. If you are instrumenting your application with [OpenTelemetry] and your http.Request's Context contains an [OpenTelemetry span context], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi Kevin, do we need to specify this "and your http.Request's Context contains an [OpenTelemetry span context]"? It is automatically added when customer's application is instrumented with OpenTelemetry right? |
||
the Entry's Trace, SpanID, and TraceSampled will be populated with information from that span context. | ||
2. Trace, SpanID, and TraceSampled fields will be populated from information from the http.Request's [W3C Traceparent] | ||
or [X-Cloud-Trace-Context] headers, if those headers exist. | ||
|
||
Note that if Trace, SpanID, or TraceSampled are explicitly provided within an Entry object, those values will take precedence over values automatically | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd say "object, then those values take precedence" (a little more direct/less wordy than "will take", and then meaning is the same) |
||
extracted from the aforementioned process. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you could just say "over automatically extracted values" |
||
|
||
[http.Request]: https://pkg.go.dev/net/http#Request | ||
[OpenTelemetry]: https://opentelemetry.io/docs/languages/go/ | ||
[OpenTelemetry span context]: https://pkg.go.dev/go.opentelemetry.io/otel/trace#SpanContext | ||
[W3C Traceparent]: https://www.w3.org/TR/trace-context | ||
[X-Cloud-Trace-Context]: https://cloud.google.com/trace/docs/trace-context#legacy-http-header | ||
*/ | ||
package logging // import "cloud.google.com/go/logging" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to call this "Automatic Metadata Extraction" or "Automatic Trace/Span Id Extraction" as in googleapis/python-logging#915?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to change it to be more specific in this instance.