-
Notifications
You must be signed in to change notification settings - Fork 39
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
Change OTel quickstart to use log4j2 instead of logback #330
Conversation
Log4j2's `JsonTemplateLayout` supports most of the Cloud Logging special JSON keys directly through the [`GcpLayout` event template](https://logging.apache.org/log4j/2.x/manual/json-template-layout.html#event-templates). I still needed to map the OTel MDC keys for trace correlation, but am planning to contribute [this upstream](https://github.com/apache/logging-log4j2/blob/rel/2.17.2/log4j-layout-template-json/src/main/resources/GcpLayout.json). One outstanding issue is converting the `trace_flags` hex value to a boolean, but it doesn't break Cloud Console if `logging.googleapis.com/trace_sampled` key is unset/false. See apache/logging-log4j2#2482.
f177495
to
b2e696e
Compare
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
<Configuration status="WARN"> | ||
<Appenders> | ||
<Console name="Console" target="SYSTEM_OUT"> | ||
<!-- [START opentelemetry_instrumentation_setup_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.
This is a different region tag than the docs currently use
opentelemetry-operations-java/examples/instrumentation-quickstart/src/main/resources/logback.xml
Line 19 in 97a8f20
<!-- [START opentelemetry_instrumentation_logbackxml] --> |
So I can update the docs before removing the logback.xml files
# - type: add | ||
# field: body.trace_flags | ||
# value: "01" | ||
# if: body["logging.googleapis.com/trace_sampled"] == true |
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.
if this returns false, will that just be a no-op? (do we actually need to comment out this config?)
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.
Ah good point. I was trying to prevent collector log spam, but it looks like the log spam is actually coming from the remove
operator:
2024-04-18T14:52:50.317Z error helper/transformer.go:98 Failed to process entry {"kind": "receiver", "name": "filelog", "data_type": "logs", "operator_id": "remove6", "operator_type": "remove", "error": "remove: field does not exist: body['logging.googleapis.com/trace_sampled']", "action": "send", "entry": {"observed_timestamp":"2024-04-18T14:52:50.317546122Z","timestamp":"2024-04-18T14:52:50.214Z","body":{"_exception":{"stackTrace":""},"_logger":"com.example.demo.SingleController","_thread":"reactor-http-epoll-20","logging.googleapis.com/insertId":"2037","logging.googleapis.com/labels":{"span_id":"5aeb502bb6ef209f","trace_flags":"01","trace_id":"5643ea6d8d99b1b30a6fbab66b1a3ddd"},"logging.googleapis.com/sourceLocation":{"function":"com.example.demo.SingleController.handleSingle"},"message":"Going to sleep for 172"},"attributes":{"log.file.name":"app.log"},"severity_text":"INFO","span_id":"WutQK7bvIJ8=","trace_id":"VkPqbY2ZsbMKb7q2axo93Q==","severity":9,"scope_name":""}}
I'll just let it be for now and reset this file
…rces-support to v0.29.0 (#2831) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud.opentelemetry:detector-resources-support](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java) | `0.28.0` -> `0.29.0` | [![age](https://developer.mend.io/api/mc/badges/age/maven/com.google.cloud.opentelemetry:detector-resources-support/0.29.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/com.google.cloud.opentelemetry:detector-resources-support/0.29.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/com.google.cloud.opentelemetry:detector-resources-support/0.28.0/0.29.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/com.google.cloud.opentelemetry:detector-resources-support/0.28.0/0.29.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>GoogleCloudPlatform/opentelemetry-operations-java (com.google.cloud.opentelemetry:detector-resources-support)</summary> ### [`v0.29.0`](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/releases/tag/v0.29.0) [Compare Source](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/compare/v0.28.0...v0.29.0) #### Release Highlights - Non-GKE resource now map to `k8s_*` monitored resource ([#​340](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/issues/340) , [#​342](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/issues/342)) - Support for mapping to custom Monitored Resources ([#​346](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/issues/346)) - Newly deprecated APIs: [mapResource](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/blob/b0caafdaceb2b7418d256cecc05fa8fce9bafecc/exporters/metrics/src/main/java/com/google/cloud/opentelemetry/metric/ResourceTranslator.java#L36) #### What's Changed - Update maven-badges to link to sonatype central by [@​psx95](https://togithub.com/psx95) in [https://github.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/322](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/322) - Add auth support for gRPC by [@​psx95](https://togithub.com/psx95) in [https://github.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/323](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/323) - Switch to ConcurrentMap for thread-safety by [@​psx95](https://togithub.com/psx95) in [https://github.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/328](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/328) - Add otlp with spring boot sample by [@​psx95](https://togithub.com/psx95) in [https://github.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/327](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/327) - Change OTel quickstart to use log4j2 instead of logback by [@​aabmass](https://togithub.com/aabmass) in [https://github.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/330](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/330) - Always output logging.googleapis.com/trace_sampled as true by [@​aabmass](https://togithub.com/aabmass) in [https://github.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/332](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/332) - Update JVM flag otel.java.experimental.extension by [@​psx95](https://togithub.com/psx95) in [https://github.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/338](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/338) - Add test case for zone resource detection on GAE standard by [@​aabmass](https://togithub.com/aabmass) in [https://github.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/341](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/341) - Fix [#​258](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/issues/258) enable mapping when not gcp kubernetes by [@​tkmsaaaam](https://togithub.com/tkmsaaaam) in [https://github.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/340](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/340) - Fix [#​340](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/issues/340) bug by [@​tkmsaaaam](https://togithub.com/tkmsaaaam) in [https://github.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/342](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/342) - Make all AttributeMappings final by [@​psx95](https://togithub.com/psx95) in [https://github.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/347](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/347) - Add support for custom MR mappings by [@​psx95](https://togithub.com/psx95) in [https://github.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/346](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/346) #### New Contributors - [@​tkmsaaaam](https://togithub.com/tkmsaaaam) made their first contribution in [https://github.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/340](https://togithub.com/GoogleCloudPlatform/opentelemetry-operations-java/pull/340) **Full Changelog**: GoogleCloudPlatform/opentelemetry-operations-java@v0.28.0...v0.29.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/googleapis/sdk-platform-java). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNzcuOCIsInVwZGF0ZWRJblZlciI6IjM3LjM3Ny44IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
Log4j2's
JsonTemplateLayout
supports most of the Cloud Logging special JSON keys directly through theGcpLayout
event template. I still needed to map the OTel MDC keys for trace correlation, but am planning to contribute this upstream.One outstanding issue is converting the
trace_flags
hex value to a boolean, but it doesn't break Cloud Console iflogging.googleapis.com/trace_sampled
key is unset/false. See apache/logging-log4j2#2482.