-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Emit traceparent header in gateway responses and add sharness test #9180
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c0bb34e
feat: set default OTel propagator
guseggert 08fa681
Emit traceparent header in gateway responses and add sharness test
iand 9b6c984
Rename collector container
iand 51f458d
Update github.com/stretchr/objx version in kubo-as-a-library to fix c…
iand 5bd3702
Modify tracing sharness to trace everything
iand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,6 +179,7 @@ require ( | |
github.com/raulk/go-watchdog v1.2.0 // indirect | ||
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect | ||
github.com/spaolacci/murmur3 v1.1.0 // indirect | ||
github.com/stretchr/objx v0.4.0 // indirect | ||
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. Needed to avoid a failure in the gotest circleci step that checks whether kubo-as-a-library builds with the current version. Error was
|
||
github.com/syndtr/goleveldb v1.0.0 // indirect | ||
github.com/tidwall/gjson v1.14.0 // indirect | ||
github.com/tidwall/match v1.1.1 // indirect | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/usr/bin/env bash | ||
|
||
test_description="Test HTTP Gateway trace context propagation" | ||
|
||
. lib/test-lib.sh | ||
|
||
test_init_ipfs | ||
|
||
export OTEL_TRACES_EXPORTER=otlp | ||
export OTEL_EXPORTER_OTLP_PROTOCOL=grpc | ||
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 | ||
export OTEL_TRACES_SAMPLER=always_on | ||
|
||
cat <<EOF > collector-config.yaml | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
|
||
processors: | ||
batch: | ||
|
||
exporters: | ||
file: | ||
path: /traces/traces.json | ||
|
||
service: | ||
pipelines: | ||
traces: | ||
receivers: [otlp] | ||
processors: [batch] | ||
exporters: [file] | ||
EOF | ||
|
||
# touch traces.json and give it 777 perms, in case docker runs as a different user | ||
rm -rf traces.json && touch traces.json && chmod 777 traces.json | ||
|
||
test_expect_success "run opentelemetry collector" ' | ||
docker run --rm -d -v "$PWD/collector-config.yaml":/config.yaml -v "$PWD":/traces --net=host --name=ipfs-test-otel-collector-t0311 otel/opentelemetry-collector-contrib:0.52.0 --config /config.yaml | ||
' | ||
|
||
test_launch_ipfs_daemon | ||
|
||
test_expect_success "Make a file to test with" ' | ||
echo "Hello Worlds!" >expected && | ||
HASH=$(ipfs add -q expected) || | ||
test_fsh cat daemon_err | ||
' | ||
|
||
# HTTP GET Request | ||
test_expect_success "GET to Gateway succeeds" ' | ||
curl -svX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$HASH" >/dev/null 2>curl_output && | ||
cat curl_output | ||
' | ||
|
||
# GET Response from Gateway should contain no trace context headers | ||
test_expect_success "GET response for request without traceparent contains no trace context headers" ' | ||
grep "< traceparent: \*" curl_output && false || true | ||
' | ||
|
||
test_expect_success "Trace collector is writing traces" ' | ||
until cat traces.json | grep "\"traceId\"" >/dev/null; do sleep 0.1; done | ||
' | ||
|
||
version="00" | ||
trace_id="4bf92f3577b34da6a3ce929d0e0e4736" | ||
parent_id="00f067aa0ba902b7" | ||
flags="00" | ||
|
||
|
||
# HTTP GET Request with traceparent | ||
test_expect_success "GET to Gateway with traceparent header succeeds" ' | ||
curl -H "traceparent: $version-$trace_id-$parent_id-$flags" -svX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$HASH" >/dev/null 2>curl_output && | ||
cat curl_output | ||
' | ||
|
||
test_expect_success "GET response for request with traceparent preserves trace id" ' | ||
grep "< Traceparent: $version-$trace_id-" curl_output | ||
' | ||
|
||
test_expect_success "Trace id is used in traces" ' | ||
until cat traces.json | grep "\"traceId\":\"$trace_id\"" >/dev/null; do sleep 0.1; done | ||
' | ||
|
||
test_kill_ipfs_daemon | ||
|
||
test_expect_success "kill docker container" ' | ||
docker kill ipfs-test-otel-collector-t0311 | ||
' | ||
|
||
test_done |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do you know the difference with:
There ?
We already use this for cmds and this works great:
kubo/core/corehttp/commands.go
Line 150 in d1713ca
They seems equivalent to me, except
otelhttp
is cleaner and more descriptive.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.
I tried that but it didn't set the HTTP headers