Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

User_id column empty in Application Insights logs

Open
#4,578 3 comments 0 reactions 0 assignees View on GitHub

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

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):

Image

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/ApplicationInsights-Java

All issues in microsoft/ApplicationInsights-Java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.