Skip to content

Commit 3261cf7

Browse files
authored
docs: dedicated tracing.md (#172)
1 parent c20ca3a commit 3261cf7

File tree

3 files changed

+50
-15
lines changed

3 files changed

+50
-15
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ possible to dynamically modify the logging at runtime.
142142
- `http://$RAINBOW_CTL_LISTEN_ADDRESS/mgr/log/level?subsystem=<system name or * for all system>&level=<level>` will set the logging level for a subsystem
143143
- `http://$RAINBOW_CTL_LISTEN_ADDRESS/mgr/log/ls` will return a comma separated list of available logging subsystems
144144

145+
## Tracing
146+
147+
See [docs/tracing.md](docs/tracing.md).
148+
145149
## Deployment
146150

147151
Suggested method for self-hosting is to run a [prebuilt Docker image](#docker).

docs/environment-variables.md

+5-15
Original file line numberDiff line numberDiff line change
@@ -300,30 +300,20 @@ Etag: "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am"
300300

301301
## Tracing
302302

303-
Tracing across the stack follows, as much as possible, the [Open Telemetry]
304-
specifications. Configuration environment variables are specified in the
305-
[OpenTelemetry Environment Variable Specification] where possible. The
306-
[Boxo Tracing] documentation is the basis for tracing here.
307-
308-
A major distinction from the more general tracing enabled in boxo is that when
309-
tracing is enabled it is restricted to flows through HTTP Gateway requests, rather
310-
than also included background processes.
311-
312-
Note: requests are also traced when there is a `Traceparent` header passed that is valid
313-
According to the [Trace Context] specification, even if the sampling fraction is set to 0.
303+
See [tracing.md](tracing.md).
314304

315305
### `RAINBOW_TRACING_AUTH`
316306

307+
Optional, setting to non-empty value enables on-demand tracing per-request.
308+
317309
The ability to pass `Traceparent` or `Tracestate` headers is guarded by an
318310
`Authorization` header. The value of the `Authorization` header should match
319311
the value in the `RAINBOW_TRACING_AUTH` environment variable.
320312

321313
### `RAINBOW_SAMPLING_FRACTION`
322314

315+
Optional, set to 0 by default.
316+
323317
The fraction (between 0 and 1) of requests that should be sampled.
324318
This is calculated independently of any Traceparent based sampling.
325319

326-
[Boxo Tracing]: https://github.com/ipfs/boxo/blob/main/docs/tracing.md
327-
[Open Telemetry]: https://opentelemetry.io/
328-
[OpenTelemetry Environment Variable Specification]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md
329-
[Trace Context]: https://www.w3.org/TR/trace-context

docs/tracing.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## Tracing
2+
3+
Tracing across the stack follows, as much as possible, the [Open Telemetry]
4+
specifications. Configuration environment variables are specified in the
5+
[OpenTelemetry Environment Variable Specification] where possible. The
6+
[Boxo Tracing] documentation is the basis for tracing here.
7+
8+
> [!NOTE]
9+
> A major distinction from the more [general tracing enabled in boxo][Boxo Tracing] is that when
10+
> tracing is enabled it is restricted to flows through HTTP Gateway requests, rather
11+
> than also included background processes.
12+
13+
### Fractional Sampling
14+
15+
To sample a % of requests set [`RAINBOW_SAMPLING_FRACTION`](environment-variables.md#rainbow_sampling_fraction) to a value between `0` and `1`.
16+
17+
### Per Request
18+
19+
Per-request tracing is possible when a non-empty [`RAINBOW_TRACING_AUTH`](environment-variables.md#rainbow_tracing_auth) is set in Rainbow and when there are both valid
20+
[Authorization](headers.md#authorization) and [`Traceparent`](headers.md#traceparent) HTTP headers passed in the request.
21+
22+
When tracing, it is often useful to skip local blockcache by setting [`Rainbow-No-Blockcache`](headers.md#rainbow-no-blockcache) header to `true`.
23+
24+
Per-request tracing exmaple:
25+
26+
```console
27+
$ export RAINBOW_TRACING_AUTH=CHANGEME-tracing-auth-secret # use value from Rainbow config
28+
$ export CID=bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi
29+
$ curl -H "Authorization: $RAINBOW_TRACING_AUTH" -H "Traceparent: 00-$(openssl rand -hex 16)-00$(openssl rand -hex 7)-01" -H "Rainbow-No-Blockcache: true" http://127.0.0.1:8090/ipfs/$CID -v -o /dev/null
30+
...
31+
> Authorization: CHANGEME-tracing-auth-secret
32+
> Traceparent: 00-b617dc6b6e302ccbabe0115eac80320b-00033792c7de8fc6-01
33+
...
34+
````
35+
36+
Now you can search for `trace_id = b617dc6b6e302ccbabe0115eac80320b` to find the trace.
37+
38+
[Boxo Tracing]: https://github.com/ipfs/boxo/blob/main/docs/tracing.md
39+
[Open Telemetry]: https://opentelemetry.io/
40+
[OpenTelemetry Environment Variable Specification]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md
41+
[Trace Context]: https://www.w3.org/TR/trace-context

0 commit comments

Comments
 (0)