Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 030eb06

Browse files
committed
Add request object influenced sampling option
Request object influenced sampling also allows us to implement blacklist/whitelist features.
1 parent 8f06490 commit 030eb06

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

trace/HTTP.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,35 @@ known attributes/labels on supported tracing backends.
117117
| "http.route" | "http.route" | "http.route" | "/http/route" |
118118
| "http.user_agent" | "http.user_agent" | "http.user_agent" | "/http/user_agent" |
119119
| "http.status_code" | "http.status_code" | "http.status_code" | "/http/status_code" |
120+
121+
## Sampling
122+
123+
There are two ways to control the `Sampler` used:
124+
* Controlling the global default `Sampler` via [TraceConfig](https://github.com/census-instrumentation/opencensus-specs/blob/master/trace/TraceConfig.md).
125+
* Pass a specific `Sampler` as an option to the HTTP plugin. Plugins should support setting
126+
a sampler per HTTP request.
127+
128+
In the following Go example, incoming and outgoing request objects can
129+
dynamically inspected to set a sampler.
130+
131+
For outgoing requests:
132+
133+
```
134+
type Transport struct {
135+
// GetStartOptions allows to set start options per request.
136+
GetStartOptions func(*http.Request) trace.StartOptions
137+
138+
// ...
139+
}
140+
```
141+
142+
For incoming requests:
143+
144+
```
145+
type Handler struct {
146+
// GetStartOptions allows to set start options per request.
147+
GetStartOptions func(*http.Request) trace.StartOptions
148+
149+
// ...
150+
}
151+
```

0 commit comments

Comments
 (0)