Class ClientErrorCollector

java.lang.Object
com.vaadin.observability.micrometer.insights.ClientErrorCollector

public class ClientErrorCollector extends Object
Retains the detail of an error a browser reported, which vaadin.client.errors counts but cannot describe.

The counter and this collector are fed by the same sample: the in-browser collector sends the message, the script it came from and the first stack frame alongside the count, in a field that never becomes a meter tag. The count answers "how often"; the insight answers "what broke, and where" — which is the difference between knowing that browsers are failing and being able to fix it.

The detail policy is the one InteractionCollector applies to a server-side failure, and the line it draws is between a location and text the page chose.

Published unconditionally: the kind, the source, and the location of the first stack frame. The latter two go through StackFrames, which returns a location or nothing — that is what makes "none of this is free-form" true by construction rather than by enumeration.

Gated on ObservabilitySettings.isInsightsDetails(): the error's message, and the frame's function name. The message because it can quote anything the page was working with; the name for the same reason, since Object.defineProperty(f, 'name', …) takes any string and V8 prints it. With the kit's own collector the browser does not even gather the message, and this class is the second of those two gates.

  • Field Details

    • DETAIL_ROUTE

      public static final String DETAIL_ROUTE
      Detail key: the path the browser was on when the error happened.
      See Also:
    • DETAIL_MESSAGE

      public static final String DETAIL_MESSAGE
      Detail key: the error message the browser reported.
      See Also:
    • DETAIL_SOURCE

      public static final String DETAIL_SOURCE
      Detail key: where the browser said the error came from.
      See Also:
    • DETAIL_FRAME

      public static final String DETAIL_FRAME
      Detail key: the first frame of the error's stack.
      See Also:
    • DETAIL_FUNCTION

      public static final String DETAIL_FUNCTION
      Detail key: the function name from that frame. Sent separately from the frame, and only when the browser was told to collect detail, because it is a string the page chose rather than a location.
      See Also:
  • Constructor Details

  • Method Details

    • capture

      public void capture(String kind, String route, Map<String,String> detail, long bufferedMs, com.vaadin.flow.component.UI ui)
      Retains one reported browser error.

      Best-effort throughout: an error report that cannot be understood is dropped rather than allowed to fail the ingest of the batch it arrived in, which may be carrying the samples of a whole outage.

      Parameters:
      kind - MeterNames.KIND_UNCAUGHT or MeterNames.KIND_PROMISE, as the browser tagged the sample; a kind outside that set is grouped as MeterNames.KIND_UNKNOWN
      route - the route template of the view the error happened on, already resolved and cardinality-capped, may be null
      detail - the browser's description of the error, keyed by DETAIL_ROUTE, DETAIL_MESSAGE, DETAIL_SOURCE, DETAIL_FRAME and DETAIL_FUNCTION. The last two of those are the location and the name of one stack frame, sent apart because they are trusted differently
      bufferedMs - how long the report waited for the browser to reach the server again, measured on the browser's clock; 0 for a report that was only waiting for the next flush. Not the same as the error happening during an outage — a report taken while the browser was connected still accrues an outage that begins before the next flush
      ui - the UI that reported it, may be null