-
public final class ApmNetworkInstrumentationFor 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.
-
-
Field Summary
Fields Modifier and Type Field Description private final SdkCoresdkCoreprivate final SdkReferencesdkCoreReferenceprivate final FloatsampleRateprivate final Set<TracingHeaderType>localHeaderTypesprivate final StringsdkInstanceNameprivate final StringtraceOriginprivate final ApmNetworkTracingScopenetworkTracingScope
-
Method Summary
Modifier and Type Method Description final SdkCoregetSdkCore()final SdkReferencegetSdkCoreReference()Reference to the SDK core instance. final FloatgetSampleRate()final Set<TracingHeaderType>getLocalHeaderTypes()final StringgetSdkInstanceName()final StringgetTraceOrigin()final ApmNetworkTracingScopegetNetworkTracingScope()final RequestTracingStateonRequest(HttpRequestInfo request)Called when a network request is about to be sent. final UnitonResponseSucceeded(RequestTracingState requestTracingState, HttpResponseInfo response)Called when a network request succeeds. final UnitonResponseFailed(RequestTracingState requestTracingState, Throwable throwable)Called when a network request fails. final UnitremoveTracingHeaders(HttpRequestInfoBuilder requestBuilder)Removes all tracing headers from the request. final UnitreportInstrumentationError(Function0<String> messageBuilder)Reports an instrumentation error to the internal logger. -
-
Method Detail
-
getSdkCore
final SdkCore getSdkCore()
-
getSdkCoreReference
final SdkReference getSdkCoreReference()
Reference to the SDK core instance.
-
getSampleRate
final Float getSampleRate()
-
getLocalHeaderTypes
final Set<TracingHeaderType> getLocalHeaderTypes()
-
getSdkInstanceName
final String getSdkInstanceName()
-
getTraceOrigin
final String getTraceOrigin()
-
getNetworkTracingScope
final ApmNetworkTracingScope getNetworkTracingScope()
-
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
-
-
-
-