Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: add connection span for each connection #922

Merged
merged 1 commit into from
Nov 3, 2022
Merged

Conversation

niklasad1
Copy link
Member

This PR adds another span to make it easier to see which connection that calls, errors and similar occur on.
The downside is that the logs because a bit hard to read with the standard tracing subscriber.

Example WS

2022-11-02T14:47:15.885354Z TRACE connection{remote_addr=127.0.0.1:56206 conn_id=0}: jsonrpsee_server::server: Request { method: GET, uri: /, version: HTTP/1.1, headers: {"host": "127.0.0.1:36521", "upgrade": "websocket", "connection": "Upgrade", "sec-websocket-key": "zOys8P04xwmfdDykx/yJXA==", "sec-websocket-version": "13"}, body: Body(Empty) }
2022-11-02T14:47:15.885645Z  INFO connection{remote_addr=127.0.0.1:56206 conn_id=0}: jsonrpsee_server::server: Accepting new connection 1/100
2022-11-02T14:47:15.886040Z DEBUG jsonrpsee_server::transport::ws: Send ping
2022-11-02T14:47:15.886520Z DEBUG connection{remote_addr=127.0.0.1:56206 conn_id=0}: jsonrpsee_server::transport::ws: Received pong
2022-11-02T14:47:15.886773Z TRACE connection{remote_addr=127.0.0.1:56206 conn_id=0}:method_call{method="say_hello"}: jsonrpsee_core::tracing: recv="{\"jsonrpc\":\"2.0\",\"id\":0,\"method\":\"say_hello\",\"params\":null}"
2022-11-02T14:47:15.886831Z TRACE connection{remote_addr=127.0.0.1:56206 conn_id=0}:method_call{method="say_hello"}: jsonrpsee_core::tracing: send="{\"jsonrpc\":\"2.0\",\"result\":\"lo\",\"id\":0}"
2022-11-02T14:47:15.886875Z TRACE connection{remote_addr=127.0.0.1:56206 conn_id=0}: jsonrpsee_core::tracing: send="{\"jsonrpc\":\"2.0\",\"result\":\"lo\",\"id\":0}"

Example HTTP

2022-11-02T14:53:21.910294Z TRACE connection{remote_addr=127.0.0.1:47568 conn_id=0}: jsonrpsee_server::server: Request { method: POST, uri: /, version: HTTP/1.1, headers: {"content-type": "application/json", "accept": "application/json", "host": "127.0.0.1:44977", "content-length": "62"}, body: Body(Streaming) }
2022-11-02T14:53:21.910566Z TRACE connection{remote_addr=127.0.0.1:47568 conn_id=0}:method_call{method="say_hello"}: jsonrpsee_core::tracing: recv="{\"jsonrpc\":\"2.0\",\"id\":0,\"method\":\"say_hello\",\"params\":[1,2,3]}"
2022-11-02T14:53:21.910627Z TRACE connection{remote_addr=127.0.0.1:47568 conn_id=0}:method_call{method="say_hello"}: jsonrpsee_core::tracing: send="{\"jsonrpc\":\"2.0\",\"result\":\"lo\",\"id\":0}"

Close #878

@niklasad1 niklasad1 requested a review from a team as a code owner November 2, 2022 15:09
Copy link
Collaborator

@jsdw jsdw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

Copy link
Contributor

@lexnv lexnv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for taking care of this!

@niklasad1 niklasad1 merged commit eaf337d into master Nov 3, 2022
@niklasad1 niklasad1 deleted the na-fix-878 branch November 3, 2022 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[server]: tag logs with connection id / ip address
3 participants