Skip to content

Commit

Permalink
[bug] fix requests.request (#573)
Browse files Browse the repository at this point in the history
- test case

close #572
  • Loading branch information
eeliu committed Mar 28, 2024
1 parent 3112ffd commit 20e4205
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@ RUN wget https://go.dev/dl/go1.18.10.linux-amd64.tar.gz -O /home/pinpoint/go1.18
RUN rm -rf /usr/local/go && cd /home/pinpoint/ && tar -C /usr/local -xzf go1.18.10.linux-amd64.tar.gz
ENV PATH=$PATH:/usr/local/go/bin
ENV PATH=$PATH:/home/pinpoint/go/bin
ENV GO111MODULE="on"
RUN go install google.golang.org/protobuf/cmd/[email protected] && go install google.golang.org/grpc/cmd/[email protected]
2 changes: 0 additions & 2 deletions .devcontainer/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ services:
image: kennethreitz/httpbin:latest
container_name: httpbin
hostname: httpbin
# ports:
# - 8999:80
volumes:
- ..:/workspace:cached

Expand Down
3 changes: 2 additions & 1 deletion plugins/PY/pinpointPy/libs/_requests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def monkey_patch():
from .NextSpanPlugin import NextSpanPlugin

Interceptors = [
Interceptor(requests.api, 'request', NextSpanPlugin)
Interceptor(requests.api, 'request', NextSpanPlugin),
Interceptor(requests, 'request', NextSpanPlugin)
]

for interceptor in Interceptors:
Expand Down
7 changes: 7 additions & 0 deletions plugins/PY/pinpointPy/libs/_requests/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ def test_patch(self):
httpbin = create_http_bin_response(body.text)
self.assertIn(Defines.PP_HEADER_PINPOINT_SPANID, httpbin.headers)

@PinTransaction("testcase", GenTestHeader())
def test_request(self):
import requests
body = requests.request("POST", 'http://httpbin/anything', data='abc')
httpbin = create_http_bin_response(body.text)
self.assertIn(Defines.PP_HEADER_PINPOINT_SPANID, httpbin.headers)


if __name__ == '__main__':
unittest.main()

0 comments on commit 20e4205

Please sign in to comment.