Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

User_id column empty in Application Insights logs

Đang mở
#4,578 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
azure, java, spring-boot
Lĩnh vực
backend, observability

Hướng nghiên cứu

So sánh thiết lập 2.6.4 Spring Boot starter/logback với thiết lập 3.7.2 web/runtime-attach, bắt đầu từ ApplicationInsights.attach(), SpringApplication.run() và user-id setter của RequestTelemetryContext được nêu trong issue. Xác minh cách user_id được truyền vào các trace so với giao dịch end-to-end, sau đó ghi lại cấu hình hoặc thay đổi được hỗ trợ để khôi phục nó trong trace logs.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Java
Star
326
Fork
223
Merge trung bình
1 ngày 1 giờ
Pull request đã merge (30 ngày)
15

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/ApplicationInsights-Java

Tất cả issue của microsoft/ApplicationInsights-Java

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.