| 1 | // Package tracing contains the tracing logic for go-ipfs, including configuring the tracer and |
| 2 | // helping keep consistent naming conventions across the stack. |
| 3 | // |
| 4 | // NOTE: Tracing is currently experimental. Span names may change unexpectedly, spans may be removed, |
| 5 | // and backwards-incompatible changes may be made to tracing configuration, options, and defaults. |
| 6 | // |
| 7 | // Tracing is configured through environment variables, as consistent with the OpenTelemetry spec as possible: |
| 8 | // |
| 9 | // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md |
| 10 | // |
| 11 | // OTEL_TRACES_EXPORTER: a comma-separated list of exporters: |
| 12 | // - otlp |
| 13 | // - zipkin |
| 14 | // - file |
| 15 | // |
| 16 | // Different exporters have their own set of environment variables, depending on the exporter. These are typically |
| 17 | // standard environment variables. Some common ones: |
| 18 | // |
| 19 | // OTLP HTTP/gRPC: |
| 20 | // |
| 21 | // - OTEL_EXPORTER_OTLP_PROTOCOL |
| 22 | // one of [grpc, http/protobuf] |
| 23 | // default: grpc |
| 24 | // - OTEL_EXPORTER_OTLP_ENDPOINT |
| 25 | // - OTEL_EXPORTER_OTLP_CERTIFICATE |
| 26 | // - OTEL_EXPORTER_OTLP_HEADERS |
| 27 | // - OTEL_EXPORTER_OTLP_COMPRESSION |
| 28 | // - OTEL_EXPORTER_OTLP_TIMEOUT |
| 29 | // |
| 30 | // Zipkin: |
| 31 | // |
| 32 | // - OTEL_EXPORTER_ZIPKIN_ENDPOINT |
| 33 | // |
| 34 | // File: |
| 35 | // |
| 36 | // - OTEL_EXPORTER_FILE_PATH |
| 37 | // file path to write JSON traces |
| 38 | // default: `$PWD/traces.json` |
| 39 | // |
| 40 | // For example, if you run a local IPFS daemon, you can use the jaegertracing/all-in-one Docker image to run |
| 41 | // a full Jaeger stack and configure Kubo to publish traces to it: |
| 42 | // |
| 43 | // docker run -d --rm --name jaeger \ |
| 44 | // -e COLLECTOR_OTLP_ENABLED=true \ |
| 45 | // -e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \ |
| 46 | // -p 5775:5775/udp \ |
| 47 | // -p 6831:6831/udp \ |
| 48 | // -p 6832:6832/udp \ |
| 49 | // -p 5778:5778 \ |
| 50 | // -p 16686:16686 \ |
| 51 | // -p 14250:14250 \ |
| 52 | // -p 14268:14268 \ |
| 53 | // -p 14269:14269 \ |
| 54 | // -p 4317:4317 \ |
| 55 | // -p 4318:4318 \ |
| 56 | // -p 9411:9411 \ |
| 57 | // jaegertracing/all-in-one |
| 58 | // OTEL_EXPORTER_OTLP_INSECURE=true OTEL_TRACES_EXPORTER=otlp ipfs daemon --init |
| 59 | // |
| 60 | // # In this example the Jaeger UI is available at http://localhost:16686. |
| 61 | // |
| 62 | // Span names follow a convention of <Component>.<Span>, some examples: |
| 63 | // |
| 64 | // - component=Gateway + span=Request -> Gateway.Request |
| 65 | // - component=CoreAPI.PinAPI + span=Verify.CheckPin -> CoreAPI.PinAPI.Verify.CheckPin |
| 66 | // |
| 67 | // We follow the OpenTelemetry convention of using whatever TracerProvider is registered globally. |
| 68 | package tracing |