(t *testing.T)
| 92 | } |
| 93 | |
| 94 | func 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 | |
| 126 | func TestURLMux(t *testing.T) { |
| 127 | ctx := context.Background() |
nothing calls this directly
no test coverage detected