User_id column empty in Application Insights logs
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- azure, java, spring-boot
- Domain
- backend, observability
Research direction
Compare the 2.6.4 Spring Boot starter/logback setup with the 3.7.2 web/runtime-attach setup, starting at ApplicationInsights.attach(), SpringApplication.run(), and the RequestTelemetryContext user-id setter shown in the issue. Verify how user_id is propagated to traces versus the end-to-end transaction, then document the supported configuration or change that restores it in trace logs.
Written by the indexing model from the issue text.
Description
Hello,
I inherited a Spring boot application, which uses Application Insights.
Originally, the following maven packages were used:
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-spring-boot-starter</artifactId>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-logging-logback</artifactId>
<version>2.6.4</version>
</dependency>
The user_id was set as follows:
RequestTelemetry requestTelemetry = ThreadContext.getRequestTelemetryContext().getHttpRequestTelemetry();
requestTelemetry.getContext().getUser().setId(email);
Using the setup above, I was able to check traces in the logs, and filter on user (user_id column):
I've since upgraded to the 3.X SDK, using the following:
- Maven packages:
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-web</artifactId>
<version>3.7.2</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-runtime-attach</artifactId>
<version>3.7.2</version>
</dependency>
- Initialize telemetry:
public static void main(String[] args) {
ApplicationInsights.attach();
SpringApplication.run(MsPlanningApplication.class, args);
}
- Set user id:
RequestTelemetryContext requestTelemetryContext = ThreadContext.getRequestTelemetryContext();
if (requestTelemetryContext != null) {
RequestTelemetry requestTelemetry = requestTelemetryContext.getHttpRequestTelemetry();
requestTelemetry.getContext().getUser().setId(email);
}
However, since the upgrade to SDK 3.X, the user_id column is empty (the messages/errors are logged just fine). When I check the end-to-end transaction, I do see my user_id.
So, why am I not seeing the user_id in my traces (when checking the logs)?
- Dominant language
- Java
- Stars
- 327
- Forks
- 222
- Avg merge
- 22h 34m
- Merged PRs (30d)
- 14
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/ApplicationInsights-Java
-
microsoft/ApplicationInsights-Java#4851 · 1 assignee ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
microsoft/ApplicationInsights-Java#4817 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
microsoft/ApplicationInsights-Java#4770 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
microsoft/ApplicationInsights-Java#4769 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
microsoft/ApplicationInsights-Java#4729 · 121 comments ·
All issues in microsoft/ApplicationInsights-Java
Similar issues
-
certification
Difficulty 1/5 Under an hour Newbie friendliness 80/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
[BUG] ECR GetAuthorizationToken returns a proxyEndpoint for the default region, not the request's Openbug ecr
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Needs: Triage Type: Feature request
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
AntennaPod/AntennaPod#8794 ·
-
agentic-workflows
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
github/copilot-sdk#2760 ·