kubo/test/sharness/t0310-tracing.sh
Gus Eggert f855bfe6ef
feat: add basic gateway tracing (#8595)
* add deprecation warning when tracer plugins are loaded
* add response format attribute to span in gateway handler
* add note about tracing's experimental status in godoc
* add nil check for TTL when adding name span attrs
* add basic sharness test for integration with otel collector
* add nil check in UnixFSAPI.processLink
* test: sharness check all json objs for swarm span
* add env var docs to docs/environment-variables.md
* chore: pin the otel collector version
* add tracing spans per response type (#8841)
* docs: tracing with jaeger-ui

Co-authored-by: Marcin Rataj <lidel@lidel.org>
2022-04-04 19:24:05 +02:00

58 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Copyright (c) 2022 Protocol Labs
# MIT/Apache-2.0 Licensed; see the LICENSE file in this repository.
#
test_description="Test tracing"
. lib/test-lib.sh
test_init_ipfs
export IPFS_TRACING=1
export IPFS_TRACING_OTLP_GRPC=1
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
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 otel/opentelemetry-collector-contrib:0.48.0 --config /config.yaml
'
test_launch_ipfs_daemon
test_expect_success "check that a swarm span eventually appears in exported traces" '
until cat traces.json | grep CoreAPI.SwarmAPI >/dev/null; do sleep 0.1; done
'
test_expect_success "kill docker container" '
docker kill ipfs-test-otel-collector
'
test_kill_ipfs_daemon
test_done