azure-functions-java-opentelemetry:1.1.0 swallows function exceptions, causing Service Bus messages to be completed instead of retried
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 79/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- azure, java
调研方向
Start by reading OpenTelemetryInvocationMiddleware.java and trace how invoke() handles telemetry setup failures versus exceptions from chain.doNext(context). Then inspect the middleware tests and add the suggested regression case with an iterator-backed chain, confirming the business exception reaches the caller. Done means downstream execution occurs once and its failure is not swallowed or replaced.
由索引模型根据 Issue 内容生成。
描述
Summary
With com.microsoft.azure.functions:azure-functions-java-opentelemetry:1.1.0 enabled, a Java Azure Function triggered by a Service Bus topic subscription reports Succeeded even when the function throws an exception.
Consequently, the failed message is completed rather than retried and never reaches the subscription’s dead-letter queue.
Removing the dependency restores the expected behavior: failed invocations, retries, and eventual dead-lettering.
Environment
Java: 17
Azure Functions Java Gradle plugin: 1.17.0
Azure Functions extension bundle: [4.*, 5.0.0)
Spring Boot: 3.5.6
azure-functions-java-opentelemetry: 1.1.0
opentelemetry-api: 1.49.0
Trigger: Service Bus topic subscription
Observed during local execution on Windows using Azure Functions Core Tools
Application Insights Java agent enabled
Steps to reproduce
Configure a Java Azure Function with a Service Bus topic trigger.
Include azure-functions-java-opentelemetry:1.1.0 and configure the telemetry agent.
Make the function synchronously throw a RuntimeException during message processing.
Send a test message to the topic.
Observe the function execution result and subscription delivery behavior.
Remove the telemetry integration dependency, clean-build, repackage, restart, and repeat with a new test message.
Expected behavior
The exception should propagate to the Java worker:
The invocation should be reported as Failed.
The message should be redelivered according to Service Bus delivery semantics.
Repeated processing failures should eventually move it to the subscription DLQ after exceeding MaxDeliveryCount.
Telemetry instrumentation should not change the function’s success/failure outcome.
Actual behavior
With the dependency enabled, the application logs a processing failure and rethrows the exception, but the host reports:
Executed 'Functions.ForgetUser'
(Succeeded, Id=822181d0-a0e0-40ee-aa1e-f8cba1408ed5, Duration=917ms)
No subsequent delivery was observed for that message, and it did not appear in the DLQ.
After removing the telemetry dependencies and rebuilding, retries and eventual dead-lettering worked.
Suspected root cause
In OpenTelemetryInvocationMiddleware.invoke():
chain.doNext(context) executes the function.
An inner catch (Throwable) records the exception, marks the span as failed, and rethrows it.
The outer catch (Exception spanCreationException) also catches this business-processing exception.
Instead of propagating it, the outer catch calls chain.doNext(context) again.
The Java worker’s InvocationChain uses an iterator. Once the downstream middleware has been consumed, the second doNext() call returns without invoking anything or rethrowing the original exception.
The middleware therefore returns normally, causing the invocation to be reported as successful.
Source: OpenTelemetryInvocationMiddleware.java
Impact
This can cause failed business processing to be silently acknowledged. Service Bus retries and dead-letter handling are bypassed, potentially leaving work permanently unprocessed unless messages can be replayed independently.
Suggested fix
Separate telemetry initialization failure handling from downstream function execution:
Invoke the downstream chain exactly once.
Always propagate exceptions from downstream execution.
Ensure failures while recording exceptions or closing spans do not suppress or replace the original processing exception.
Add a regression test using an iterator-backed middleware chain that verifies a thrown business exception reaches the caller.
Request
Could the maintainers confirm this defect and advise whether a patch release or supported workaround is planned?
- 主要语言
- Java
- 星标
- 4
- 派生
- 22
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Azure/azure-functions-java-additions 的其他 Issue
-
OTel Java agent does not appear to load in Function Worker under the Flex Consumption hosting plan未关闭area:java-functions
难度 4/5 3-5 天 新手友好度 35/100
-
area:java-functions
难度 4/5 3-5 天 新手友好度 25/100
-
Separate class to another artifact not used by function customer可能重新可做 @kaibocai 于 1527 天前认领,目前没有进行中的 PR。 未关闭area:java-functions
Azure/azure-functions-java-additions#12 · 1 条评论 · 已指派 1 人 ·
查看 Azure/azure-functions-java-additions 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
finos/rune-common#819 ·
维护者通常 1 天内回复
-
enhancement good first issue storege-module
难度 2/5 1-3 小时 新手友好度 76/100
sdlc-pro/spring-lens#647 ·
维护者通常 1 天内回复
-
lang-java needs-triage package:jni package:jni_flutter package:jnigen
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 83/100
valkey-io/valkey-glide#7975 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复