Skip to content

Commit

Permalink
Return error if span context was not found (grafana#11207)
Browse files Browse the repository at this point in the history
**What this PR does / why we need it**:
This is a follow up to grafana#10956.

`lokigrpc.GetParentSpanForRequest` would ignore
`opentracing.ErrSpanContextNotFound`. However, that should be up to the
caller to decide whether this error should be ignored or not.

**Checklist**
- [ ] Reviewed the
[`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md)
guide (**required**)
- [ ] Documentation added
- [ ] Tests updated
- [ ] `CHANGELOG.md` updated
- [ ] If the change is worth mentioning in the release notes, add
`add-to-release-notes` label
- [ ] Changes that require user attention or interaction to upgrade are
documented in `docs/sources/setup/upgrade/_index.md`
- [ ] For Helm chart changes bump the Helm chart version in
`production/helm/loki/Chart.yaml` and update
`production/helm/loki/CHANGELOG.md` and
`production/helm/loki/README.md`. [Example
PR](grafana@d10549e)
- [ ] If the change is deprecating or removing a configuration option,
update the `deprecated-config.yaml` and `deleted-config.yaml` files
respectively in the `tools/deprecated-config-checker` directory.
[Example
PR](grafana@0d4416a)
  • Loading branch information
jeschkies authored and rhnasc committed Apr 12, 2024
1 parent fa645b4 commit 3f81a93
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pkg/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func (s *Scheduler) enqueueRequest(frontendContext context.Context, frontendAddr
// information, since that is a long-running request.
tracer := opentracing.GlobalTracer()
parentSpanContext, err := lokigrpc.GetParentSpanForRequest(tracer, msg)
if err != nil {
if err != nil && err != opentracing.ErrSpanContextNotFound {
return err
}

Expand Down
12 changes: 2 additions & 10 deletions pkg/util/httpgrpc/carrier.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ func GetParentSpanForHTTPRequest(tracer opentracing.Tracer, req *weaveworks_http
}

carrier := (*HeadersCarrier)(req)
extracted, err := tracer.Extract(opentracing.HTTPHeaders, carrier)
if err == opentracing.ErrSpanContextNotFound {
err = nil
}
return extracted, err
return tracer.Extract(opentracing.HTTPHeaders, carrier)
}

func GetParentSpanForQueryRequest(tracer opentracing.Tracer, req *queryrange.QueryRequest) (opentracing.SpanContext, error) {
Expand All @@ -52,11 +48,7 @@ func GetParentSpanForQueryRequest(tracer opentracing.Tracer, req *queryrange.Que
}

carrier := opentracing.TextMapCarrier(req.Metadata)
extracted, err := tracer.Extract(opentracing.TextMap, carrier)
if err == opentracing.ErrSpanContextNotFound {
err = nil
}
return extracted, err
return tracer.Extract(opentracing.TextMap, carrier)
}

func GetParentSpanForRequest(tracer opentracing.Tracer, req Request) (opentracing.SpanContext, error) {
Expand Down

0 comments on commit 3f81a93

Please sign in to comment.