Add auto-instrumentation for Spring MVC handler and @Transactional spans (like Datadog agent)
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 领域
- backend, observability
调研方向
首先检查 issue 中提到的 Spring MVC 和 Spring 事务集成点,尤其是 HandlerAdapter.handle() 和 TransactionInterceptor.invoke(),并将其与上游的 OpenTelemetry Spring MVC instrumentation module 进行比较。完成标准是 Java agent 创建带有控制器或服务方法上下文的 spring.handler 和 spring.transaction span,并在不修改应用程序的情况下保留所需的从请求到数据库的 waterfall。
由索引模型根据 Issue 内容生成。
描述
Is your feature request related to a problem? Please describe.
When using the Application Insights Java agent (3.7.x) with a Spring Boot application, the transaction waterfall only shows auto-instrumented external calls (JDBC, HTTP clients) but not the internal Spring
framework flow.
The Datadog Java agent, by comparison, automatically creates spans for Spring framework integration points via bytecode instrumentation, producing a detailed waterfall without any code change:
servlet.request (incoming HTTP)
└─ spring.handler (controller method)
└─ spring.transaction (@Transactional service method)
└─ jdbc.query (SQL query via repository)
└─ postgresql.query (driver-level execution)
This is achieved because the Datadog agent instruments Spring MVC handler dispatch and Spring @Transactional boundaries automatically — not every bean method, but the key framework integration points that
give full visibility into the request lifecycle.
With the Application Insights agent, the same request only shows:
GET /api/v1/threads/{id}/messages (request)
└─ SELECT ... FROM message (JDBC)
└─ POST https://openai.azure.com (HTTP)
The entire controller-to-service layer is invisible, making it difficult to identify which business logic step is slow or failing.
Describe the solution you would like
Auto-instrument Spring framework integration points that the Datadog agent already covers, specifically:
- spring.handler — Spring MVC handler method dispatch (the controller method matched by @RequestMapping / @GetMapping / etc.). This span should include the controller class and method name.
- spring.transaction — Spring @Transactional boundaries. This would capture the service-layer method wrapped in a transaction, providing the controller → service link in the waterfall.
These are not arbitrary application methods — they are well-defined framework extension points where Spring already has interceptor/advice infrastructure. The agent could instrument HandlerAdapter.handle()
and TransactionInterceptor.invoke() at the bytecode level, just as it already does for JDBC and HTTP clients.
This would produce the same waterfall visibility that Datadog users get out of the box, without requiring any application code changes, @WithSpan annotations, or customInstrumentation configuration.
Describe alternatives you have considered
- customInstrumentation in applicationinsights.json: Requires listing every class and method individually. Does not scale, is fragile to maintain, and new methods are silently missed. No wildcard or pattern
support is available. - @WithSpan annotations: Requires modifying application code, adds a dependency on opentelemetry-instrumentation-annotations, and must be manually added to every relevant method.
- Spring AOP aspect with ObservationRegistry: A custom @Aspect that wraps all Spring bean methods in Micrometer Observations (bridged to OTel spans via micrometer-tracing-bridge-otel). This works but
requires application-side code, adds spring-boot-starter-aop as a dependency, and introduces AOP proxy overhead. It also instruments more than necessary (every public bean method) since there is no way to
target just framework integration points. - OpenTelemetry Java agent extensions (ByteBuddy): Building a custom InstrumentationModule targeting Spring MVC and Spring TX. However, the Application Insights documentation does not guarantee compatibility
with custom agent extensions.
Additional context
The Datadog Java agent achieves this by instrumenting specific Spring framework classes at the bytecode level:
- HandlerAdapter / DispatcherServlet for spring.handler spans
- PlatformTransactionManager / TransactionInterceptor for spring.transaction spans
These are stable Spring APIs that rarely change between versions. The OpenTelemetry upstream agent already instruments Spring MVC handlers (via spring-webmvc instrumentation module), so the foundation exists
in the OTel ecosystem — it may just need to be enabled or surfaced in the Application Insights distribution.
- 主要语言
- Java
- 星标
- 327
- 派生
- 222
- 平均合并
- 1 天 3 小时
- 30 天内合并 PR
- 12
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/ApplicationInsights-Java 的其他 Issue
-
Java 25 native-access warning from bundled Netty requires broad ALL-UNNAMED permission可能已有人在做 @rajkumar-rangaraj 于 15 天前认领。 未关闭
microsoft/ApplicationInsights-Java#4851 · 已指派 1 人 ·
维护者通常 2 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
microsoft/ApplicationInsights-Java#4817 · 1 条评论 ·
维护者通常 2 天内回复
-
难度 4/5 3-5 天 新手友好度 42/100
microsoft/ApplicationInsights-Java#4770 · 2 条评论 ·
维护者通常 2 天内回复
-
难度 5/5 一周以上 新手友好度 30/100
microsoft/ApplicationInsights-Java#4769 · 2 条评论 ·
维护者通常 2 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
microsoft/ApplicationInsights-Java#4729 · 130 条评论 ·
维护者通常 2 天内回复
查看 microsoft/ApplicationInsights-Java 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
apache/rocketmq-dashboard#5358 ·
维护者通常 3 天内回复
-
area:cpan-port area:database bug
难度 2/5 1-3 小时 新手友好度 84/100
fglock/PerlOnJava#1605 ·
维护者通常 1 天内回复
-
1.0.0-rc2
难度 2/5 1-3 小时 新手友好度 68/100
wso2/dpdp-accelerator#377 ·
维护者通常 1 天内回复
-
area/dependencies backport/26.4 kind/cve severity/high source/scan-dependencies status/triage
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复