Skip to content

How to add custom dimensions to a trace #1771

Closed
@martijnburgers

Description

@martijnburgers

I am running a Java Quarkus application with applicationinsights-agent-3.1.1.jar .

The applications logs in json format

{"timestamp":"2021-06-26T20:50:58.833+02:00","sequence":1440,"loggerClassName":"org.jboss.logging.Logger","loggerName":"io.quarkus","level":"INFO","message":"someservice.service 1.0.0-SNAPSHOT on JVM (powered by Quarkus 1.13.7.Final) started in 8.270s. Listening on: http://localhost:8080","threadName":"Quarkus Main Thread","threadId":95,"hostName":"someHostName","processName":"someservice.service-dev.jar","processId":91912}
{"timestamp":"2021-06-26T20:50:58.844+02:00","sequence":1441,"loggerClassName":"org.jboss.logging.Logger","loggerName":"io.quarkus","level":"INFO","message":"Profile dev activated. Live Coding activated.","threadName":"Quarkus Main Thread","threadId":95,"hostName":"someHostName","processName":"someservice.service-dev.jar","processId":91912}
{"timestamp":"2021-06-26T20:50:58.844+02:00","sequence":1442,"loggerClassName":"org.jboss.logging.Logger","loggerName":"io.quarkus","level":"INFO","message":"Installed features: [cdi, mutiny, quarkiverse-logging-json, resteasy, resteasy-jackson, resteasy-jaxb, resteasy-multipart, resteasy-mutiny, smallrye-context-propagation, smallrye-openapi, swagger-ui]","threadName":"Quarkus Main Thread","threadId":95,"hostName":"someHostName","processName":"someservice.service-dev.jar","processId":91912}
{"timestamp":"2021-06-26T20:56:09.483+02:00","sequence":1446,"loggerClassName":"org.slf4j.impl.Slf4jLogger","loggerName":"nl.somecompany.someService.service.Service","level":"INFO","message":"rocess incoming request","threadName":"executor-thread-1","threadId":101,"ndc":"f45a16d5-6c16-4040-92a5-0b8388752823","hostName":"someHostName","processName":"someService.service-dev.jar","processId":91912,"properties":{"requestId":"f45a16d5-6c16-4040-92a5-0b8388752823","scenarioName":null}}

The last line also includes custom properties created with the following line of code:

logger.info("Process incoming request", kv("properties", context));

Application Insights shows every log line (trace) as shown above but the customDimensions never include the custom properties. It only shows:

LoggerName
nl.somecompany.someservice.service.someservice

LoggingLevel
INFO

SourceType
Logger

How can we add custom dimensions to application insights from Java logging?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions