-
Notifications
You must be signed in to change notification settings - Fork 5
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
Propagate opentelemetry tracing headers in requests to limitador #49
Conversation
src/filter/http_context.rs
Outdated
let req_headers = self.get_http_request_headers(); | ||
for (header, value) in req_headers.iter() { | ||
match header.as_str() { | ||
"traceparent" | "tracestate" | "baggage" => { |
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.
self.get_http_request_headers
returns lowercase header names? in other words, if the header is TraceParent
, is the value captured? According to https://w3c.github.io/trace-context/#traceparent-header
The header name is [ASCII case-insensitive](https://infra.spec.whatwg.org/#ascii-case-insensitive). That is, TRACEPARENT, TraceParent, and traceparent are considered the same header. The header name is a single word; it does not contain any delimiters such as a hyphen.
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.
Yep from what I could tell no matter the provided format the headers were retrieved in lowercase - perhaps due to this https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_conn_man/header_casing
I could add a .to_lowercase()
before the match for safety in case though (perhaps this preserve case formatter causes the headers to no longer be lowercase when received by wasm shim). Also considering moving the three header strings out to constants
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.
if it's only used there, no need for a constant.
verification steps
diff --git a/Makefile b/Makefile
index 7808041..5362a26 100644
--- a/Makefile
+++ b/Makefile
@@ -61,10 +61,10 @@ $(WASM_RELEASE_PATH): $(RUST_SOURCES)
make -C $(PROJECT_PATH) -f $(MKFILE_PATH) build
development: $(WASM_RELEASE_PATH)
- docker-compose up
+ docker compose up
stop-development:
- docker-compose down
+ docker compose down
# get-protoc will download zip from $2 and install it to $1.
define get-protoc
Expected to see in limitador's logs the
|
@adam-cattermole nitpick: does it makes sense to use some external library, as a new dep strum, for such a simple thing as to iterate few values? |
I had the same thought on this - I'm wondering if there's a nice alternative that would allow us to simply add/remove from the |
src/filter/http_context.rs
Outdated
|
||
const RATELIMIT_SERVICE_NAME: &str = "envoy.service.ratelimit.v3.RateLimitService"; | ||
const RATELIMIT_METHOD_NAME: &str = "ShouldRateLimit"; | ||
|
||
// tracing headers | ||
#[derive(EnumIter)] | ||
#[derive(Clone)] |
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.
Not hurtful, but I don't know we clone that anywhere...
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.
Woops, remnant from an earlier change - removed it now.
86aa753
to
c0bb113
Compare
Propagates the following three headers to limitador:
Example curl:
Limitador:
Resolves #48