You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: .readme-partials.yml
+13
Original file line number
Diff line number
Diff line change
@@ -80,6 +80,19 @@ body: |-
80
80
If you already have a "raw" Http `request` object you can assign it to `entry.metadata.httpRequest` directly. More information about
81
81
how the `request` is interpreted as raw can be found in the [code](https://github.com/googleapis/nodejs-logging/blob/15849160116a814ab71113138cb211c2e0c2d4b4/src/entry.ts#L224-L238).
82
82
83
+
## Automatic Trace/Span ID Extraction
84
+
Cloud Logging libraries use [trace fields within LogEntry](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#FIELDS.trace) to capture trace contexts, which enables the [correlation of logs and traces](https://cloud.google.com/logging/docs/view/correlate-logs), and distributed tracing troubleshooting.
85
+
These tracing fields, including [trace](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#FIELDS.trace), [spanId](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#FIELDS.span_id), and [traceSampled](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#FIELDS.trace_sampled), define the trace context for a `LogEntry`.
86
+
87
+
If not provided explicitly in a LogEntry, the Cloud Logging library automatically populates `trace`, `span_id`, and `trace_sampled` fields from detected OpenTelemetry span contexts, or from HTTP request headers.
88
+
89
+
### Extracting Trace/Span ID from OpenTelemetry Context
90
+
If you are using OpenTelemetry and there is an active span in the OpenTelemetry Context, the `trace`, `span_id`, and `trace_sampled` fields in the log entry are automatically populated from the active span. More information about OpenTelemetry can be found [here](https://opentelemetry.io/docs/languages/js/).
91
+
92
+
### Extracting Trace/Span ID from HTTP Headers
93
+
If tracing fields are not provided explicitly and no OpenTelemetry context is detected, the `trace` / `span_id` fields are extracted automatically from HTTP headers.
94
+
Trace information can be automatically populated from either the [W3C Traceparent](https://www.w3.org/TR/trace-context) or [X-Cloud-Trace-Context](https://cloud.google.com/trace/docs/trace-context#legacy-http-header) headers.
95
+
83
96
## Error handling with logs written or deleted asynchronously
84
97
85
98
The `Log` class provide users the ability to write and delete logs asynchronously. However, there are cases when log entries
Copy file name to clipboardexpand all lines: README.md
+13
Original file line number
Diff line number
Diff line change
@@ -170,6 +170,19 @@ how to populate the Http request metadata for log entries.
170
170
If you already have a "raw" Http `request` object you can assign it to `entry.metadata.httpRequest` directly. More information about
171
171
how the `request` is interpreted as raw can be found in the [code](https://github.com/googleapis/nodejs-logging/blob/15849160116a814ab71113138cb211c2e0c2d4b4/src/entry.ts#L224-L238).
172
172
173
+
## Automatic Trace/Span ID Extraction
174
+
Cloud Logging libraries use [trace fields within LogEntry](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#FIELDS.trace) to capture trace contexts, which enables the [correlation of logs and traces](https://cloud.google.com/logging/docs/view/correlate-logs), and distributed tracing troubleshooting.
175
+
These tracing fields, including [trace](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#FIELDS.trace), [spanId](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#FIELDS.span_id), and [traceSampled](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#FIELDS.trace_sampled), define the trace context for a `LogEntry`.
176
+
177
+
If not provided explicitly in a LogEntry, the Cloud Logging library automatically populates `trace`, `span_id`, and `trace_sampled` fields from detected OpenTelemetry span contexts, or from HTTP request headers.
178
+
179
+
### Extracting Trace/Span ID from OpenTelemetry Context
180
+
If you are using OpenTelemetry and there is an active span in the OpenTelemetry Context, the `trace`, `span_id`, and `trace_sampled` fields in the log entry are automatically populated from the active span. More information about OpenTelemetry can be found [here](https://opentelemetry.io/docs/languages/js/).
181
+
182
+
### Extracting Trace/Span ID from HTTP Headers
183
+
If tracing fields are not provided explicitly and no OpenTelemetry context is detected, the `trace` / `span_id` fields are extracted automatically from HTTP headers.
184
+
Trace information can be automatically populated from either the [W3C Traceparent](https://www.w3.org/TR/trace-context) or [X-Cloud-Trace-Context](https://cloud.google.com/trace/docs/trace-context#legacy-http-header) headers.
185
+
173
186
## Error handling with logs written or deleted asynchronously
174
187
175
188
The `Log` class provide users the ability to write and delete logs asynchronously. However, there are cases when log entries
0 commit comments