Skip to content

Commit e3c6670

Browse files
docs: Documentation update for OpenTelemetry and tracing (#1657)
* docs: Documentation update for OpenTelemetry and tracing * update wording * Fix comments * 🦉 Updates from Hermetic Build image * fix comments --------- Co-authored-by: diegomarquezp <diegomarquezp@google.com>
1 parent e1c48ef commit e3c6670

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

‎.readme-partials.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,17 @@ custom_content: |
227227
<artifactId>google-cloud-logging-servlet-initializer</artifactId>
228228
</dependency>
229229
```
230+
#### Population of Trace/Span ID fields in a LogEntry
231+
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.
232+
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`.
233+
234+
Tracing information set manually takes precedence over information set by the following methods:
235+
236+
* Auto-populate Trace/Span ID from OpenTelemetry Context
237+
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 populated from the active span. More information about OpenTelemetry can be found [here](https://opentelemetry.io/docs/languages/java/).
238+
239+
* Use the [servlet initializer](https://github.com/googleapis/java-logging-servlet-initializer) to Populate Trace/Span ID from HTTP Headers
240+
If trace/span Id are not manually set or auto-populated from OpenTelemetry context, you can use the [servlet initializer](https://github.com/googleapis/java-logging-servlet-initializer) to populate trace/span Id from HTTP headers.
241+
This package filters all servlet requests to automatically capture the execution context of the servlet request and stores it by using ContextHandler class. Http request and trace/span Id information are populated from the stored Context class instances.
242+
Using this method, trace/span Id 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.
230243

‎.repo-metadata.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
"api_shortname": "logging",
33
"name_pretty": "Cloud Logging",
44
"product_documentation": "https://cloud.google.com/logging/docs",
5+
"api_description": "allows you to store, search, analyze, monitor, and alert on log data and events from Google Cloud and Amazon Web Services. Using the BindPlane service, you can also collect this data from over 150 common application components, on-premises systems, and hybrid cloud systems. BindPlane is included with your Google Cloud project at no additional cost.",
56
"client_documentation": "https://cloud.google.com/java/docs/reference/google-cloud-logging/latest/history",
6-
"issue_tracker": "https://issuetracker.google.com/savedsearches/559764",
77
"release_level": "stable",
8+
"transport": "grpc",
89
"language": "java",
910
"repo": "googleapis/java-logging",
1011
"repo_short": "java-logging",
1112
"distribution_name": "com.google.cloud:google-cloud-logging",
1213
"api_id": "logging.googleapis.com",
13-
"transport": "grpc",
1414
"library_type": "GAPIC_COMBO",
15-
"api_description": "allows you to store, search, analyze, monitor, and alert on log data and events from Google Cloud and Amazon Web Services. Using the BindPlane service, you can also collect this data from over 150 common application components, on-premises systems, and hybrid cloud systems. BindPlane is included with your Google Cloud project at no additional cost.",
15+
"requires_billing": true,
1616
"codeowner_team": "@googleapis/api-logging @googleapis/yoshi-java @googleapis/api-logging-partners",
17+
"issue_tracker": "https://issuetracker.google.com/savedsearches/559764",
1718
"recommended_package": "com.google.cloud.logging"
18-
}
19+
}

‎README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file:
1919
<dependency>
2020
<groupId>com.google.cloud</groupId>
2121
<artifactId>libraries-bom</artifactId>
22-
<version>26.40.0</version>
22+
<version>26.43.0</version>
2323
<type>pom</type>
2424
<scope>import</scope>
2525
</dependency>
@@ -52,7 +52,7 @@ If you are using Maven without the BOM, add this to your dependencies:
5252
If you are using Gradle 5.x or later, add this to your dependencies:
5353

5454
```Groovy
55-
implementation platform('com.google.cloud:libraries-bom:26.42.0')
55+
implementation platform('com.google.cloud:libraries-bom:26.43.0')
5656
5757
implementation 'com.google.cloud:google-cloud-logging'
5858
```
@@ -82,7 +82,7 @@ The client application making API calls must be granted [authorization scopes][a
8282
### Prerequisites
8383

8484
You will need a [Google Cloud Platform Console][developer-console] project with the Cloud Logging [API enabled][enable-api].
85-
85+
You will need to [enable billing][enable-billing] to use Google Cloud Logging.
8686
[Follow these instructions][create-project] to get your project set up. You will also need to set up the local development environment by
8787
[installing the Google Cloud Command Line Interface][cloud-cli] and running the following commands in command line:
8888
`gcloud auth login` and `gcloud config set project [YOUR PROJECT ID]`.
@@ -282,7 +282,7 @@ Cloud Function or GKE. The logger agent installed on these environments can capt
282282
The agent can parse structured logs printed to STDOUT and capture additional log metadata beside the log payload.
283283
The parsed information includes severity, source location, user labels, http request and tracing information.
284284

285-
#### Auto-population of log entrys' metadata
285+
#### Auto-population of Metadata in a LogEntry
286286

287287
LogEntry object metadata information such as [monitored resource](https://cloud.google.com/logging/docs/reference/v2/rest/v2/MonitoredResource),
288288
[Http request](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#HttpRequest) or
@@ -329,6 +329,19 @@ If you use Maven, to use the servlet initializer add the following dependency to
329329
<artifactId>google-cloud-logging-servlet-initializer</artifactId>
330330
</dependency>
331331
```
332+
#### Population of Trace/Span ID fields in a LogEntry
333+
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.
334+
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`.
335+
336+
Tracing information set manually takes precedence over information set by the following methods:
337+
338+
* Auto-populate Trace/Span ID from OpenTelemetry Context
339+
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 populated from the active span. More information about OpenTelemetry can be found [here](https://opentelemetry.io/docs/languages/java/).
340+
341+
* Use the [servlet initializer](https://github.com/googleapis/java-logging-servlet-initializer) to Populate Trace/Span ID from HTTP Headers
342+
If trace/span Id are not manually set or auto-populated from OpenTelemetry context, you can use the [servlet initializer](https://github.com/googleapis/java-logging-servlet-initializer) to populate trace/span Id from HTTP headers.
343+
This package filters all servlet requests to automatically capture the execution context of the servlet request and stores it by using ContextHandler class. Http request and trace/span Id information are populated from the stored Context class instances.
344+
Using this method, trace/span Id 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.
332345

333346

334347

@@ -464,7 +477,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
464477
[contributing]: https://github.com/googleapis/java-logging/blob/main/CONTRIBUTING.md
465478
[code-of-conduct]: https://github.com/googleapis/java-logging/blob/main/CODE_OF_CONDUCT.md#contributor-code-of-conduct
466479
[license]: https://github.com/googleapis/java-logging/blob/main/LICENSE
467-
480+
[enable-billing]: https://cloud.google.com/apis/docs/getting-started#enabling_billing
468481
[enable-api]: https://console.cloud.google.com/flows/enableapi?apiid=logging.googleapis.com
469482
[libraries-bom]: https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM
470483
[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png

0 commit comments

Comments
 (0)