[
https://issues.apache.org/jira/browse/CASSANDRA-8162?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14354275#comment-14354275
]
Aleksey Yeschenko commented on CASSANDRA-8162:
----------------------------------------------
It would work as is, but I want us to make some changes before committing it:
1. There is no need to log an extra event with the IP. Simply having the client
ip address in the option stored in {{system_traces.sessions}} is enough.
2. {{ClientState#getRemoteAddress()}} will always be either {{null}} or an
instance of {{InetSocketAddress}}, so that instanceof check is redundant. We
should get rid of it, and also update {{ClientState.remoteAddress}} field to be
of type {{InetSocketAddress}}, plus update {{ClientState#getRemoteAddress()}}
accordingly.
3. The {{null}} check should be replaced with a {{ClientState.isInternal}}
check. Non-internal {{ClientState}} instances will always have
{{remoteAddress}} present.
4. Passing {{null}} for non-existent options and {{""}} for non-existent query
is a bit ugly, we should avoid that. I understand the desire to avoid
duplication, but I think there is a slightly better way:
- replace the use of {{ImmutableMap}} and {{Collections.emptyMap()}} in
{{BatchMessage}}, {{ExecuteMessage}}, {{PrepareMessage}}, and {{QueryMessage}}
with regular {{HashMap}}/{{TreeMap}}. Nothing requires them to be immutable,
it's merely a syntactic thing
- add another overloaded version of {{Tracing#begin()}} that would accept
{{ClientState}} as third argument
- make it add {{"client"}} ip address to the {{parameters}} map if
{{!ClientState.isInternal}} before forwarding to the original
{{Tracing#begin()}} method
Re-labeling as 3.0 because of the {{ClientState.remoteAddress}} field type
change.
> Log client address in query trace
> ---------------------------------
>
> Key: CASSANDRA-8162
> URL: https://issues.apache.org/jira/browse/CASSANDRA-8162
> Project: Cassandra
> Issue Type: Improvement
> Components: Core
> Reporter: Tyler Hobbs
> Assignee: Stefania
> Priority: Minor
> Fix For: 3.0
>
> Attachments: 8162.txt
>
>
> With probabilistic tracing, it can be helpful to log the source IP for
> queries.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)