aws / aws-xray-java-agent

The official AWS X-Ray Auto Instrumentation Agent for Java.
Apache License 2.0
42 stars 18 forks source link

Agent doesn't take X-Forwarded-For header into account #78

Closed ashevtsov-wawa closed 3 years ago

ashevtsov-wawa commented 3 years ago

We keep seeing client_ip field set as 127.0.0.1 even though X-Forwarded-For header is set in the request. From X-Ray Concepts:

If a load balancer or other intermediary forwards a request to your application, X-Ray takes the client IP from the X-Forwarded-For header in the request instead of from the source IP in the IP packet.

I wonder if it's due to the use of getLocalIPAddress() method here

    private void populateHeaderToTransactionState(HttpNetworkProtocolRequestEvent requestEvent, XRayTransactionState transactionState) {
        transactionState.withHost(requestEvent.getHost())
                .withMethod(requestEvent.getMethod())
                .withUrl(requestEvent.getURL())
                .withUserAgent(requestEvent.getUserAgent())
                .withClientIP(requestEvent.getLocalIPAddress())
                .withTraceheaderString(requestEvent.getHeaderData(HEADER_KEY));
willarmiros commented 3 years ago

Hi @ashevtsov-wawa,

Thanks for raising this issue! You're absolutely correct that this is a missing feature on the agent. I've opened #79 to address this for now.

ashevtsov-wawa commented 3 years ago

@willarmiros thanks for looking into this issue and for raising the PR. I left one comment.

ashevtsov-wawa commented 3 years ago

@willarmiros I saw that the PR got merged a month ago. Wondering when a new version is going to be released?

willarmiros commented 3 years ago

@ashevtsov-wawa apologies I was out on vacation. We can't give exact release dates but will be working to get a release out as soon as possible!

willarmiros commented 3 years ago

Fixed in 2.9.0