Expected behavior
ThreadContext.getRequestTelemetryContext().getHttpServletRequest() returns current servlet request if is implementation of HttpServletRequest
Actual behavior
returns always null
To Reproduce
Steps to reproduce the behavior:
Create own Telemetry initializer
in onInitializeTelemetry call ThreadContext.getRequestTelemetryContext().getHttpServletRequest()
Sample Application
@FieldDefaults(level = PRIVATE, makeFinal = true)
@RequiredArgsConstructor
public class OwnTelemetryInitializer extends WebTelemetryInitializerBase {
@Override
protected void onInitializeTelemetry(Telemetry telemetry) {
Optional.ofNullable(ThreadContext.getRequestTelemetryContext())
.map(RequestTelemetryContext::getHttpServletRequest)
.map(HttpServletRequest::getRemoteAddr)
.ifPresent(
clientIp -> telemetry.getContext().getLocation().setIp(clientIp)
);
}
}
System information
Please provide the following information:
- SDK Version: 2.6.0
- OS type and version: MacOS Catalina 10.15.4
- Using spring-boot? YES
- Additional relevant libraries (with version, if applicable):
Expected behavior
ThreadContext.getRequestTelemetryContext().getHttpServletRequest()returns current servlet request if is implementation of HttpServletRequestActual behavior
returns always
nullTo Reproduce
Steps to reproduce the behavior:
Create own Telemetry initializer
in onInitializeTelemetry call
ThreadContext.getRequestTelemetryContext().getHttpServletRequest()Sample Application
System information
Please provide the following information: