-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: tracing of gateway requests #143
Changes from all commits
5b90024
a4766f7
597121b
ee26b80
687c902
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## `Authorization` | ||
|
||
Optional request header that guards per-request tracing features. | ||
|
||
See [`RAINBOW_TRACING_AUTH`](./environment-variables.md#rainbow_tracing_auth) | ||
|
||
## `Traceparent` | ||
|
||
See [`RAINBOW_TRACING_AUTH`](./environment-variables.md#rainbow_tracing_auth) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -297,6 +297,18 @@ | |
EnvVars: []string{"RAINBOW_LIBP2P_LISTEN_ADDRS"}, | ||
Usage: "Multiaddresses for libp2p bitswap client to listen on (comma-separated)", | ||
}, | ||
&cli.StringFlag{ | ||
Name: "tracing-auth", | ||
Value: "", | ||
EnvVars: []string{"RAINBOW_TRACING_AUTH"}, | ||
Usage: "If set the key gates use of the Traceparent header by requiring the key to be passed in the Authorization header", | ||
}, | ||
&cli.Float64Flag{ | ||
Name: "sampling-fraction", | ||
Value: 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this default to 1 instead of 0? I'd been using 0 with some testing to prevent flooding as I was more interested in Traceheaders, but the default OTEL sampler is "parentbased_always_on". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A value of zero seems like the expected default, so that no sampling is done. |
||
EnvVars: []string{"RAINBOW_SAMPLING_FRACTION"}, | ||
Usage: "Rate at which to sample gateway requests. Does not include traceheaders which will always sample", | ||
}, | ||
} | ||
|
||
app.Commands = []*cli.Command{ | ||
|
@@ -459,7 +471,8 @@ | |
gatewayListen := cctx.String("gateway-listen-address") | ||
ctlListen := cctx.String("ctl-listen-address") | ||
|
||
handler, err := setupGatewayHandler(cfg, gnd) | ||
tracingAuth := cctx.String("tracing-auth") | ||
handler, err := setupGatewayHandler(cfg, gnd, tracingAuth) | ||
if err != nil { | ||
return err | ||
} | ||
|
@@ -480,7 +493,7 @@ | |
registerVersionMetric(version) | ||
registerIpfsNodeCollector(gnd) | ||
|
||
tp, shutdown, err := newTracerProvider(cctx.Context) | ||
tp, shutdown, err := newTracerProvider(cctx.Context, cctx.Float64("sampling-fraction")) | ||
if err != nil { | ||
return err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory could invent an
OTEL_TRACES_SAMPLER
andOTEL_TRACES_SAMPLER_ARG
if that makes more sense, but this seemed fine for now.