open-telemetry / open-telemetry/opentelemetry-java-instrumentation
Add try-catch logic for framework native instrumentation
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 1.2k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 228
Description
Is your feature request related to a problem? Please describe.
Some instrumentations in this project are implemented by registering callbacks/handlers through extension points provided by the native frameworks (e.g., OkHttp's Interceptor chain, Feign's RequestInterceptor, etc.) rather than by bytecode-level instrumentation of the target method directly.
In such cases, if the instrumentation code injected via these extension points does not have proper try-catch protection around the call to the actual framework logic (e.g., chain.proceed(request)), any unexpected exception may influent user's request.
In our distro, we met a such case recently, the related stack trace looks like below(The problem caused by our distro related logic):
Caused by: XXXXException
......
at io.opentelemetry.sdk.trace.MultiSpanProcessor.onEnd(MultiSpanProcessor.java:54)
t io.opentelemetry.sdk.trace.SdkSpan.endInternal(SdkSpan.java:570)
at io.opentelemetry.sdk.trace.SdkSpan.end(SdkSpan.java:539)
at io.opentelemetry.javaagent.shaded.instrumentation.api.instrumenter.Instrumenter.doEnd(Instrumenter.java:309)
at io.opentelemetry.javaagent.shaded.instrumentation.api.instrumenter.Instrumenter.end(Instrumenter.java:166)
at io.opentelemetry.javaagent.shaded.instrumentation.okhttp.v3_0.internal.TracingInterceptor.intercept(TracingInterceptor.java:51)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:43)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
Describe the solution you'd like
Add proper try-catch in common place in order to avoid any exception thrown from within the native extension point callback
Describe alternatives you've considered
No response
Additional context
No response
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the shared handling for native framework extension-point callbacks, including the OkHttp TracingInterceptor and analogous Feign RequestInterceptor paths mentioned in the issue. Compare how these callbacks invoke framework logic and determine how completion should be verified without allowing instrumentation exceptions to affect user requests; the issue provides no test file or entry point.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100