MCPcopy
hub / github.com/caddyserver/caddy / TestMetricsProvisionOTLPNoopExporter

Function TestMetricsProvisionOTLPNoopExporter

modules/caddyhttp/metrics_test.go:544–564  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

542}
543
544func 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.

Callers

nothing calls this directly

Calls 2

provisionOTLPMethod · 0.95
shutdownMethod · 0.95

Tested by

no test coverage detected