Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8c2075b

Browse files
committedJan 10, 2025··
add initial tracing docs
1 parent a54b58f commit 8c2075b

10 files changed

+63
-66
lines changed
 
Loading
Loading
Binary file not shown.
Loading
Binary file not shown.
Loading
Loading
Binary file not shown.
Binary file not shown.

‎content/docs/reference/tracing.mdx

+63-66
Original file line numberDiff line numberDiff line change
@@ -16,109 +16,106 @@ import TabItem from '@theme/TabItem';
1616

1717
## Summary
1818

19-
Tracing tracks the progression of a single user request as it is handled by Pomerium.
19+
Pomerium has comprehensive support for OpenTelemetry tracing, allowing detailed introspection into requests and authorization flows.
20+
You can use tracing to debug errors and latency issues in your applications.
2021

21-
Each unit of work is called a Span in a trace. Spans include metadata about the work, including the time spent in the step (latency), status, time events, attributes, links. You can use tracing to debug errors and latency issues in your applications, including in downstream connections.
22-
23-
## How to configure
22+
## Configuration
2423

2524
<Tabs>
2625
<TabItem value="Core" label="Core">
2726

28-
#### Shared Tracing Settings
27+
### Environment Variables
28+
29+
The recommended way to configure tracing is by using the standard OpenTelemetry environment variables:
30+
- [SDK environment variables](https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#general-sdk-configuration)
31+
- [OTLP exporter environment variables](https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/)
32+
33+
The main variables used to configure tracing in Pomerium are the following:
2934

30-
| Config Key | Description | Required |
31-
| :-- | :-- | --- |
32-
| tracing_provider | The name of the tracing provider. (e.g. Jaeger, Zipkin) ||
33-
| tracing_sample_rate | Percentage of requests to sample in decimal notation. Default is `0.0001`, or .01% ||
35+
| Name | Description | Default |
36+
| :--- | :---------- | :------ |
37+
| [`OTEL_TRACES_EXPORTER`](https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#exporter-selection) | Trace exporter to be used. <br/> Valid values are `"otlp"` or `"none"` | `"none"` |
38+
| [`OTEL_EXPORTER_OTLP_ENDPOINT`](https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/#otel_exporter_otlp_endpoint) or <br/> [`OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`](https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/#otel_exporter_otlp_traces_endpoint) | See [Endpoint Configuration](https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/#endpoint-configuration). |
39+
| [`OTEL_EXPORTER_OTLP_PROTOCOL`](https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/#otel_exporter_otlp_protocol) or <br/> [`OTEL_EXPORTER_OTLP_TRACES_PROTOCOL`](https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/#otel_exporter_otlp_traces_protocol) | See [Protocol Configuration](https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/#protocol-configuration). <br/> Valid values are `"grpc"` or `"http/protobuf"`. <br/>If unset, Pomerium will attempt to determine the protocol based on the endpoint port number (the standard ports are 4317 for GRPC, 4318 for HTTP), otherwise it will default to `"http/protobuf"`. | (auto) |
40+
| [`OTEL_TRACES_SAMPLER_ARG`](https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_traces_sampler_arg) | Sampling probability, a number in the \[0..1\] range, e.g. `1.0` (sample all traces) or `0.25` (sample 25% of traces) | `1.0` |
3441

35-
Set `tracing_sample_rate = 1` if you want to see all requests in the tracings.
42+
### Config file
3643

37-
#### Datadog
44+
Tracing can also be configured using the Pomerium config file if desired:
3845

39-
Datadog is a real-time monitoring system that supports distributed tracing and monitoring.
46+
| Config Key | Equivalent Environment Variable |
47+
| :--- | :---------- |
48+
| `tracing_provider` | [`OTEL_TRACES_EXPORTER`](https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#exporter-selection) |
49+
| `tracing_otlp_endpoint` | [`OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`](https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/#otel_exporter_otlp_traces_endpoint) |
50+
| `tracing_otlp_protocol` | [`OTEL_EXPORTER_OTLP_TRACES_PROTOCOL`](https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/#otel_exporter_otlp_traces_protocol) |
51+
| `tracing_sample_rate` | [`OTEL_TRACES_SAMPLER_ARG`](https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_traces_sampler_arg) |
4052

41-
| Config Key | Description | Required |
42-
| :-- | :-- | --- |
43-
| tracing_datadog_address | `host:port` address of the Datadog Trace Agent. Defaults to `localhost:8126` ||
53+
</TabItem>
54+
<TabItem value="Enterprise" label="Enterprise">
4455

45-
#### Jaeger (partial)
56+
1. In the Enterprise Console, navigate to Settings > Tracing
4657

47-
**Warning** At this time, the Jaeger protocol does not capture spans inside the Proxy Service. Please use the Zipkin protocol with Jaeger for full support.
58+
2. In the "Tracing Provider" dropdown, select "OTLP"
4859

49-
[Jaeger](https://www.jaegertracing.io/) is a distributed tracing system released as open source by Uber Technologies. It is used for monitoring and troubleshooting microservices-based distributed systems, including:
60+
3. Enter your desired sample rate and OTLP endpoint
61+
62+
4. Optionally, enter a protocol ("grpc" or "http/protobuf"). If the endpoint uses port 4317 or 4318, the protocol will be selected automatically. Port 4317 is the standard for OTLP GRPC, and 4318 for OTLP HTTP.
63+
64+
![Enterprise tracing config](./img/tracing/tracing-otlp.png)
65+
</TabItem>
66+
</Tabs>
5067

51-
- Distributed context propagation
52-
- Distributed transaction monitoring
53-
- Root cause analysis
54-
- Service dependency analysis
55-
- Performance / latency optimization
68+
## Examples
5669

57-
| Config Key | Description | Required |
58-
| :-- | :-- | --- |
59-
| tracing_jaeger_collector_endpoint | Url to the Jaeger HTTP Thrift collector. ||
60-
| tracing_jaeger_agent_endpoint | Send spans to jaeger-agent at this address. ||
70+
### Using Jaeger to visualize trace data
6171

62-
For quick local testing, use Jaeger all-in-one, which is an executable designed to launch the Jaeger UI, jaeger-collector, jaeger-query, and jaeger-agent, with an in-memory storage component.
72+
[Jaeger](https://www.jaegertracing.io/) is a popular open-source tracing platform. It can be used to collect trace data and visualize it in the browser.
73+
74+
1. Run Jaeger in all-in-one mode with Docker:
6375

6476
```bash
65-
docker run -d --name jaeger \
66-
-e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
67-
-e COLLECTOR_OTLP_ENABLED=true \
68-
-p 6831:6831/udp \
69-
-p 6832:6832/udp \
70-
-p 5778:5778 \
77+
$ docker run -d --name jaeger \
7178
-p 16686:16686 \
7279
-p 4317:4317 \
7380
-p 4318:4318 \
74-
-p 14250:14250 \
75-
-p 14268:14268 \
76-
-p 14269:14269 \
77-
-p 9411:9411 \
78-
jaegertracing/all-in-one:1.45
79-
81+
jaegertracing/jaeger:latest
8082
```
8183

82-
Pomerium settings
83-
84-
```yaml
85-
tracing_provider: jaeger
86-
tracing_jaeger_collector_endpoint: http://localhost:14268/api/traces
87-
tracing_jaeger_agent_endpoint: localhost:6831
84+
2. Run Pomerium with OpenTelemetry environment variables set:
85+
```bash
86+
$ OTEL_TRACES_EXPORTER=otlp OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 pomerium --config path/to/your/config.yaml`
8887
```
8988

90-
Open Jaeger UI at `http://localhost:16686` in the browser to view Pomerium traces.
89+
3. Navigate to a Pomerium route defined in the config file
9190

92-
#### Zipkin
91+
4. Open your browser to http://localhost:16686 to view traces in the Jaeger UI.
9392

94-
Zipkin is an open-source distributed tracing system and protocol.
93+
### Tracing errors
9594

96-
Many tracing backends support Zipkin either directly or through intermediary agents, including Jaeger. For full tracing support, we recommend using the Zipkin tracing protocol.
95+
A typo in the OAuth2 issuer URL configuration is a common mistake that can lead to unexpected errors.
96+
A user attempting to navigate to a Pomerium route that requires authentication might see an error page instead of being redirected to the Identity Provider.
97+
In the Jaeger UI, traces that contain errors are highlighted and easy to find:
9798

98-
| Config Key | Description | Required |
99-
| :---------------------- | :------------------------------- | -------- |
100-
| tracing_zipkin_endpoint | Url to the Zipkin HTTP endpoint. | ✅ |
99+
![Jaeger trace list](./img/tracing/jaeger-trace-list-err.png)
101100

102-
</TabItem>
103-
<TabItem value="Enterprise" label="Enterprise">
101+
Clicking on this trace will show us the original unauthenticated request (`GET https://verify.localhost.pomerium.io/`) and that it was redirected to sign in.
102+
When attempting to initiate the auth flow, an error was encountered, which was recorded in the trace:
104103

105-
Configure **Tracing** in the Console:
104+
![Jaeger error trace](./img/tracing/error-flow.png)
106105

107-
1. Select a **Tracing Provider** and set **Sample Tracing Rate**
106+
Clicking on the span that recorded the error will show the error message - we are missing a trailing slash in the issuer URL!
108107

109-
![Select tracing provider](./img/tracing/tracing-providers.png)
108+
### Visualizing the Pomerium auth flow
110109

111-
![Select tracing provider and sample rate](./img/tracing/default-tracing.png)
110+
Pomerium can trace a request's entire journey through the authentication process, across multiple individual redirects between Pomerium services and the Identity Provider.
112111
113-
2. Configure tracing **Endpoints**
112+
For example, this trace shows an unauthenticated request (`GET https://verify.localhost.pomerium.io/`) that triggered a sequence of redirects to perform the auth flow:
114113
115-
![Set Jaeger endpoints](./img/tracing/jaeger-endpoints.png)
114+
![Auth flow](./img/tracing/auth-flow.png)
116115
117-
![Set Zipkin endpoint](./img/tracing/zipkin-endpoint.png)
116+
The trace above ends with a final redirect to repeat the original request, but this time the user is authenticated:
118117
119-
</TabItem>
120-
</Tabs>
118+
![Auth flow 2](./img/tracing/auth-flow-2.png)
121119
122-
### Examples
120+
This trace ends with the proxied request to the upstream server.
123121
124-
![jaeger example trace](img/jaeger.png)

0 commit comments

Comments
 (0)
Please sign in to comment.