Propagate tracing information (#51847)

Previously, we were not propagating the parent trace ID across HTTP
requests. This didn't used to be the case -- I'm honestly not sure
when/how this changed, but it's been broken for at least a couple of
months.

This wraps internal requests with the Opentelemetry transport, which
will pass along the tracing information so that we can effectively
connect traces across multiple services together.
This commit is contained in:
Camden Cheek 2023-05-11 17:31:06 -06:00 committed by GitHub
parent 61b34362e0
commit 6e6f91c42e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View File

@ -32,6 +32,7 @@ go_library(
"@com_github_prometheus_client_golang//prometheus/promauto",
"@com_github_puerkitobio_rehttp//:rehttp",
"@com_github_sourcegraph_log//:log",
"@io_opentelemetry_go_contrib_instrumentation_net_http_otelhttp//:otelhttp",
"@io_opentelemetry_go_otel//attribute",
],
)

View File

@ -22,6 +22,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/sourcegraph/log"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"github.com/sourcegraph/sourcegraph/internal/actor"
"github.com/sourcegraph/sourcegraph/internal/env"
@ -467,6 +468,7 @@ func TracedTransportOpt(cli *http.Client) error {
}
cli.Transport = &policy.Transport{RoundTripper: cli.Transport}
cli.Transport = otelhttp.NewTransport(cli.Transport)
return nil
}