-
Notifications
You must be signed in to change notification settings - Fork 2.9k
ECS log-format doesn't comply for trace fields #45585
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
Comments
/cc @brunobat (opentelemetry), @radcortez (opentelemetry) |
The tracing data is in the MDC context. |
@troosan any chance you could have a look? |
indeed, I'm aware of this, which is why as a workaround I proposed a logstash filter to move the info to the right place and this is what is documented here there would be work to do to abstract the work done for the google cloud logging |
If you switch to the quarkiverse logging extension <dependency>
<groupId>io.quarkiverse.loggingjson</groupId>
<artifactId>quarkus-logging-json</artifactId>
<version>3.1.0</version>
</dependency> You can use the following which will map keys from the MDC to the correct elastic keys @Singleton
public class ElasticLogJsonProvider implements JsonProvider {
public static final String TRACE_ID = "traceId";
public static final String SPAN_ID = "spanId";
public static final String ECS_TRACE_ID = "trace.id";
public static final String ECS_SPAN_ID = "span.id";
@Override
public void writeTo(JsonGenerator generator, ExtLogRecord event) throws IOException {
renameToElasticField(event, generator, TRACE_ID, ECS_TRACE_ID);
renameToElasticField(event, generator, SPAN_ID, ECS_SPAN_ID);
}
private static void renameToElasticField(ExtLogRecord event, JsonGenerator generator, String source, String ecsKey) throws IOException {
String value = event.getMdc(source);
if (value != null) {
event.removeMdc(source);
generator.writeStringField(ecsKey, value);
}
}
} |
indeed, that will work with the |
Oh sorry i didn't notice there were different, and yeah its confusing, you can't easily know what features are different between the two, i edited the comment, to clarify it. |
@troosan thank you for referencing relevant comments in the related pull request. They give great insights and a good workaround. @Malandril thank you for the proposed workaround! However I'd love to see this implemented in ´io.quarkus:quarkus-logging-json´, especially since the ECS log format is "officially supported" since Quarkus 3.17. |
I opened a PR on the quarkiverse version of quarkus-logging-json to support the logging of trace.id and span.id |
Description
Since 3.17, Quarkus supports the ECS log-format (introduced in #43232). For example by setting following property:
According to the ECS Tracing Field Details, expected fields are
span.id
,trace.id
, ...However AS-IS the
ecs
log-format still results in the nested MDC object:Furthermore, I currently don't see any way possible to get the log keys compliant to the "ECS Tracing Field Details" specs.
I tried with
quarkus.log.console.json.key-overrides=mdc.traceId=trace.id
, which results inIllegalArgumentException: No enum constant org.jboss.logmanager.formatters.StructuredFormatter.Key.MDC.TRACEID
Implementation ideas
In case the ecs log format is configured, by default use trace field logging keys as per ECS specification.
The text was updated successfully, but these errors were encountered: