Skip to content

Commit

Permalink
Update quickstart sample to output correct severity strings
Browse files Browse the repository at this point in the history
  • Loading branch information
aabmass committed Apr 17, 2024
1 parent 97a8f20 commit 0c8acf2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 12 additions & 0 deletions examples/instrumentation-quickstart/otel-collector-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ receivers:
layout: '%Y-%m-%dT%H:%M:%S.%fZ'
severity:
parse_from: body.severity
preset: none
# parse minimal set of severity strings that Cloud Logging explicitly supports
# https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSeverity
mapping:
debug: debug
info: info
info3: notice
warn: warning
error: error
fatal: critical
fatal3: alert
fatal4: emergency

# set trace_flags to SAMPLED if GCP attribute is set to true
- type: add
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@
{
"logging.googleapis.com/trace": "%mdc{trace_id}",
"logging.googleapis.com/spanId": "%mdc{span_id}",
"logging.googleapis.com/trace_sampled": "#asBoolean{%replace(%mdc{trace_flags}){'01', 'true'}}"
"logging.googleapis.com/trace_sampled": "#asBoolean{%replace(%mdc{trace_flags}){'01', 'true'}}",
"severity": "%replace(%replace(%level){'WARN', 'WARNING'}){'TRACE', 'DEBUG'}"
}
</pattern>
</provider>

<!-- Rename fields for the Logging agent -->
<fieldNames>
<level>severity</level>
<timestamp>timestamp</timestamp>
<level>[ignore]</level>
<levelValue>[ignore]</levelValue>
</fieldNames>

Expand All @@ -45,7 +46,7 @@
<!-- [END opentelemetry_instrumentation_logbackxml] -->
</appender>

<root level="INFO">
<root level="TRACE">
<appender-ref ref="STDOUT"/>
</root>

Expand Down

0 comments on commit 0c8acf2

Please sign in to comment.