Package com.vaadin.extension
Class InstrumentationHelper
java.lang.Object
com.vaadin.extension.InstrumentationHelper
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final io.opentelemetry.instrumentation.api.instrumenter.Instrumenter<InstrumentationRequest,Void> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanDetermines whether a higher-level instrumentation, for example a servlet or application server instrumentation, has already created a root server span.static voidendRootSpan(jakarta.servlet.http.HttpServletResponse servletResponse, io.opentelemetry.context.Context context, Throwable throwable) Ends the root span from the specified context.static voidendSpan(io.opentelemetry.api.trace.Span span, Throwable throwable, io.opentelemetry.context.Scope scope) Ends the provided span.static io.opentelemetry.context.ContextenhanceRootSpan(jakarta.servlet.http.HttpServletRequest servletRequest, io.opentelemetry.context.Context context) Enhances the root span with data from a servlet request adds additional data to the context, like session ID.getActiveRouteTemplate(com.vaadin.flow.component.UI ui) Get the route template for the currently active view.static StringgetRequestFilename(jakarta.servlet.http.HttpServletRequest request) Get the file name from the HTTP request.getRouteTemplateForLocation(String location) Get the route template for the provided locationstatic io.opentelemetry.api.trace.Tracerstatic voidhandleException(io.opentelemetry.api.trace.Span span, Throwable throwable) static booleanisRequestType(jakarta.servlet.http.HttpServletRequest servletRequest, String requestType) static io.opentelemetry.context.ContextstartRootSpan(jakarta.servlet.http.HttpServletRequest servletRequest) Creates a server root span from the HTTP servlet request, and returns a context containing the created spanstatic io.opentelemetry.api.trace.SpanCreates and starts a new span with the provided name.static io.opentelemetry.api.trace.SpanCreates and starts a new span with the provided name, at the provided start timestamp.static voidupdateHttpRoute(com.vaadin.flow.component.UI ui)
-
Field Details
-
INSTRUMENTATION_NAME
- See Also:
-
INSTRUMENTATION_VERSION
- See Also:
-
INSTRUMENTER
public static final io.opentelemetry.instrumentation.api.instrumenter.Instrumenter<InstrumentationRequest,Void> INSTRUMENTER
-
-
Constructor Details
-
InstrumentationHelper
public InstrumentationHelper()
-
-
Method Details
-
getTracer
public static io.opentelemetry.api.trace.Tracer getTracer() -
startSpan
Creates and starts a new span with the provided name. Also adds common attributes provided by Vaadin contexts.- Parameters:
spanName- the name of the span- Returns:
- the new span
-
startSpan
Creates and starts a new span with the provided name, at the provided start timestamp. Also adds common attributes provided by Vaadin contexts.- Parameters:
spanName- the name of the spanstartTimestamp- the start timestamp of the span- Returns:
- the new span
-
endSpan
public static void endSpan(io.opentelemetry.api.trace.Span span, Throwable throwable, io.opentelemetry.context.Scope scope) Ends the provided span. If throwable is not null, then the error message and stacktrace will be added to the span, and the span status is set toStatusCode.ERROR. If a scope is provided, then the scope will be closed as well.- Parameters:
span- the span to endthrowable- the throwable to record, or nullscope- the scope to close, or null
-
startRootSpan
public static io.opentelemetry.context.Context startRootSpan(jakarta.servlet.http.HttpServletRequest servletRequest) Creates a server root span from the HTTP servlet request, and returns a context containing the created span- Parameters:
servletRequest- the servlet request- Returns:
- the context that was created
-
endRootSpan
public static void endRootSpan(jakarta.servlet.http.HttpServletResponse servletResponse, io.opentelemetry.context.Context context, Throwable throwable) Ends the root span from the specified context.- Parameters:
servletResponse- the response for the current server root spancontext- the context that contains the root spanthrowable- the throwable to record, or null
-
enhanceRootSpan
public static io.opentelemetry.context.Context enhanceRootSpan(jakarta.servlet.http.HttpServletRequest servletRequest, io.opentelemetry.context.Context context) Enhances the root span with data from a servlet request adds additional data to the context, like session ID.- Parameters:
servletRequest- the request- Returns:
- the created context
-
checkRootSpan
public static boolean checkRootSpan()Determines whether a higher-level instrumentation, for example a servlet or application server instrumentation, has already created a root server span.- Returns:
- whether a server root span already exists
-
updateHttpRoute
public static void updateHttpRoute(com.vaadin.flow.component.UI ui) -
getActiveRouteTemplate
Get the route template for the currently active view.- Parameters:
ui- Current UI to get active view path for.- Returns:
- view template if available, else
Optional.empty()
-
getRouteTemplateForLocation
Get the route template for the provided location- Parameters:
location- the location for which to get the route- Returns:
- view template if available, else
Optional.empty()
-
handleException
-
getRequestFilename
Get the file name from the HTTP request.- Parameters:
request- http request to get file name from- Returns:
- file name
-
isRequestType
public static boolean isRequestType(jakarta.servlet.http.HttpServletRequest servletRequest, String requestType)
-