Azure / azure-sdk-for-js

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.
MIT License
1.98k stars 1.15k forks source link

[@azure/monitor-opentelemetry-exporter] Problem with SEMATTRS_ENDUSER_ID on backend, it didnt show in Application Insights as User Id properly. #29182

Open CrazyBaran opened 2 months ago

CrazyBaran commented 2 months ago

Describe the bug I setup in span atributes: span.attributes[SEMATTRS_ENDUSER_ID] = 'test';, but on Application Insights I got enduser.id in Custom Properties not in Request Properties as User ID as it is on browser with application insight SDK. In my opinion this code line should do that, but it didnt work: https://github.com/Azure/azure-sdk-for-js/blob/8d1d94acaea0ea6559a82a956d7c4fe95c0a7f86/sdk/monitor/monitor-opentelemetry-exporter/src/utils/spanUtils.ts#L64 Maybe it is related to https://github.com/Azure/azure-sdk-for-js/pull/28965 ?

Expected behavior When using SEMATTRS_ENDUSER_ID value should go to Request, Internal, etc properties as User Id, not to Custom Properties as enduser.id Additionally in my opinion it should show up as Authenticated User Id as description of SEMATTRS_ENDUSER_ID say: "Username or client_id extracted from the access token or Authorization header in the inbound request from outside the system."

Screenshots Code: image As is from OpenTelemetry from nodejs backend: image As is from Angular SPA from browser with use of ApplicationInsights JS SDK: image

Additional Context In docs it is also mention this way. Docs are little outdated as SemanticAttributes are deprecated to consts. https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-add-modify?tabs=nodejs#set-the-user-id-or-authenticated-user-id

JacksonWeber commented 2 months ago

Hi @CrazyBaran thank you for filing this issue. We plan to address this inconsistency soon and will link to this issue once the appropriate PR is up.

CrazyBaran commented 2 months ago

@JacksonWeber My main problem was that ai.user.id is not showing up in application insights. This inconsistency is some minor issue.

JacksonWeber commented 2 months ago

@CrazyBaran Ah, I see. Yes, this issue will be resolved by #28965 as it provides support for the User Id property.

JacksonWeber commented 3 weeks ago

@CrazyBaran Please let me know if the above PR resolved the issue for you, and let me know if you have any other issues!

github-actions[bot] commented 3 weeks ago

Hi @CrazyBaran. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

github-actions[bot] commented 2 weeks ago

Hi @CrazyBaran, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

CrazyBaran commented 2 weeks ago

@JacksonWeber Hey, right now it is working like expected. User showing in App Insight. Still in my opinion should be other semantic key (SEMATTRS_ENDUSER_ID), but this is small thing.