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

Function TestOpenTelemetry

secrets/secrets_test.go:94–124  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

92}
93
94func TestOpenTelemetry(t *testing.T) {
95
96 ctx := context.Background()
97
98 te := oteltest.NewTestExporter(t, OpenTelemetryViews)
99
100 k := NewKeeper(&erroringKeeper{})
101 defer k.Close()
102 _, _ = k.Encrypt(ctx, nil)
103
104 _, _ = k.Decrypt(ctx, nil)
105 _, _ = k.Decrypt(ctx, nil)
106
107 // Check collected spans.
108 spanStubs := te.GetSpans()
109 metrics := te.GetMetrics(ctx)
110 diff := oteltest.Diff(spanStubs.Snapshots(), metrics, pkgName, "gocloud.dev/secrets", []oteltest.Call{
111 {Method: "Encrypt", Code: gcerrors.Internal},
112 {Method: "Decrypt", Code: gcerrors.Internal},
113 {Method: "Decrypt", Code: gcerrors.Internal},
114 })
115 if diff != "" {
116 t.Error(diff)
117 }
118
119 if err := te.Shutdown(ctx); err != nil {
120 // Just log and continue - not failing the test on shutdown errors.
121 t.Logf("OpenTelemetry shutdown error (non-fatal): %v", err)
122 }
123
124}
125
126func TestURLMux(t *testing.T) {
127 ctx := context.Background()

Callers

nothing calls this directly

Calls 10

CloseMethod · 0.95
EncryptMethod · 0.95
DecryptMethod · 0.95
GetSpansMethod · 0.95
GetMetricsMethod · 0.95
ShutdownMethod · 0.95
NewTestExporterFunction · 0.92
DiffFunction · 0.92
NewKeeperFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected