-
Notifications
You must be signed in to change notification settings - Fork 415
/
messaging.go
38 lines (33 loc) · 1.37 KB
/
messaging.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2023 Datadog, Inc.
package namingschematest
import (
"testing"
"github.com/DataDog/dd-trace-go/v2/ddtrace/mocktracer"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// NewKafkaTest creates a new test for Kafka naming schema.
func NewKafkaTest(genSpans GenSpansFn) func(t *testing.T) {
return func(t *testing.T) {
assertOpV0 := func(t *testing.T, spans []*mocktracer.Span) {
require.Len(t, spans, 2)
assert.Equal(t, "kafka.produce", spans[0].OperationName())
assert.Equal(t, "kafka.consume", spans[1].OperationName())
}
assertOpV1 := func(t *testing.T, spans []*mocktracer.Span) {
require.Len(t, spans, 2)
assert.Equal(t, "kafka.send", spans[0].OperationName())
assert.Equal(t, "kafka.process", spans[1].OperationName())
}
wantServiceNameV0 := ServiceNameAssertions{
WithDefaults: []string{"kafka", "kafka"},
WithDDService: []string{"kafka", TestDDService},
WithDDServiceAndOverride: []string{TestServiceOverride, TestServiceOverride},
}
t.Run("ServiceName", NewServiceNameTest(genSpans, wantServiceNameV0))
t.Run("SpanName", NewSpanNameTest(genSpans, assertOpV0, assertOpV1))
}
}