MCPcopy
hub / github.com/grafana/tempo / extractTenant

Function extractTenant

modules/frontend/util.go:15–26  ·  view source on GitHub ↗

extractTenant extracts tenant ID from request context and returns HTTP error response if extraction fails

(req *http.Request, logger log.Logger)

Source from the content-addressed store, hash-verified

13
14// extractTenant extracts tenant ID from request context and returns HTTP error response if extraction fails
15func extractTenant(req *http.Request, logger log.Logger) (string, *http.Response) {
16 tenant, err := user.ExtractOrgID(req.Context())
17 if err != nil {
18 level.Error(logger).Log("msg", "failed to extract tenant id", "err", err)
19 return "", &http.Response{
20 StatusCode: http.StatusBadRequest,
21 Status: http.StatusText(http.StatusBadRequest),
22 Body: io.NopCloser(strings.NewReader(err.Error())),
23 }
24 }
25 return tenant, nil
26}
27
28func acceptAllBlocks(_ *backend.BlockMeta) bool { return true }

Callers 10

TestExtractTenantFunction · 0.85
newSearchHTTPHandlerFunction · 0.85
newTraceIDHandlerFunction · 0.85
newTraceIDV2HandlerFunction · 0.85
newTagsHTTPHandlerFunction · 0.85
newTagsV2HTTPHandlerFunction · 0.85
newTagValuesHTTPHandlerFunction · 0.85

Calls 3

ContextMethod · 0.65
LogMethod · 0.65
ErrorMethod · 0.65

Tested by 1

TestExtractTenantFunction · 0.68