MCPcopy Create free account
hub / github.com/google/go-cloud / Diff

Function Diff

internal/testing/oteltest/diff.go:69–79  ·  view source on GitHub ↗

Diff compares the list of spans and metric data obtained from OpenTelemetry instrumentation (using a test exporter like `sdktrace/tracetest.NewExporter` and `sdkmetric/metrictest.NewExporter`) with an expected list of calls. The span/metric name and status code/status attribute are compared. Order m

(gotSpans []sdktrace.ReadOnlySpan, gotMetrics []metricdata.ScopeMetrics, namePrefix, provider string, want []Call)

Source from the content-addressed store, hash-verified

67// provider is the name of the provider used (e.g., "aws").
68// want is the list of expected calls.
69func Diff(gotSpans []sdktrace.ReadOnlySpan, gotMetrics []metricdata.ScopeMetrics, namePrefix, provider string, want []Call) string {
70 ds := diffSpans(gotSpans, namePrefix, want)
71 dc := DiffMetrics(gotMetrics, namePrefix, provider, want)
72 if len(ds) > 0 {
73 ds = "trace: " + ds + "\n"
74 }
75 if len(dc) > 0 {
76 dc = "metrics: " + dc
77 }
78 return ds + dc
79}
80
81func mapStatusCode(code gcerrors.ErrorCode) codes.Code {
82 // For gcerrors used by gocloud, OK -> Ok, everything else -> Error is common.

Callers 4

TestOpenTelemetryFunction · 0.92
TestOpenTelemetryFunction · 0.92
TestOpenTelemetryFunction · 0.92
TestOpenTelemetryFunction · 0.92

Calls 2

diffSpansFunction · 0.85
DiffMetricsFunction · 0.85

Tested by 4

TestOpenTelemetryFunction · 0.74
TestOpenTelemetryFunction · 0.74
TestOpenTelemetryFunction · 0.74
TestOpenTelemetryFunction · 0.74