azure-functions-java-opentelemetry:1.1.0 swallows function exceptions, causing Service Bus messages to be completed instead of retried
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
- 79/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- azure, java
- Lĩnh vực
- backend, distributed-systems
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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?
- Ngôn ngữ chính
- Java
- Star
- 4
- Fork
- 22
- Merge trung bình
- 1 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Azure/azure-functions-java-additions
-
OTel Java agent does not appear to load in Function Worker under the Flex Consumption hosting planĐang mởarea:java-functions
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Migrate to Junit5Đang mởarea:java-functions
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
-
Separate class to another artifact not used by function customerCó thể làm lại được @kaibocai đã nhận 1527 ngày trước và không có pull request nào đang mở. Đang mởarea:java-functions
Azure/azure-functions-java-additions#12 · 1 bình luận · 1 người được giao ·
Tất cả issue của Azure/azure-functions-java-additions
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
finos/rune-common#819 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue storege-module
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
sdlc-pro/spring-lens#647 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
lang-java needs-triage package:jni package:jni_flutter package:jnigen
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
valkey-io/valkey-glide#7975 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày