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
Describe the bug
When the property enable_log_correlation is configured with true value in the apm agent (for Java), traceId and transactionId are inserted in MDC and these values are written in log registries, but when you call a RestTemplate the next logs doesn't print the MDC values (traceId and transactionId).
To Reproduce
Configure APM Agent with the following params (used in Eclipse IDE)
I think the problem is that we insert the properties properly to MDC when creating the transaction. Later, when RestTemplate is invoked we create a span and activate it, then when we deactivate it, we remove the properties from MDC, but since we are using same property names, the properties are no longer set in MDC after RestTemplate span is deactivated.
I will try to prepare a quick fix and provide a test build.
Describe the bug
When the property enable_log_correlation is configured with true value in the apm agent (for Java), traceId and transactionId are inserted in MDC and these values are written in log registries, but when you call a RestTemplate the next logs doesn't print the MDC values (traceId and transactionId).
To Reproduce
-javaagent:${workspace_loc:elastic_apm_micros_spring2}/configuration/apm/elastic-apm-agent-1.4.0.jar
-Delastic.apm.service_name=bankservice
-Delastic.apm.service_version=1.0.0
-Delastic.apm.environment=dev
-Delastic.apm.sanitize_field_names=pass*,pwd*
-Delastic.apm.capture_headers=true
-Delastic.apm.enable_log_correlation=true
-Delastic.apm.application_packages=org.jrovira.blog.apm
-Delastic.apm.server_urls=http://localhost:8200
@PostMapping("/account")
public ResponseEntity processAccount(@RequestParam String name, @RequestParam String nif) {
LOGGER.info("test1");
restTemplate.getForEntity(riskUrl, Boolean.class, nif);
LOGGER.info("test2");
}
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<includeCallerData>false</includeCallerData>
<includeContext>false</includeContext>
<shortenedLoggerNameLength>36</shortenedLoggerNameLength>
<customFields>
{
"micro_name": "${microName}"
}
</customFields>
</encoder>
</appender>
The console output
{...,"message":"test1",...,"transaction.id":"612a533941b93965","trace.id":"484302c7d391d4df487d39e238ded4b1",...}
{...,"message":"test2",...}
in the second log doesn't appear the transaction.id and trace.id fields.
Expected behavior
The second log should be
{...,"message":"test2",...,"transaction.id":"612a533941b93965","trace.id":"484302c7d391d4df487d39e238ded4b1",...}
The complete source code of my app is in https://bitbucket.org/jrovirablog/elastic_apm_micros_spring2/commits/f4fe94b424abe3ee416816893e4d8e5a1c6e583e
Thanks for all.
The text was updated successfully, but these errors were encountered: