5201 zio interceptor#5256
Open
cheleb wants to merge 20 commits into
Open
Conversation
Closed
cf38d4e to
8a517dd
Compare
3f0c8ad to
d9bdecd
Compare
d878a9b to
5acf9f7
Compare
5acf9f7 to
3c488ea
Compare
Member
|
Thanks - below a preliminary review by Claude: |
3c488ea to
6028487
Compare
Contributor
Author
Member
|
@cheleb Yes you're right, sorry. Claude also now agrees: |
Contributor
Author
|
I've addressed all the point exempt the #5 TBH no idea what/how to achieved this :-/ |
6507ace to
d3126b7
Compare
…treaming responses Refactor `handleRequest` in `ZIOpenTelemetryTracing` to properly manage span finalization, especially for streaming response bodies. The updated implementation: - Wraps `ZioStreamHttpResponseBody` with `ensuringWith` to ensure the span is finalized and errors are logged when the stream is consumed or fails. - Improves error handling for request decoding failures. - Decouples the span finalization logic from the main request handling flow to support different response types.
…sibility Refactor the `Logging` trait to allow overriding the log level and log endpoint via protected methods (`oltpLogLevel` and `otelLogEndpoint`) instead of directly accessing environment variables. This enables easier customization in subclasses.
…andling in tracing
…nd enhance tracing logic
…emetryTracingConfig
…c and improve logging
…nd tracing support - Introduced `zioOpenTelemetryBootstrap` project in build.sbt. - Created `ZIOpenTelemetryApp` and `ZIOpenTelemetryAppDefault` classes for OpenTelemetry integration. - Implemented logging, metrics, and tracing traits with default no-op implementations. - Added support for OTLP gRPC endpoints for logging, metrics, and tracing. - Added tests for the new bootstrap functionality.
… opentelemetry-api
…add bootstrap module
d3126b7 to
a7d31c9
Compare
…uding OtlpEnv, attributes, logging, metrics, and tracing 100% Opus 4.7
…Listener The interceptor previously pattern-matched the zio-http-specific ZioStreamHttpResponseBody (with an asInstanceOf) to defer span finalization until a streamed response body was sent, which coupled the published module to the zio-http backend (and to opentelemetry-metrics). Instead, finalize the span via the generic BodyListener.onComplete - the same mechanism MetricsEndpointInterceptor uses. The wiring moves into the endpoint interceptor (where the BodyListener is available); the span is now finalized once the response body has actually been fully sent, for any backend and any body type, and a failure while streaming the body is captured as a span error (previously only stream-level failures on the zio-http path were handled, and a streamed 5xx never set ERROR status). - build: the published module no longer depends on zioHttpServer or opentelemetryMetrics; it now depends on (zio, serverCore), with zioHttpServer kept as a test-only dependency to exercise a real streaming response body. Added the previously-transitive opentelemetry-semconv dependency explicitly. - tests: the mock streaming BodyListener now mirrors the production ZioHttpBodyListener (fires the callback when the stream is actually consumed/fails); the streaming-error test now asserts the span is ERROR. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…g cleanups - A RequestResult.Failure (unmatched / decode / auth failure) is no longer marked as a span error: it surfaces to the client as a 4xx, which per the OTel HTTP-server semantic conventions is not a server-span error. This also removes the inconsistency with the already-correct "4xx response is not an error" handling. Updated the decode-failure test accordingly. - Side-effecting OpenTelemetry calls (setStatus/setAllAttributes/updateName) now run in ZIO.attempt rather than ZIO.succeed, so a thrown exception is a typed failure instead of a defect; the span is finalized via .ensuring so a failing span mutation can never skip finalization. - Config cleanups: removed the dead Defaults.spanName and the stale @param spanName scaladoc; fixed doc typos (Otel4z -> ZIO OpenTelemetry, broken [[ZIOpenTelemetry]] link). - Bootstrap: the baseLogLayer scaladoc referenced a non-existent consoleLogLayer override; corrected to baseLogLayer. - Test: assert a successfully streamed response leaves the span status UNSET. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The docs referenced a non-existent `tapir-otel4z` artifact and claimed the module "uses the otel4s library under the hood" - it doesn't; it's built on zio-telemetry (dev.zio %% zio-opentelemetry), and otel4s is the unrelated Typelevel library behind the separate tapir-otel4s-* modules. Corrected to the real artifacts: tapir-zio-opentelemetry (the ZIOpenTelemetryTracing interceptor) and tapir-zio-opentelemetry-bootstrap (the ZIOpenTelemetryApp bootstrap + otel4z* layer helpers). Added a short usage snippet for the interceptor and dropped the link to the (unpublished) example. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Whaow, now I feel really dumb :p |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Provides ZIO OpenTelementry Tracing interceptor.
ZIO OpenTelemetry example with OpenTelemetry setup is provided with:
As ZIO OpenTelemetry provides them.