Skip to content

Commit c60d7c3

Browse files
committed
fix dict key failed in requests
> add testcase for **parameters
1 parent 0710996 commit c60d7c3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

plugins/PY/pinpointPy/libs/_requests/NextSpanPlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def isSample(*args, **kwargs):
4646

4747
def onBefore(self, parentId, *args, **kwargs):
4848
traceId, _args, _kwargs = super().onBefore(parentId, *args, **kwargs)
49-
url = _args[1]
49+
url = kwargs.get('url') or args[1]
5050
target = urlparse(url).netloc
5151
###############################################################
5252
pinpoint.add_trace_header(

plugins/PY/pinpointPy/libs/_requests/test_case.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ def test_request(self):
6565
httpbin = create_http_bin_response(body.text)
6666
self.assertIn(Defines.PP_HEADER_PINPOINT_SPANID, httpbin.headers)
6767

68+
@PinTransaction("testcase", GenTestHeader())
69+
def test_request_kwargs(self):
70+
import requests
71+
parameters = {
72+
'method': "POST", "url": 'http://httpbin/anything', "data": 'abc'
73+
}
74+
body = requests.request(**parameters)
75+
httpbin = create_http_bin_response(body.text)
76+
self.assertIn(Defines.PP_HEADER_PINPOINT_SPANID, httpbin.headers)
77+
6878
def test_request_no_transaction(self):
6979
import requests
7080
from threading import Thread

0 commit comments

Comments
 (0)