Commit Graph

146 Commits

Author SHA1 Message Date
Erik Seliger
f61ce6e8e8
tenant: Introduce first version of tenant package (#64271)
This PR aims to craft the /internal/tenant package for use by all Sourcegraph cluster-internal services to properly scope data visibility to the correct requesting tenant.
For now, we only expose methods we know we will DEFINITELY need.

This PR also adds the required middlewares so we can start to tinker with it in implementations.

## Test plan

CI passes. We don't enforce anything for now except not passing unparseable tenant IDs, which should be fine.
2024-08-08 12:02:19 +02:00
Erik Seliger
7dc2707fff
chore: Break dependency of internal/trace on conf (#62177)
This PR adds an initializer function that will be called from the svcmain package through the call to tracer.Init.

The reasoning behind this is that it's very easy to accidentally use a package that uses conf internally from a service like Cody Gateway, Appliance, Migrator, or other MSP services and just because we don't have any config source for the trace ID should not let the process stall entirely.
To make it absolutely clear that a dependency is safe to use from a conf perspective, this change indicates that well by dropping the dependency on it entirely and making it another packages concern to pass this type down.

Test plan:

All tests for Sourcegraph are still passing.

---------

Co-authored-by: Robert Lin <robert@bobheadxi.dev>
2024-04-30 21:12:39 +02:00
Keegan Carruthers-Smith
40b3b419e5
search: consistent telemetry between honeycomb and tracing for zoekt (#60719)
This commit has a few changes to how we do telemetry for zoekt.

- SearchOption attributes are part of span creation.
- SearchOption and Stats attributes are filtered to remove default
  values. This mirrors how we log in net/trace which I find useful when
  reading options.
- Add missing fields from SearchOption
- EndWithErrIfNotContext helper introduced and used for Search and List.
- List uses same pattern for telemetry as Search
- List logs actor
- List correctly logs repos count and always logs stats.crashes.

Test Plan: go test and "HONEYCOMB_LOCAL=true sg start" followed by a
search. I then visually eyeballed the log output for events.
2024-02-26 12:17:03 +02:00
Erik Seliger
e2c20585b5
trace: Memoize template for trace URL (#59970)
This showed up in some profiles as being an area of ~high contention, 99% of which is coming from parsing the template string every time. This PR adds some caching to it.

## Test plan

n/a - code review
2024-01-30 18:30:35 +01:00
Robert Lin
7678c7b031
chore: upgrade otel SDK packages (#59564)
This is prep for an upgrade of our otel-collector itself - we are adding a dependency on a beta receiver in https://github.com/sourcegraph/sourcegraph/pull/59561 , and want to make sure we are up to date.

This change also gets us to the stable metrics API, which is nice.
2024-01-15 20:08:54 +00:00
Jean-Hadrien Chabran
a9c3f8ce9a
chore: links/ownership devx->dev-infra (#58999) 2023-12-14 15:07:20 +00:00
Robert Lin
f9c22fea75
eventlogs: add automatic propagation for trace ID (#58060)
This mirrors the change from https://github.com/sourcegraph/sourcegraph/pull/57774 but applies the addition of trace ID to:

1. translation of v2 events into `event_logs`
2. bulk-inserting events into `event_logs` via the legacy mutations and direct usages

While we will be deprecating widespread usage of the legacy events, we still need to support it somewhat for now, and going forward we will still retain the `event_logs` table as a semistructured reference for events that get recorded.
2023-11-03 21:27:23 +00:00
Robert Lin
4556b317f1
tracer: enforce trace policy entirely via Sampler (#58068)
This change updates our internal tracer to enforce policy only via a `Sampler` implementation. This has the following benefits:

1. Even when a trace should not be sampled, contexts are still populated with valid spans, rather than no-op ones. This is important to make use of trace IDs for non-tracing purposes, e.g. https://github.com/sourcegraph/sourcegraph/pull/57774 and https://github.com/sourcegraph/sourcegraph/pull/58060
2. We enforce trace policies the way they were meant to be enforced in OpenTelemetry: by simply indicating that the span should not be exported.

This was not possible before because OpenTracing did not use context propagation, hence we did not have a way to use trace policy flags set in context - but thanks to @camdencheek's work removing OpenTracing entirely, we can now do this in a more idiomatic fashion.

Thanks to this, I've removed a few places that prevented trace context from being populated based on trace policy (HTTP and GraphQL middleware, and `internal/trace`). This delegates sampling decisions to the sampler, and ensures we accept valid trace context everywhere.

## Test plan

Unit tests on a TracerProvider configured with the new sampler.

Manual testing:

```
sg run jaeger otel-collector 
sg start
```

Setting `observability.tracing.debug` to `true` we can see logs indicating the desired traits for non-`ShouldTrace` traces:

```
[         worker] INFO tracer tracer/logged_otel.go:63 Start {"spanName": "workerutil.dbworker.store.insights_query_runner_jobs_store.dequeue", "isRecording": false, "isSampled": false, "isValid": true}
```

With `observability.tracing.sampling` set to `none`, running a search with `&trace=1` only gives us spans from zoekt, which seems to have always been outside our rules here.

With `observability.tracing.sampling` set to `selective`, running a search with `&trace=1` gives us a full trace.

With `observability.tracing.sampling` set to `all`, Jaeger instantly gets loads of traces, and in logs we see:

```
[         worker] INFO tracer tracer/logged_otel.go:63 Start {"spanName": "workerutil.dbworker.store.exhaustive_search_worker_store.dequeue", "isRecording": true, "isSampled": true, "isValid": true}
```

---------

Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>
2023-11-02 09:00:14 -07:00
William Bezuidenhout
1ae6cc6bfd
logger: update log lib and remove use of description (#57690)
* log: remove use of description paramter in Scoped

* temporarily point to sglog branch

* bazel configure + gazelle

* remove additional use of description param

* use latest versions of zoekt,log,mountinfo

* go.mod
2023-10-18 17:29:08 +02:00
Robert Lin
4797786509
httpapi/graphql: add error wrapping to graphql serving (#56401)
We're getting a huge number of mysterious JSON issues in our GraphQL routes: https://sourcegraph.slack.com/archives/C05EMJM2SLR/p1694018006616969

All we get is an `encoding/json/*json.SyntaxError (*::)` right now which is not helpful. This adds a bit of error wrapping so we can at least tell if the error came from serving the GraphQL request.

This change also:

- removes duplicate error logging in `ErrorHandler`, we have much more robust logging in a separate layer
- removes a very old `reportError` method that directly reports to Sentry or something. This is almost certainly unused now that we use `sourcegraph/log` to report errors.

## Test plan

CI
2023-09-06 13:26:30 -07:00
Camden Cheek
084a10ba3b
Tracing: final cleanups (#54694)
This will be my last PR related to the backend tracing work I've been
doing. This is a set of small cleanups to the `trace` package that I've
collecting as I have worked on tracing and used tracing. Following this
PR, the `trace` package is just a very lightweight wrapper around the
standard OpenTelemetry APIs. I think it's best to keep the package
around rather than using opentelemetry directly because it easy to add
convenience methods (which I would be sad to lose).

Each commit is self-contained and has a descriptive message.

If anyone wants to pick up where I'm leaving off, here are a few things
left undone:
- Convert Zoekt to use OpenTelemetry rather than OpenTracing
- Add OpenTelemetry support to other services like syntect-server
- Merge the `internal/trace` and `internal/tracer` packages
- Consider adding a type that conforms to the OpenTelemetry `Span`
interface but also writes to `x/net/trace` that can be enabled when
tracing is not available.
- Remove unrelated code from the `trace` and `tracer` package (see
[here](https://sourcegraph.com/github.com/sourcegraph/sourcegraph@a6759b95dbd8e5e3a604f7fd452b0b85f37091d9/-/blob/internal/tracer/tracer.go?L75-83)
and
[here](https://sourcegraph.com/github.com/sourcegraph/sourcegraph@769fbbf5008e8decc63967dbff53f26333620265/-/blob/internal/trace/buckets.go?L3-7))
- Noodle on a `Traceable` interface (one that impls `Attr()` or
`Attrs()`) so types can be easily added with `SetAttributes()`
- Experiment with sampling
- Experiment with replacing `policy.ShouldTrace` with native
opentelemetry tools

## Test plan

Tested manually that tracing still looks good locally. Will test on
other instances when it rolls out.

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
2023-07-13 10:16:11 +02:00
Camden Cheek
cf037e2ee4
Tracing: replace family and title with name (#54563)
This removes the "title" argument to `trace.New()`. This was previously
only displayed as an attribute on the span, which is confusing since
people would often use a span name for this argument since it is called
"title." OpenTelemetry does not have the concept of a family and title
(these are from `x/net/trace`, which is no longer used), so this is
another step towards reconciling our tracing package with OpenTelemetry.

Basically, I went through all uses of `trace.New()` and either named the
span `family.title`, removed the title in the case it was an empty
string, or converted the title to a set of more structured attributes.

Now, `trace.New()` only takes a context, a span name, and an optional
set of attributes.
2023-07-05 23:14:18 +00:00
Camden Cheek
2972241984
Tracing: remove LazyPrintf (#54564)
This removes the `LazyPrintf` method on `trace.Trace`. This method
existed because of `x/net/trace`, but now we can just use `AddEvent`
instead. It's not quite as ergonomic, but it provides more readable span
events (they're not named `LazyPrintf`) and helps discourage adding
massive payloads to a span.

This is another step towards standardization on OpenTelemetry.
2023-07-04 14:17:00 +00:00
Camden Cheek
8f2903f1ba
Tracing: inherit from raw OTel trace for TraceFromContext (#53874)
Currently, if we have a raw OTel trace in the context but no active
`trace.Trace`, we `TraceFromContext` will not use that, so we can lose
some tracing information. This provides a temporary fix to make
`TraceFromContext` create a new, ephemeral `*Trace` that contains the
OTel span if it exists.

I think the real solution here is to just go all in on the OTel tooling
and make our custom trace stuff conform to the OTel interfaces. I'll
work on that in the background, but I want to get this out before 5.1.
2023-06-21 21:56:40 +00:00
Robert Lin
61ce005b83
internal/trace: remove net/trace integration (#53795)
Follow-up from
https://github.com/sourcegraph/sourcegraph/pull/53435#issuecomment-1597050970
and INC-214 - this removes `net/trace` instrumentation entirely in the
next release.

It seems [this gets low usage and may be difficult to
use](https://github.com/sourcegraph/sourcegraph/pull/53795#pullrequestreview-1489890896),
and it seems to introduce some risk and overhead. This will also make it
easier to drop our internal trace wrapper entirely and/or integrate it
as part of OpenTelemetry's APIs instead of having a proprietary way of
doing traces.

## Test plan

Already tested in https://github.com/sourcegraph/sourcegraph/pull/53435
2023-06-21 18:35:07 +00:00
Keegan Carruthers-Smith
03ac5f4e98
trace: handle http.ErrAbortHandler in loggingRecoverer (#53432)
This is an intentional panic which means we want to abort the http
request. This is not an error that needs reporting.

Test Plan: CI
2023-06-14 06:46:45 +00:00
Robert Lin
a346366d61
trace: add SRC_ENABLE_NET_TRACE to disable net/trace (#53435)
This change adds `SRC_ENABLE_NET_TRACE`, which if set to `false` will
disable `net/trace` support in `internal/trace` and our debug routers.
The plan is to just set this to `false` in Sourcegraph.com
(https://github.com/sourcegraph/deploy-sourcegraph-cloud/pull/17937)
until we can absolutely confirm that `net/trace` is an issue - it's also
possible this is only problematic for Sourcegraph.com levels of traffic.
Follow-ups will be in
[INC-214](https://sourcegraph.slack.com/archives/C05CGC5UL3E).

Context: today we noticed unreliability in Sourcegraph.com,
[INC-214](https://sourcegraph.slack.com/archives/C05CGC5UL3E), where a
lot of requests would get no responses. We diagnosed the issue to be a
frontend pod that had a huge goroutine leak, causing unreliability in
sourcegraph.com for requests routed to the affected pod. Removing the
affected pod immediately resolved the stability issues.

<img width="300" alt="image"
src="https://github.com/sourcegraph/sourcegraph/assets/23356519/b158305c-8724-463c-b5e5-0c20a3ea9d72">
<img width="500" alt="image"
src="https://github.com/sourcegraph/sourcegraph/assets/23356519/8780f3ca-9f0d-496e-9daf-f7e46d2c969a">

It appears this may be caused by increased usage of `internal/trace`,
which [creates a trace with
`golang.org/x/net/trace`](https://sourcegraph.com/github.com/sourcegraph/sourcegraph@f3b0276dfe24018db5f76d5d8d430db98e59f2dd/-/blob/internal/trace/tracer.go?L32-33),
which then [acquires a global
mutex](https://sourcegraph.com/go/golang.org/x/net/-/blob/trace/trace.go?L369-380).
Cloud Profile indicates this trend started ~June 5, which _somewhat_
correlates with a series of changes that removed OpenTracing usages and
replaced them with OpenTelemetry/`internal/trace`, the latter of which
ends up in this code path.

<img width="979" alt="image"
src="https://github.com/sourcegraph/sourcegraph/assets/23356519/304c6de7-6d0c-4a29-936f-b56405f8cae8">
<img width="1001" alt="image"
src="https://github.com/sourcegraph/sourcegraph/assets/23356519/48a281db-df81-4e3e-8455-90844ee008a4">

See incident discussion thread for more details:
https://sourcegraph.slack.com/archives/C05CGC5UL3E/p1686712614273539?thread_ts=1686710733.750869&cid=C05CGC5UL3E

## Test plan

`sg start`, code review, CI
2023-06-14 05:20:48 +00:00
Robert Lin
775091b2c6
instrumentation: set X-Trace to trace ID, X-Trace-URL to trace URL, add X-Trace-Span (#53259)
This allows us to return `X-Trace` and `X-Trace-Span` from Cody Gateway
with the shared HTTP instrumentation helper, which will help linking up
traces in case GCP tracing doesn't work out, and also help with
debugging customer instances that talk to Cody Gateway. Outside of
Sourcegraph core we don't have access to conf so setting this to a URL
doesn't make as much sense, and there seems to be a somewhat
pre-existing standard in Jaeger to set `x-trace` to a trace ID (?), and
`X-Trace-Span` just tacks onto that with a bit more detail (for Cody
Gateway locally, `x-trace` will point to the entire trace, would be nice
to have the span ID as well).

In Sourcegraph core, this means that we now can't set the URL to
`X-Trace` as we've done before. Instead, we now set it to `X-Trace-URL`,
and send both in responses. There appears to be no references to
`X-Trace` that expects an URL, so I think we should be good here -
streaming search uses a field on its responses.

Related: #53025 

## Test plan

With `?trace=1` in both Cody chat and search, I now get something like
the following:

<img width="708" alt="image"
src="https://github.com/sourcegraph/sourcegraph/assets/23356519/b56f63e5-ad3e-4aad-8108-3aaa6af6f67e">

The "View trace" still works as expected, and the link and the headers
point to the same trace.
2023-06-09 11:33:11 -07:00
Camden Cheek
dfab9c5b4b
Tracing: remove opentracing (#52978)
This removes the remainder of opentracing-related code from
sourcegraph/sourcegraph. We still use an opentracing propagator so that
downstream services that use opentracing (cough cough Zoekt) will still
work (but Zoekt is weird in a lot of ways and is kind of broken already
in some cases).
2023-06-06 11:02:15 -06:00
Camden Cheek
9cfc5b248d
Tracing: truncate errors (#52953)
I suspect that one of the reasons we're failing to get a lot of our
traces on sourcegraph.com is that we're generating very large error
strings because we're joining tons of errors together into massive
multierrors.

This updates our tracing code to truncate the error string if it's
greater than 512 runes.
2023-06-05 22:45:33 +00:00
Jean-Hadrien Chabran
3d36d34b3d
ci: re-enable race detection (#52776)
The previous approach to enable race detection was too radical and
accidently led to build our binaries with the race flage enabled, which
caused issues when building images down the line.

This happened because putting a `test --something` in bazelrc also sets
it on `build` which is absolutely not what we wanted. Usually folks get
this one working by having a `--stamp` config setting that fixes this
when releasing binaries, which we don't at this stage, as we're still
learning Bazel.

Luckily, this was caught swiftly. The current approach insteads takes a
more granular approach, which makes the `go_test` rule uses our own
variant, which injects the `race = "on"` attribute, but only on
`go_test`.


## Test plan

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->

CI, being a main-dry-run, this will cover the container building jobs,
which were the ones failing.

---------

Co-authored-by: Alex Ostrikov <alex.ostrikov@sourcegraph.com>
2023-06-05 20:41:47 +02:00
Camden Cheek
f10b37d2e2
Tracing: remove opentracing spans (#52490)
This removes all uses of `ot.StartSpanFromContext` and converts them to
`trace.New()`.
2023-06-01 16:08:14 +00:00
Camden Cheek
0a748d098a
Tracing: add trace.FinishWithErr (#52478)
This just adds a little helper method for a very common operation when
using tracing: finish the span and set its error.

Basically, this turns a 4-liner into a 1-liner. This is nice because
tracing can add quite a bit of noise to a function. Also, it's directly
deferrable so it's less error-prone.
2023-05-26 15:58:50 +00:00
Camden Cheek
154e035076
Tracing: remove unused trace.Stringer (#52485)
This is no longer used. It was effectively replaced by
attribute.Stringer.
2023-05-26 09:56:03 -06:00
Camden Cheek
c20a01e123
Tracing: remove trace.Tag (#52091)
`trace.Tag` is only used in the `trace.New()` function, after which it
is immediately translated to opentelemetry attributes. Let's reduce the
number of types we have to deal with and just use attributes directly.
2023-05-17 18:09:48 +00:00
Camden Cheek
4132bef679
Tracing: remove opentracing bridge code (#52088)
This removes the last usage of `OTLogFieldsToOTelAttrs`, which is also
the only consumer of all the opentracing bridge code, so this removes
all that.
2023-05-17 11:49:05 -06:00
Camden Cheek
5774f6c738
Tracing: remove deprecated methods (#51859)
This does the minimum amount of work needed to remove the deprecated
methods on `trace.Trace`. We still rely on the `otlog.Field` type
heavily in the observation package, so to minimize the surface area of
the change, I exported the `OTLogFieldsToOTelAttrs` field so we can
start to push the opentelemetry attribute types upwards in the stack
more incrementally.

## Test plan

It compiles + existing tests.

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
2023-05-12 10:46:40 -06:00
Robert Lin
6f521ec670
trace/internal: do not add tracing in policy transport (#51848)
Policy transport shouldn't have tracing tucked away in it - moves the
old OpenTracing thing here up into the transport option.

I originally thought we should remove it since otelhttp (added in
https://github.com/sourcegraph/sourcegraph/pull/51847) should propagate
the same thing via the propagators we initialize, but we might want to
keep it in case anyone relies on context things it sets.

## Test plan

n/a - functionally the same
2023-05-12 08:51:20 -07:00
Camden Cheek
d64586442a
Tracing: clean up uses of opentracing in search code (#51856)
This removes nearly all the dependencies on opentracing from the search
codebase.

The search codebase used the opentracing log types heavily for logging,
tracing, and pretty printing our search jobs. And because our search
jobs all conform to a common interface, it would be difficult to
approach this incrementally. So I just ripped the band-aid off and
converted everything to use the opentelemetry types.

Now the only dependent of the opentracing log types is the observation
package.
2023-05-12 04:04:15 -06:00
Robert Lin
ce842515c0
httptrace: do not mutate shared logger (#51826)
Previously, every slow request would be logged with the first trace ID
that the middleware encounters. This change ensures we make a copy of
the base logger first before creating new loggers with additional
fields.

Detected by @michaellzc who noticed all slow requests were being logged
with the same executor request, even when they weren't :)

## Test plan

n/a
2023-05-11 11:25:19 -07:00
William Bezuidenhout
055e8788e5
bazel: configure (#49825)
Latest run of `bazel configure`

## Test plan
Green CI
https://buildkite.com/sourcegraph/sourcegraph/builds/209227#0187085a-f76a-4eaf-ad46-3c398bde7966
<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
2023-03-22 11:01:24 +02:00
Erik Seliger
f87fb2d7cc
Remove trace.SQL (#49816)
We should use the otelsql in dbconn instead. This should be redundant.

See https://sourcegraph.slack.com/archives/C04MYFW01NV/p1679435638206579
for more context.
2023-03-22 00:21:49 +00:00
Dave Try
2b8fa079f0
bazel: fix buf files (#49444)
fix protoc-gen-go version
2023-03-15 20:21:38 +00:00
Dave Try
293385d5dd
bazel: update timeouts to suppress warnings (#49399)
Updates all of the BUILD fields with timeouts to suppress warnings and
reduce log spam.


## Test plan

Green CI
2023-03-15 15:04:16 +02:00
Robert Lin
1cb5bc4b59
internal/tracer: correctly set Tracer names in OpenTracing bridge (#40945)
The existing wrapped OpenTelemetry TracerProvider for bridging
OpenTracing API calls to OpenTelemetryAPI calls discards the name
provided to the `Tracer()` constructor on it, since it uses a fixed
tracer that we provide it.

This change leverages an upstream patch,
https://github.com/open-telemetry/opentelemetry-go/pull/3116 (dependency
update: https://github.com/sourcegraph/sourcegraph/pull/47126), that
allows wrapped tracers to be created on the fly with the provided
parameters, so that we can more accurately see the instrumentation
source.

## Test plan

Via the bridge, we can see that the Tracer used is the bridge tracer:

<img width="1322" alt="image"
src="https://user-images.githubusercontent.com/23356519/186957763-60faee32-e6a5-4bda-bb64-fddb82eacc0d.png">

Via direct usage of OpenTelemetry, we can see that the Tracer used has
the custom name set:

<img width="1448" alt="image"
src="https://user-images.githubusercontent.com/23356519/186957773-c6ff7643-3f89-498d-857b-1dd79b36508d.png">
2023-02-23 11:07:39 -08:00
Keegan Carruthers-Smith
2c9b2ddeaf
trace: repo-update warns if slower than 10m (#47655)
Previously we would warn after 5s. Personally on my dev machine (in
South Africa) this would fire very often since GitHub isn't as fast for
me. Additionally for customers with large monorepos I expect this log is
constantly spamming. I think a better approach is to instead put an
extremely high value which if exceeded truly indicates a warning.

Test Plan: go test
2023-02-15 10:49:18 +02:00
Jean-Hadrien Chabran
5bea6c78c8
bazel: build the //lib folder (#46929) 2023-01-27 15:30:35 +01:00
Camden Cheek
be1a40a76c
gRPC: propagate tracing information (#46611)
This adds some default options for gRPC clients and servers that allow us to propagate our tracing information across RPC boundaries.
2023-01-23 22:10:18 +00:00
Jean-Hadrien Chabran
bc5490c4bb
bazel: introduce build files for Go (#46770) 2023-01-23 14:00:01 +01:00
Jean-Hadrien Chabran
11892ed462
linters: re-enable nolintlint and staticcheck SA1019 (#45847) 2022-12-20 14:24:44 +00:00
Dave Try
de80d33da9
trace: fix broken logger scope (#45540)
fix broken logger scope
2022-12-12 14:04:42 +00:00
coury-clark
6dc57e510c
insights: add trace id to queued query record (#44626) 2022-11-18 16:17:27 -08:00
Michal Vrtiak
79ed283126
Omit sensitive query parameters when logging auth errors. (#43912) 2022-11-07 14:20:18 -04:00
Indradhanush Gupta
d3186381bd
internal/trace: Log status code (#43386) 2022-10-25 13:48:15 +05:30
Camden Cheek
747b618e70
Backend: add stacktrace to panic handler (#42678)
add stacktrace to panic handler
2022-10-07 15:32:30 -06:00
Robert Lin
8a54aba93a
Revert "Revert "httptrace: remove unused repo and origin label" (#42187) (#42189)
This reverts commit 20de2ba52e (#42187 , #42118)
2022-09-29 08:46:21 -07:00
Jean-Hadrien Chabran
20de2ba52e
Revert "httptrace: remove unused repo and origin label" (#42187)
This reverts commit 6ad85b0ec7, which is causing e2e tests to fail.
2022-09-27 19:25:17 +02:00
Robert Lin
6ad85b0ec7
httptrace: remove unused repo and origin label (#42118)
A repo label is set on httptrace metrics, but it only tracks a small set of hardcoded repositories that have not been changed for at least 4 years. There do not appear to be any references to this label in any dashboard either.

origin is another label untouched for 4+ years, and is always set to 'unknown' in s2. Tracking references also reveals two metrics that have no references in dashboards.
2022-09-27 09:29:40 -07:00
Robert Lin
9d3a4c6161
trace/policy: fix docstring about ShouldTrace fallback (#42129) 2022-09-27 09:13:37 -07:00
Robert Lin
fa42ad2e4e
all: always check if opentracing.SpanFromContext is nil (#42027)
policy.ShouldTrace does not guarantee that span has been started within a context, just that one should be created if anyone asks. opentracing.SpanFromContext documents that it can return nil if no span is started, which may cause a panic when used. To mitigate this, this we update the docstring of policy.ShouldTrace and make sure usages of opentracing.SpanFromContext always check for the nil-ness of the span. We do this even if a trace is started right before, just in case.

The OpenTelemetry equivalent, trace.SpanFromContext, returns a zero-value no-op span instead (though there are no usages of this function yet).
2022-09-26 09:48:29 -07:00