Skip to content

Commit 68ac1cd

Browse files
committed
.
1 parent 1e0edc8 commit 68ac1cd

File tree

1 file changed

+9
-54
lines changed

1 file changed

+9
-54
lines changed

docs/design/otlp.md

Lines changed: 9 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ OpenTelemetry Protocol (OTLP) is the vendor-agnostic wire format used by OpenTel
1212
* *JSON* (optional)
1313
* **Transports**
1414
* *gRPC* (default port `4317`)
15-
* *HTTP/1.1* (default port `4318`, binary protobuf or JSON payloads)
15+
* *HTTP/1.1*, *HTTP/2* (default port `4318`, binary protobuf or JSON payloads)
1616
* **Signals**
1717
* Traces, Metrics, Logs – transported independently but share common envelope (`Resource`, `Scope` etc.)
1818

@@ -58,10 +58,11 @@ src/
5858
| `trace` / `metrics` / `logs` | Enable signal exporters | `span.rs`, `metric.rs`, `logs.rs` |
5959
| `grpc-tonic` | Use `tonic` gRPC transport | `exporter/tonic` |
6060
| `http-proto` *(default)* | HTTP + protobuf body | `exporter/http` |
61-
| `http-json` | HTTP + JSON body | same as above |
62-
| `gzip-tonic` `zstd-tonic` | gRPC message compression | tonic layer |
63-
| `reqwest-client` / `reqwest-blocking-client` *(default)* | Choose async vs blocking HTTP client |
64-
| TLS helpers (`tls-roots`, `tls-webpki-roots`, `reqwest-rustls*`) | Supply trust roots for TLS |
61+
| `http-json` | HTTP + JSON body | `exporter/http` |
62+
| `gzip-tonic` `zstd-tonic` | gRPC message compression | `exporter/tonic` |
63+
| `reqwest-client` / `reqwest-blocking-client` *(default)* | Choose async vs blocking Reqwest HTTP client |
64+
| `hyper-client` | Use Hyper HTTP transport *(requires both Reqwest features disabled)* |
65+
| TLS helpers (`tls-roots`, `tls-webpki-roots`, `reqwest-rustls`) | Supply trust roots for TLS |
6566

6667
Because **only one transport is valid per exporter**, `protocol` is currently a *hint* – unsupported values are ignored by the concrete builder.
6768

@@ -96,7 +97,8 @@ sequenceDiagram
9697
Tx--)Exp: Future resolves
9798
Exp--)SDK: OTelSdkResult
9899
```
99-
Highlights:
100+
Notes:
101+
100102
* Serialization happens **inside the transport client** module to keep exporters thin.
101103
* `export` is `async` for `tonic` / `reqwest` clients, surfaced via `SpanExporter` implementing `opentelemetry_sdk::trace::SpanExporter`.
102104
* Resource attributes are injected once per exporter via `set_resource()` before first export.
@@ -119,51 +121,4 @@ Signal builders read **signal-specific env vars** (e.g. `OTEL_EXPORTER_OTLP_TRAC
119121
* Feature gating errors (compression requested w/o feature)
120122
* Runtime errors are wrapped in `OTelSdkError` from the SDK.
121123

122-
Design choice: **builder fails fast**, runtime exporter surfaces errors through `export()` future so processors can retry/back-off.
123-
124-
---
125-
126-
## 8. Extension & Customisation Points
127-
1. **Custom Headers / Metadata** – builder methods `.with_metadata(map)` (gRPC) or `.with_headers()` (HTTP).
128-
2. **Compression**`.with_compression(Compression::Gzip)` gated by feature.
129-
3. **TLS** – via `TonicConfig` or `HttpConfig` structs; TLS root features embed or load certs.
130-
4. **Alternate HTTP client**`reqwest-client` feature switches to async client; external crates could implement `OtlpHttpClient` trait in their own crate.
131-
5. **Protocol JSON** – toggle at build time; serializers for JSON/Protobuf share same data model structs.
132-
133-
---
134-
135-
## 9. Interactions with Other Exporters
136-
* **Prometheus exporter** (“pull” model) lives in its own crate and bypasses OTLP entirely.
137-
* **Jaeger / Zipkin** exporters are *alternative* “push” paths; users select exactly one per signal.
138-
* **stdout exporter** is often combined with OTLP in dev mode.
139-
* Sample configuration:
140-
```rust
141-
let otlp = SpanExporter::builder().with_tonic().build()?;
142-
let jaeger = opentelemetry_jaeger::new_agent_pipeline().install_simple()?;
143-
let provider = SdkTracerProvider::builder()
144-
.with_batch_exporter(otlp)
145-
.with_simple_exporter(jaeger)
146-
.build();
147-
```
148-
149-
---
150-
151-
## 10. Key Architectural Decisions
152-
| Decision | Rationale |
153-
|----------|-----------|
154-
| *Builder pattern with marker types* | Compile-time guarantee that a transport is selected exactly once. |
155-
| *Transport-specific modules* | Keep heavy deps (`tonic`, `reqwest`) behind feature gates to minimise compile times. |
156-
| *Env-vars override hierarchy* | Conforms to OTLP spec; simplifies Kubernetes/Docker deployments. |
157-
| *Separate crates per exporter* | Prevent dependency bloat for projects that only need a subset of signals/transports. |
158-
| *Non-exhaustive error enums* | Allow adding new failure modes without breaking semver. |
159-
160-
---
161-
162-
### Source References
163-
164-
* Builder traits – [`exporter/mod.rs`](../../opentelemetry-otlp/src/exporter/mod.rs)
165-
* HTTP transport – [`exporter/http/mod.rs`](../../opentelemetry-otlp/src/exporter/http/mod.rs)
166-
* gRPC transport – [`exporter/tonic/mod.rs`](../../opentelemetry-otlp/src/exporter/tonic/mod.rs)
167-
* Span exporter – [`span.rs`](../../opentelemetry-otlp/src/span.rs)
168-
* Metric exporter – [`metric.rs`](../../opentelemetry-otlp/src/metric.rs)
169-
* Logs exporter – [`logs.rs`](../../opentelemetry-otlp/src/logs.rs)
124+
Design choice: **builder fails fast**, runtime exporter surfaces errors through `

0 commit comments

Comments
 (0)