Skip to content

Commit

Permalink
linting fixes and CHANGELOG update
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminsky committed Oct 5, 2021
1 parent 38d38d4 commit 7baaea4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#686](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/686))
- `opentelemetry-instrumentation-tornado` now sets `http.client_ip` and `tornado.handler` attributes
([#706](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/706))
- `opentelemetry-instrumentation-requests` added `tracked_url_callback`
([#714](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/714))

### Changed
- `opentelemetry-instrumentation-botocore` Unpatch botocore Endpoint.prepare_request on uninstrument
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@
# pylint: disable=unused-argument
# pylint: disable=R0915
def _instrument(
tracer,
span_callback=None,
name_callback=None,
tracked_url_callback=None,
tracer, span_callback=None, name_callback=None, tracked_url_callback=None
):
"""Enables tracing of all requests calls that go through
:code:`requests.session.Session.request` (this includes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,14 @@ def test_tracked_url_callback(self):
httpretty.register_uri(
httpretty.GET, url_404, status=404,
)

def tracked_url_callback(method, url):
return "404" not in url

RequestsInstrumentor().uninstrument()
RequestsInstrumentor().instrument(tracked_url_callback=tracked_url_callback)
RequestsInstrumentor().instrument(
tracked_url_callback=tracked_url_callback
)
self.perform_request(self.URL)
self.perform_request(url_404)

Expand Down Expand Up @@ -271,7 +274,7 @@ def span_callback(span, result: requests.Response):
{
SpanAttributes.HTTP_METHOD: "GET",
SpanAttributes.HTTP_URL: self.URL,
SpanAttributes.HTTP_STATUS_CODE: 200,
SpanAttributes.HTTP_STATUS_CODE: 200,
"http.response.body": "Hello!",
},
)
Expand Down

0 comments on commit 7baaea4

Please sign in to comment.