Package 

Class ApmNetworkInstrumentation


  • 
    public final class ApmNetworkInstrumentation
    
                        

    For internal usage only.

    Provides APM (Application Performance Monitoring) tracing instrumentation for network requests. This class handles the creation and management of trace spans for HTTP requests, including header injection, sampling decisions, and span lifecycle management.

    • Method Detail

      • getSdkCoreReference

         final SdkReference getSdkCoreReference()

        Reference to the SDK core instance.

      • onRequest

         final RequestTracingState onRequest(HttpRequestInfo request)

        Called when a network request is about to be sent. This method creates a trace span, applies sampling decisions, and injects tracing headers.

        Parameters:
        request - the HTTP request information.
      • onResponseSucceeded

         final Unit onResponseSucceeded(RequestTracingState requestTracingState, HttpResponseInfo response)

        Called when a network request succeeds. This method updates the span with response information and finishes it.

        Parameters:
        requestTracingState - the tracing state from onRequest.
        response - the HTTP response information.
      • onResponseFailed

         final Unit onResponseFailed(RequestTracingState requestTracingState, Throwable throwable)

        Called when a network request fails. This method marks the span as errored, adds error details, and finishes it.

        Parameters:
        requestTracingState - the tracing state from onRequest.
        throwable - the exception that caused the failure.
      • removeTracingHeaders

         final Unit removeTracingHeaders(HttpRequestInfoBuilder requestBuilder)

        Removes all tracing headers from the request. This is useful when starting a new independent trace for redirect requests, ensuring each redirect creates a separate root span.

        Parameters:
        requestBuilder - the request builder to remove headers from.
      • reportInstrumentationError

         final Unit reportInstrumentationError(Function0<String> messageBuilder)

        Reports an instrumentation error to the internal logger.

        Parameters:
        messageBuilder - the error message to report