# WebSocketInstrumentationConfig

**Kind**: interface | **Module**: [Insights](https://docs.interop.io/desktop/reference/javascript/insights/index.md)

**Source**: https://docs.interop.io/desktop/reference/javascript/insights/websocketinstrumentationconfig/index.html

Configuration for the WebSocket instrumentation.

## Properties

- **`bytesMetric`** (`boolean | string | null`, optional) default: `false`
  If `true` or a string, a counter summing WebSocket payload bytes is published
  ("io.insights.websocket.bytes" unless a string names it), tagged with
  direction ("send" / "receive") and server.address/server.port.
- **`connectDurationMetric`** (`boolean | string | null`, optional) default: `false`
  If `true` or a string, the connection establishment time (construction until
  the open event) is published as a histogram metric
  ("io.insights.websocket.connect.duration" unless a string names it).
  Successful connections only.
- **`connectDurationMetricBuckets`** (`number[]`, optional) default: `[0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10]`
  Explicit histogram bucket boundaries for connectDurationMetric, in seconds, ascending.
- **`enabled`** (`boolean`, required)
  Whether the WebSocket instrumentation is enabled.
- **`ignoreGateway`** (`boolean`, optional) default: `false`
  If `true`, the io.Connect gateway connection is excluded from instrumentation.
  By default the gateway socket IS tracked: its connection lifecycle (connects,
  drops, close codes, reconnect attempts) is core platform-health telemetry. The
  gateway is recognized via the platform-provided connection URL
  (window.glue42gd.gwURL, compared by origin and path); where that is unavailable
  the flag has no effect - use ignorePattern to exclude infrastructure sockets
  explicitly.

  Cost note: with the message/byte metrics enabled, the gateway socket
  contributes a sample per gateway message - volume that describes io.Connect
  itself rather than the application. Enable those metrics deliberately, or set
  this flag to exclude the gateway.

  Sockets explicitly handed to the pre-init recorder via its trackWebSocket hook
  (e.g. the core-js gateway transport handing over its own connection) bypass
  this flag even when set - explicit handover is a deliberate opt-in.
  ignorePattern still applies to them and remains the veto.
- **`ignorePattern`** (`string`, optional)
  Optional regex pattern for WebSocket URLs that should be excluded from
  instrumentation - e.g. infrastructure sockets beyond the gateway connection
  (which can be excluded using ignoreGateway).
- **`matchPattern`** (`string`, optional)
  Optional regex pattern; if specified, only matching WebSocket URLs are
  instrumented.
- **`messagesMetric`** (`boolean | string | null`, optional) default: `false`
  If `true` or a string, a counter of WebSocket messages is published
  ("io.insights.websocket.messages" unless a string names it), tagged with
  direction ("send" / "receive") and server.address/server.port.
- **`platform`** (`boolean`, optional) default: `false`
  If `true`, the io.Connect Desktop platform also tracks its OWN main-process
  WebSocket connections - most importantly its gateway connection, which is
  created before the platform's io.Insights initializes: the platform's
  bootstrap installs the pre-init recorder (with WebSocket tracking enabled)
  early enough that the connection is observed from construction, and the
  platform's io.Insights instance adopts it at initialization. Read by the
  platform's bootstrap; has no effect outside the platform process.
- **`preInit`** (`boolean`, optional) default: `true`
  Unless `false`, the pre-init recorder (installEarlyInstrumentation from
- **`trace`** (`boolean`, optional) default: `true`
  If `true` (the default), each WebSocket connection is published as a span
  ("interopio.api.instrumentation.webSocket") covering construction until close,
  with connectMs, the negotiated protocol, close code/reason/wasClean, message
  and byte totals in both directions, and the connection duration. Abnormal
  closures (1006) and connection failures mark the span as ERROR.

  If `false`, no connection spans are published - metrics-only mode: the
  message/byte counters and the connect-duration histogram keep reporting.
