WsDiagnostics class final
Provider-agnostic WebSocket diagnostics emitter.
Owns the orchestration shared by every WebSocket client: a per-session
correlation id, settings-driven filtering, redaction, metrics
normalization, and emission via the ws-* trace keys. Concrete clients
bind by pushing events through the WsDiagnosticsSink contract; the two
ws-specific reads of the old interceptor (metrics.lastUrl,
metrics.toJson()) become the optional url and metrics arguments.
Depends only on ispectify — no WebSocket package is required.
- Implemented types
Constructors
- WsDiagnostics({required ISpectLogger logger, ISpectWSInterceptorSettings settings = const ISpectWSInterceptorSettings(), String source = defaultSource, RedactionService? redactor})
Properties
- enableRedaction → bool
-
Whether redaction is enabled for this interceptor.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- logger → ISpectLogger
-
The logger instance for network logging.
no setter
- redactor → RedactionService
-
The redaction service for this interceptor.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- settings → ISpectWSInterceptorSettings
-
Filtering, redaction toggle, and print toggles for emitted logs.
final
- source → String
-
Source label attached to every emitted log (e.g.
ws,socket_io).final
Methods
-
newConnection(
) → void -
Resets the correlation id, starting a new connection session.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onError(
Object error, StackTrace stackTrace, {String? url}) → void -
Records a connection-level error not tied to a single frame.
override
-
onReceived(
Object data, {String? url, Map< String, Object?> ? metrics}) → void -
Records an inbound frame.
urlandmetricsare optional context.override -
onSent(
Object data, {String? url, Map< String, Object?> ? metrics}) → void -
Records an outbound frame.
urlandmetricsare optional context.override -
onStateChanged(
WsConnectionState state, {String? url, Object? raw}) → void -
Records a connection-state transition.
rawis the client's own state object, retained as a stringified hint when present.override -
processMapData(
Map data, {required bool useRedaction}) → Map< String, dynamic> -
Processes and redacts a map, ensuring string keys.
inherited
-
redactUrl(
String url, {required bool useRedaction}) → String -
Redacts query parameter values and userInfo credentials in a URL.
inherited
-
redactUrlAndPath(
Uri uri, {required bool useRedaction}) → ({String path, String url}) -
Redacts both URL and path from a Uri in one call.
inherited
-
safeRedact(
Object data, {required bool useRedaction}) → Object -
Applies redaction with error handling: logs a warning and returns
a placeholder on failure instead of propagating the exception.
inherited
-
shouldProcess<
T> ({required bool enabled, required bool filter(T)?, required T value}) → bool -
Returns
truewhen the interceptor isenabledand the optionalfiltereither isnullor returnstrueforvalue.inherited -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- defaultSource → const String
- Default source label used when no adapter-specific label is given.