(t *testing.T, expectedAttributesByOpName map[string][]attribute.KeyValue, unexpectedAttributesByOpName map[string][]attribute.Key)
| 253 | } |
| 254 | |
| 255 | func assertTracingSpans(t *testing.T, expectedAttributesByOpName map[string][]attribute.KeyValue, unexpectedAttributesByOpName map[string][]attribute.Key) { |
| 256 | allSpans := spanExporter.GetSpans() |
| 257 | require.NotEmpty(t, allSpans, "expected spans to be recorded") |
| 258 | |
| 259 | for op, expectedAttributes := range expectedAttributesByOpName { |
| 260 | sp, ok := findSpanByName(allSpans, op) |
| 261 | require.True(t, ok, "expected span with operation name %q to be present, spans present were: %v", op, spanNames(allSpans)) |
| 262 | |
| 263 | for _, attr := range expectedAttributes { |
| 264 | val, ok := findAttributeByKey(sp.Attributes, attr.Key) |
| 265 | require.True(t, ok, "expected attribute with key %q with value %q to be present on span %q, got attributes: %v", attr.Key, attr.Value.AsString(), op, sp.Attributes) |
| 266 | require.Equal(t, attr.Value.AsString(), val.AsString(), "expected attribute value for key %q to match on span %q", attr.Key, op) |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | for op, unexpectedAttributes := range unexpectedAttributesByOpName { |
| 271 | sp, ok := findSpanByName(allSpans, op) |
| 272 | require.True(t, ok, "expected span with operation name %q to be present, spans present were: %v", op, spanNames(allSpans)) |
| 273 | |
| 274 | for _, attrKey := range unexpectedAttributes { |
| 275 | _, ok := findAttributeByKey(sp.Attributes, attrKey) |
| 276 | require.False(t, ok, "expected attribute with key %q to NOT be present on span %q, got attributes: %v", attrKey, op, sp.Attributes) |
| 277 | } |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | func spanNames(spans tracetest.SpanStubs) []string { |
| 282 | names := make([]string, len(spans)) |
no test coverage detected