Skip to content

HttpServletRequest is not included in RequestTelemetryContext #1247

@librucha

Description

@librucha

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):

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions