Skip to content

Add OTel Logging Middleware - #211

Open
bauer-andreas wants to merge 5 commits into
mainfrom
andreas-bauer/logging-middleware
Open

bauer-andreas wants to merge 5 commits into
mainfrom
andreas-bauer/logging-middleware

Conversation

@bauer-andreas

Copy link
Copy Markdown

Motivation

Instrumentation support varies based on the transport. Especially current Client Transport lack any sort of middleware. Therefore, it is useful to leverage the OpenAPI middleware system to provide constant emission of telemetry across client and server transports. The Open Telemetry Semantic Conventions is a widely established convention for metadata emission.

Modifications

  • Add a new ClientOTelLoggingMiddleware and ServerOTelLoggingMiddleware following Open Telemetry Semantic Conventions for HTTP
  • Introduce a new default-enabled Logging and OTelSemanticConvention trait that guards the two new dependencies on swift-log and swift-otel-semantic-conventions.

Result

Consistent request and response logging across server and client implementations following OTel Semantic Conventions.

Test Plan

Added two new unit test suites that exercise both of the middleware using an in-memory logger that is injected via the new TaskLocal Logger form swift-log.

…ndencies.

The new middleware features are gated behind two new traits for Logging and OTelSemanticConventions
@bauer-andreas bauer-andreas added the 🆕 semver/minor Adds new public API. label Sep 18, 2026
@bauer-andreas
bauer-andreas force-pushed the andreas-bauer/logging-middleware branch from 1c6ec82 to e6cf52f Compare September 18, 2026 11:42
@bauer-andreas bauer-andreas changed the title Andreas bauer/logging middleware Add OTel Logging Middleware Sep 18, 2026
@czechboy0

Copy link
Copy Markdown
Contributor

This is great, @bauer-andreas! I've wanted us to have telemetry middlewares built-in, so thanks for getting this started.

Since this has a pretty large API surface, and there are various smaller decisions that would benefit from more discussion, would you be open to writing up a proposal? We don't normally accept non-trivial new API without one. 🙏

@czechboy0 czechboy0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking as needs-work for now, as we'll need to run a proposal for this first.

@czechboy0

Copy link
Copy Markdown
Contributor

Also cc @simonjbeaumont and @slashmo for visibility and additional thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants