Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions opentelemetry-instrumentation-tower/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

## vNext

### Changed

* Added OpenTelemetry trace support
9 changes: 7 additions & 2 deletions opentelemetry-instrumentation-tower/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ rust-version = "1.75.0"

version = "0.16.0"
license = "Apache-2.0"
description = "OpenTelemetry Metrics Middleware for Tower-compatible Rust HTTP servers"
description = "OpenTelemetry Metrics and Tracing Middleware for Tower-compatible Rust HTTP servers"
homepage = "https://github.com/open-telemetry/opentelemetry-rust-contrib"
repository = "https://github.com/open-telemetry/opentelemetry-rust-contrib"
documentation = "https://docs.rs/tower-otel-http-metrics"
Expand All @@ -21,12 +21,17 @@ axum = { features = ["matched-path", "macros"], version = "0.8", default-feature
futures-util = { version = "0.3", default-features = false }
http = { version = "1", features = ["std"], default-features = false }
http-body = { version = "1", default-features = false }
opentelemetry = { workspace = true, features = ["futures", "metrics"]}
opentelemetry = { workspace = true, features = ["futures", "metrics", "trace"] }
opentelemetry-semantic-conventions = { workspace = true, features = ["semconv_experimental"] }
pin-project-lite = { version = "0.2", default-features = false }
tower-service = { version = "0.3", default-features = false }
tower-layer = { version = "0.3", default-features = false }

[dev-dependencies]
tokio = { version = "1" }
tower = { version = "0.3" }
tower-test = { version = "0.3" }
opentelemetry_sdk = { workspace = true, features = ["testing"] }

[lints]
workspace = true
36 changes: 34 additions & 2 deletions opentelemetry-instrumentation-tower/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
# Tower OTEL Metrics Middleware
# Tower OTEL HTTP Instrumentation Middleware

OpenTelemetry Metrics Middleware for Tower-compatible Rust HTTP servers.
OpenTelemetry HTTP Metrics and Tracing Middleware for Tower-compatible Rust HTTP servers.

This middleware provides both metrics and distributed tracing for HTTP requests, following OpenTelemetry semantic conventions.

## Features

- **HTTP Metrics**: Request duration, active requests, request/response body sizes
- **Distributed Tracing**: HTTP spans with semantic attributes
- **Semantic Conventions**: Uses OpenTelemetry semantic conventions for consistent attribute naming
- **Flexible Configuration**: Support for custom attribute extractors and tracer configuration
- **Framework Support**: Works with any Tower-compatible HTTP framework (Axum, Hyper, Tonic etc.)

## Usage

## Metrics

The middleware exports the following metrics:

- `http.server.request.duration` - Duration of HTTP requests
- `http.server.active_requests` - Number of active HTTP requests
- `http.server.request.body.size` - Size of HTTP request bodies
- `http.server.response.body.size` - Size of HTTP response bodies

## Tracing

HTTP spans are created with the following attributes (following OpenTelemetry semantic conventions):

- `http.request.method` - HTTP method
- `url.scheme` - URL scheme (http/https)
- `url.path` - Request path
- `url.full` - Full URL
- `user_agent.original` - User agent string
- `http.response.status_code` - HTTP response status code

## Examples

Expand Down
Loading
Loading