MCPcopy
hub / github.com/grafana/dskit / TestOTelSpanCreatedWithTenantAttribute

Function TestOTelSpanCreatedWithTenantAttribute

spanlogger/otel_spanlogger_test.go:226–238  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

224}
225
226func TestOTelSpanCreatedWithTenantAttribute(t *testing.T) {
227 t.Cleanup(spanExporter.Reset)
228
229 ctx := user.InjectOrgID(context.Background(), "team-a")
230 sp, _ := NewOTel(ctx, log.NewNopLogger(), tracer, "name", tenant.NewMultiResolver())
231 sp.Finish()
232
233 spans := spanExporter.GetSpans()
234 require.Len(t, spans, 1, "There should be exactly one span after the span is finished")
235 exportedSpan := spans[0]
236
237 require.Equal(t, []attribute.KeyValue{attribute.StringSlice(TenantIDsTagName, []string{"team-a"})}, exportedSpan.Attributes)
238}
239
240func TestOTelSpanCreatedWithMultipleTenantsAttribute(t *testing.T) {
241 t.Cleanup(spanExporter.Reset)

Callers

nothing calls this directly

Calls 6

InjectOrgIDFunction · 0.92
NewMultiResolverFunction · 0.92
NewOTelFunction · 0.85
FinishMethod · 0.45
LenMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected