microsoft / ApplicationInsights-Java

Application Insights for Java
http://aka.ms/application-insights
Other
296 stars 199 forks source link

Unable to see MDC properties in App Insights via Function App #2904

Closed mikeliucc closed 1 year ago

mikeliucc commented 1 year ago

Expected behavior

Based on the various docs on Microsoft Learn, I'm under the understanding that MDC properties can be captured under customDimensions in the traces table. However, so far I am only able to capture log messages (in message field). Can't find the MDC properties anywhere... Please help!

Actual behavior

No MDC properties are captured (AFAIK)

To Reproduce

We are using Java 8 to create our Function Apps. Here's our stack:

Sample Application

In our function app, the code looks something like this:

Logger logger = LogFactory.getLogger(getClass()); ... MDC.put("search.result", ...); MDC.put("client.group", ...); ... loggger.info("Client requesting product search {} with {} ...", searchParam, clientContext);

System information

Please provide the following information:

Hoping for any suggestions you might have... Thanks in advance!

Logs

Turn on SDK logs and attach/paste them to the issue. If using an application server, also attach any relevant server logs.

Be sure to remove any private information from the logs before posting!

Screenshots

If applicable, add screenshots to help explain your problem.

mikeliucc commented 1 year ago

Tagging @trask ... hoping you can provide some insights here (puns intended). Thanks!

trask commented 1 year ago

hi @mikeliucc! what does the sdkVersion column report on those trace records?

trask commented 1 year ago

we just released a new Public Preview of Application Insights Java agent integration into Azure Functions, can you try this (instead of attaching the Java agent yourself)?

I tested MDC yesterday using this route and it worked for me: https://github.com/trask/azure-functions-logback-mdc-example

mikeliucc commented 1 year ago

Hot cakes - That worked beautifully!!

image

Thank you so much!