1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//! # tonic-debug
//!
//! A debugging and diagnostics middleware for [tonic](https://github.com/hyperium/tonic)
//! gRPC servers.
//!
//! ## Overview
//!
//! Debugging gRPC services built with tonic can be challenging — messages are
//! binary-encoded protobufs, connection issues are opaque, and the standard
//! logging often lacks the detail needed to quickly diagnose problems.
//!
//! `tonic-debug` solves this by providing:
//!
//! - **Human-readable protobuf inspection** — decodes protobuf wire format
//! without needing `.proto` schemas, showing field numbers, types, and values.
//! - **Connection lifecycle observability** — tracks connection events (connect,
//! disconnect, errors) with active/total counters via tower/hyper integration.
//! - **Structured logging via `tracing`** — all output goes through the
//! `tracing` crate with structured fields for easy filtering and aggregation.
//! - **Optional OpenTelemetry export** — enable the `opentelemetry` feature to
//! forward spans and attributes to your OTel collector.
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use tonic_debug::DebugLayer;
//!
//! // Add the debug layer to your tonic server
//! // tonic::transport::Server::builder()
//! // .layer(DebugLayer::new())
//! // .add_service(my_service)
//! // .serve(addr)
//! // .await?;
//! ```
//!
//! ## Configuration
//!
//! ```rust
//! use tonic_debug::{DebugLayer, DebugConfig};
//! use std::collections::HashSet;
//!
//! let layer = DebugLayer::with_config(DebugConfig {
//! log_headers: true,
//! log_bodies: true,
//! log_response_frames: true,
//! max_body_bytes: 8192,
//! hex_dump: false,
//! sensitive_headers: HashSet::new(),
//! reveal_sensitive_headers: false,
//! });
//! ```
//!
//! ## Connection Tracking
//!
//! ```rust
//! use tonic_debug::ConnectionMetrics;
//!
//! let metrics = ConnectionMetrics::new();
//! // Use metrics.active_connections(), metrics.total_connections(), etc.
//! ```
//!
//! ## Feature Flags
//!
//! | Feature | Description |
//! |----------------|--------------------------------------------------|
//! | `opentelemetry`| Adds OpenTelemetry span attributes and export |
// Re-export primary types for ergonomic usage.
pub use ;
pub use ;
pub use DebugService;