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

Function TestFieldForResourceWithEvolution

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

Source from the content-addressed store, hash-verified

120}
121
122func TestFieldForResourceWithEvolution(t *testing.T) {
123 ctx := context.Background()
124 releaseTime := time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)
125 evolutions := mockEvolutionData(releaseTime)
126
127 testCases := []struct {
128 name string
129 key telemetrytypes.TelemetryFieldKey
130 tsStart uint64
131 tsEnd uint64
132 expectedResult string
133 }{
134 {
135 name: "Window straddles release - both columns",
136 key: telemetrytypes.TelemetryFieldKey{
137 Name: "service.name",
138 FieldContext: telemetrytypes.FieldContextResource,
139 Evolutions: evolutions,
140 },
141 tsStart: uint64(time.Date(2024, 6, 1, 0, 0, 0, 0, time.UTC).UnixNano()),
142 tsEnd: uint64(time.Date(2025, 6, 1, 0, 0, 0, 0, time.UTC).UnixNano()),
143 expectedResult: "multiIf(resource.`service.name` IS NOT NULL, resource.`service.name`::String, mapContains(resources_string, 'service.name'), resources_string['service.name'], NULL)",
144 },
145 {
146 name: "Window fully after release - JSON column only",
147 key: telemetrytypes.TelemetryFieldKey{
148 Name: "service.name",
149 FieldContext: telemetrytypes.FieldContextResource,
150 Evolutions: evolutions,
151 },
152 tsStart: uint64(time.Date(2025, 6, 1, 0, 0, 0, 0, time.UTC).UnixNano()),
153 tsEnd: uint64(time.Date(2025, 7, 1, 0, 0, 0, 0, time.UTC).UnixNano()),
154 expectedResult: "resource.`service.name`::String",
155 },
156 {
157 name: "Window fully before release - map column only",
158 key: telemetrytypes.TelemetryFieldKey{
159 Name: "service.name",
160 FieldContext: telemetrytypes.FieldContextResource,
161 Evolutions: evolutions,
162 },
163 tsStart: uint64(time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC).UnixNano()),
164 tsEnd: uint64(time.Date(2024, 6, 1, 0, 0, 0, 0, time.UTC).UnixNano()),
165 expectedResult: "resources_string['service.name']",
166 },
167 {
168 name: "Window fully after release - materialized resource",
169 key: telemetrytypes.TelemetryFieldKey{
170 Name: "deployment.environment",
171 FieldContext: telemetrytypes.FieldContextResource,
172 FieldDataType: telemetrytypes.FieldDataTypeString,
173 Materialized: true,
174 Evolutions: evolutions,
175 },
176 tsStart: uint64(time.Date(2025, 6, 1, 0, 0, 0, 0, time.UTC).UnixNano()),
177 tsEnd: uint64(time.Date(2025, 7, 1, 0, 0, 0, 0, time.UTC).UnixNano()),
178 expectedResult: "resource.`deployment.environment`::String",
179 },

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