TestPanic tests that registering two metrics with the same name across any type of metric triggers a panic.
(t *testing.T)
| 38 | // TestPanic tests that registering two metrics with the same name across any |
| 39 | // type of metric triggers a panic. |
| 40 | func (s) TestPanic(t *testing.T) { |
| 41 | cleanup := snapshotMetricsRegistryForTesting() |
| 42 | defer cleanup() |
| 43 | |
| 44 | want := "metric simple counter already registered" |
| 45 | defer func() { |
| 46 | if r := recover(); !strings.Contains(fmt.Sprint(r), want) { |
| 47 | t.Errorf("expected panic contains %q, got %q", want, r) |
| 48 | } |
| 49 | }() |
| 50 | desc := MetricDescriptor{ |
| 51 | // Type is not expected to be set from the registerer, but meant to be |
| 52 | // set by the metric registry. |
| 53 | Name: "simple counter", |
| 54 | Description: "number of times recorded on tests", |
| 55 | Unit: "{call}", |
| 56 | } |
| 57 | RegisterInt64Count(desc) |
| 58 | RegisterInt64Gauge(desc) |
| 59 | } |
| 60 | |
| 61 | // TestInstrumentRegistry tests the metric registry. It registers testing only |
| 62 | // metrics using the metric registry, and creates a fake metrics recorder which |
nothing calls this directly
no test coverage detected