Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(py): fix redis connection
Browse files Browse the repository at this point in the history
- use format_host
eeliu committed May 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 469dc3c commit b4575e9
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ jobs:
make
./bin/TestCommon
- name: Codecovage
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4

cpp-windows:
runs-on: [windows-latest]
13 changes: 10 additions & 3 deletions plugins/PY/pinpointPy/libs/_pyRedis/PyRedisPlugins.py
Original file line number Diff line number Diff line change
@@ -26,6 +26,10 @@
from pinpointPy import Defines


def format_host(host, port, db) -> str:
return f'redis(host={host},port={port},db={db})'


class PyRedisPlugins(Common.PinTrace):

def __init__(self, name):
@@ -37,8 +41,10 @@ def onBefore(self, parentId, *args, **kwargs):
Defines.PP_INTERCEPTOR_NAME, self.getUniqueName(), trace_id)
pinpoint.add_trace_header(
Defines.PP_SERVER_TYPE, Defines.PP_REDIS, trace_id)
pinpoint.add_trace_header(
Defines.PP_DESTINATION, str(args[0]), trace_id)
from redis.connection import Connection
if isinstance(args[0], Connection):
pinpoint.add_trace_header(
Defines.PP_DESTINATION, format_host(args[0].host, args[0].port, args[0].db), trace_id)
return trace_id, args, kwargs

def onEnd(self, traceId, ret):
@@ -62,8 +68,9 @@ def onBefore(self, parentId, *args, **kwargs):
pipeLine = args[0]
# fixed: Redis Collections Not release #612
# @quicksandznzn
connection_kwargs = pipeLine.connection_pool.connection_kwargs
pinpoint.add_trace_header(
Defines.PP_DESTINATION, str(pipeLine.connection), trace_id)
Defines.PP_DESTINATION, format_host(connection_kwargs["host"], connection_kwargs["port"], connection_kwargs["db"]), trace_id)
import sys
if 'unittest' in sys.modules.keys():
pipeLine._pinpoint_ = True
4 changes: 3 additions & 1 deletion plugins/PY/pinpointPy/libs/_pyRedis/__init__.py
Original file line number Diff line number Diff line change
@@ -42,11 +42,13 @@ def monkey_patch():


__all__ = ['monkey_patch']
__version__ = '0.0.3'
__version__ = '0.0.4'
__author__ = 'liu.mingyi@navercorp.com'

"""
## Changes
### 0.0.4 5/22/2024
- fix 0.0.3 : use format_host
### 0.0.3 5/21/2024
- Redis Collections Not release #612
"""

0 comments on commit b4575e9

Please sign in to comment.