(t *testing.T)
| 542 | } |
| 543 | |
| 544 | func TestMetricsProvisionOTLPNoopExporter(t *testing.T) { |
| 545 | // OTEL_METRICS_EXPORTER=none makes autoexport return its built-in |
| 546 | // no-op reader, which avoids any network I/O while still exercising |
| 547 | // the full provisionOTLP -> shutdown lifecycle. |
| 548 | t.Setenv("OTEL_METRICS_EXPORTER", "none") |
| 549 | |
| 550 | ctx, _ := caddy.NewContext(caddy.Context{Context: context.Background()}) |
| 551 | |
| 552 | m := &Metrics{OTLP: true} |
| 553 | |
| 554 | if err := m.provisionOTLP(ctx); err != nil { |
| 555 | t.Fatalf("provisionOTLP returned unexpected error: %v", err) |
| 556 | } |
| 557 | if m.meterProvider == nil { |
| 558 | t.Fatalf("provisionOTLP did not create a MeterProvider") |
| 559 | } |
| 560 | |
| 561 | if err := m.shutdown(context.Background()); err != nil { |
| 562 | t.Fatalf("shutdown returned unexpected error: %v", err) |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | // shutdown on a nil receiver is a convenience so App.Stop can call it |
| 567 | // without guarding against app.Metrics being unset. |
nothing calls this directly
no test coverage detected