MCPcopy
hub / github.com/SigNoz/signoz / TestGetFieldKeyName

Function TestGetFieldKeyName

pkg/telemetrytraces/field_mapper_test.go:14–120  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestGetFieldKeyName(t *testing.T) {
15 ctx := context.Background()
16
17 mockEvolution := mockEvolutionData(time.Date(2024, 6, 2, 0, 0, 0, 0, time.UTC))
18 testCases := []struct {
19 name string
20 key telemetrytypes.TelemetryFieldKey
21 expectedResult string
22 expectedError error
23 }{
24 {
25 name: "Simple column type - timestamp",
26 key: telemetrytypes.TelemetryFieldKey{
27 Name: "timestamp",
28 FieldContext: telemetrytypes.FieldContextSpan,
29 },
30 expectedResult: "timestamp",
31 expectedError: nil,
32 },
33 {
34 name: "Map column type - string attribute",
35 key: telemetrytypes.TelemetryFieldKey{
36 Name: "user.id",
37 FieldContext: telemetrytypes.FieldContextAttribute,
38 FieldDataType: telemetrytypes.FieldDataTypeString,
39 },
40 expectedResult: "attributes_string['user.id']",
41 expectedError: nil,
42 },
43 {
44 name: "Map column type - number attribute",
45 key: telemetrytypes.TelemetryFieldKey{
46 Name: "request.size",
47 FieldContext: telemetrytypes.FieldContextAttribute,
48 FieldDataType: telemetrytypes.FieldDataTypeNumber,
49 },
50 expectedResult: "attributes_number['request.size']",
51 expectedError: nil,
52 },
53 {
54 name: "Map column type - bool attribute",
55 key: telemetrytypes.TelemetryFieldKey{
56 Name: "request.success",
57 FieldContext: telemetrytypes.FieldContextAttribute,
58 FieldDataType: telemetrytypes.FieldDataTypeBool,
59 },
60 expectedResult: "attributes_bool['request.success']",
61 expectedError: nil,
62 },
63 {
64 name: "Map column type - resource attribute",
65 key: telemetrytypes.TelemetryFieldKey{
66 Name: "service.name",
67 FieldContext: telemetrytypes.FieldContextResource,
68 Evolutions: mockEvolution,
69 },
70 expectedResult: "multiIf(resource.`service.name` IS NOT NULL, resource.`service.name`::String, mapContains(resources_string, 'service.name'), resources_string['service.name'], NULL)",
71 expectedError: nil,

Callers

nothing calls this directly

Calls 5

FieldForMethod · 0.95
mockEvolutionDataFunction · 0.70
NewFieldMapperFunction · 0.70
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected