Skip to content
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

Unable to propagate UserId via MDC #3254

Open
MatthiasMpo opened this issue Aug 17, 2023 · 4 comments
Open

Unable to propagate UserId via MDC #3254

MatthiasMpo opened this issue Aug 17, 2023 · 4 comments

Comments

@MatthiasMpo
Copy link

Expected behavior

When I insert the userId into the logging context via MDC, I would expect that it would be mapped correctly.

Actual behavior

UserId is only visible as custom properties.

To Reproduce

// does not work
MDC.put("enduser.id", userId)
// does work
Span.current().setAttribute("enduser.id", userId)

System information

Please provide the following information:

  • SDK Version: 3.4.15
  • OS type and version: Windows
  • Application Server type and version (if applicable):
  • Using spring-boot? Yes (3.1.2)
  • Additional relevant libraries (with version, if applicable):

image

@trask
Copy link
Member

trask commented Aug 18, 2023

hi @MatthiasMpo! MDC only applies to logs

@MatthiasMpo
Copy link
Author

hi @MatthiasMpo! MDC only applies to logs

Hi @trask, maybe I was not clear. I set enduser.id via MDC and Span Attribute.
After that only my requests and Dependencies had the correct user. Traces did not.
I would expect that the MDC properties are also able to map to Application Insights "default" properties.
Or is there another way to set the User Id for Traces in Java? In all my dotnet application it works via ITelemetryInitializer.

@trask
Copy link
Member

trask commented Aug 23, 2023

does this work for other MDC attributes, e.g. xyz? just trying to understand if it's something specific to enduser.id or not, thx

@MatthiasMpo
Copy link
Author

I also tried it with user_agent.original (SemanticConventions). It was respected in Request via Span, but not with MDC. If I use xyz I see in traces and request xyz as customDimensions.

I found enduser.id in the Microsoft Docu for Application Insights in Java: https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-add-modify?tabs=java#set-the-user-id-or-authenticated-user-id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants