io.quarkus.websockets.next.runtime.telemetry.TelemetrySupport Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-websockets-next Show documentation
Show all versions of quarkus-websockets-next Show documentation
Implementation of the WebSocket API with enhanced efficiency and usability
package io.quarkus.websockets.next.runtime.telemetry;
import java.util.Map;
import io.quarkus.websockets.next.runtime.WebSocketConnectionBase;
import io.quarkus.websockets.next.runtime.WebSocketEndpoint;
/**
* Integrates traces into WebSockets with {@link WebSocketEndpoint} decorator.
*/
public abstract class TelemetrySupport {
private final ConnectionInterceptor connectionInterceptor;
TelemetrySupport(ConnectionInterceptor connectionInterceptor) {
this.connectionInterceptor = connectionInterceptor;
}
public abstract WebSocketEndpoint decorate(WebSocketEndpoint endpoint, WebSocketConnectionBase connection);
public boolean interceptConnection() {
return connectionInterceptor != null;
}
/**
* Collects telemetry when WebSocket connection is opened.
* Only supported when {@link #interceptConnection()}.
*/
public void connectionOpened() {
connectionInterceptor.connectionOpened();
}
/**
* Collects telemetry when WebSocket connection opening failed.
* Only supported when {@link #interceptConnection()}.
*/
public void connectionOpeningFailed(Throwable throwable) {
connectionInterceptor.connectionOpeningFailed(throwable);
}
protected Map getContextData() {
return connectionInterceptor == null ? Map.of() : connectionInterceptor.getContextData();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy