Class SpringMetricsServiceInitListener

java.lang.Object
com.vaadin.observability.micrometer.MetricsServiceInitListener
com.vaadin.observability.spring.SpringMetricsServiceInitListener
All Implemented Interfaces:
com.vaadin.flow.server.VaadinServiceInitListener, Serializable, EventListener

public final class SpringMetricsServiceInitListener extends MetricsServiceInitListener
Spring/Boot-aware MetricsServiceInitListener that skips the default Observation handler registration and enriches the HTTP server observation.

In Spring/Boot setups the framework already registers a DefaultMeterObservationHandler on the shared ObservationRegistry (via Boot's ObservationAutoConfiguration or the user's own @Configuration), so re-registering here would double-emit Timers. HTTP observation enrichment is delegated to SpringHttpObservationEnricher, making the parent HTTP span render as e.g. http post /vaadin/uidl instead of the generic http post /**, and marking it errored when Vaadin request handling raises an exception the servlet chain never sees.

This class is declared public so it can be reused by both ObservabilityConfiguration (plain-Spring import) and the Boot auto-configuration starter.

See Also:
  • Constructor Details

    • SpringMetricsServiceInitListener

      public SpringMetricsServiceInitListener(io.micrometer.core.instrument.MeterRegistry registry, io.micrometer.observation.ObservationRegistry observationRegistry, ObservabilitySettings settings)
      Creates a new listener.
      Parameters:
      registry - the Micrometer meter registry, must not be null
      observationRegistry - the Micrometer observation registry; may be null when no ObservationRegistry bean is present — traces will be skipped in that case
      settings - the observability settings, must not be null
  • Method Details