-
Notifications
You must be signed in to change notification settings - Fork 621
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
Add falcon version 1.4.1 support to opentelemetry-instrumentation-falcon #1000
Conversation
In falcon 3, not setting remote_addr leads to an error where net.peer.ip is not set in the span. Between falcon 2 and falcon 3, there was a slightly less than documented change (falconry/falcon#1573) where REMOTE_ADDR is not always set and is therefore not always readable. Removing the optional remote_addr arg from the simulate_request call (to support falcon 1.4.1) then borked the behavior in falcon 3 (where it used to be totally optional in falcon 2) https://github.com/falconry/falcon/blob/2.0.0/falcon/testing/helpers.py#L176 Function that sets the net.peer.ip var |
Given how this is handled in the wsgi instrumentation, I am going to update the tests to make the NET_PEER_IP optional. Lines 195 to 197 in fcba751
|
Tested locally and working for all three versions, ready for review and approval to run the test suite here. |
SpanAttributes.NET_PEER_PORT: "65133", | ||
SpanAttributes.HTTP_FLAVOR: "1.1", | ||
"falcon.resource": "HelloWorldResource", | ||
SpanAttributes.HTTP_STATUS_CODE: 201, | ||
}, | ||
) | ||
if SpanAttributes.NET_PEER_IP in span.attributes: | ||
self.assertEqual( | ||
span.attributes[SpanAttributes.NET_PEER_IP], "127.0.0.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious, if remote_addr="127.0.0.1"
was removed from the call to simulate_request
then why should it appear here? Is this a default value? If so, it would be good to test also a non-default value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In falcon 1.4.1 (the new version added in this PR), the remote_addr param doesn't exist. This to me wasn't a huge deal as in the tests, it was being tested with the default value anyways, '127.0.0.1'. So I removed the remote_addr param from the tests.
However in falcon 3.x, there was an update to the code that was made which doesn't set the remote_addr if the default value is used. (See my comment above) or
https://github.com/falconry/falcon/blob/2.0.0/falcon/testing/helpers.py#L176
vs
https://github.com/falconry/falcon/blob/3.0.1/falcon/testing/helpers.py#L1168-L1172
This is different to how it was done in falcon 2.x where the remote_addr was always set, just with the default value.
The if statement in the test here was a compromise to show that there is something strange going on between the different versions.
If you have any thoughts on this, please let me know. I am open to suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, that's fine, can you please add this explanation to the test as a comment? ✌️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added. Thank you
@owais |
ed0e0e1
to
fd03868
Compare
7e2d6c9
to
0f3111c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments, LGTM.
...on/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py
Outdated
Show resolved
Hide resolved
...on/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py
Outdated
Show resolved
Hide resolved
instrumentation/opentelemetry-instrumentation-falcon/tests/app.py
Outdated
Show resolved
Hide resolved
@srikanthccv Not sure what to do here. Lint locally seems to be failing due to this commit, 40c1805 Specifically this
|
If it's not related to your changes please ignore. We will get that fixed in separate PR. |
Thanks @srikanthccv |
...on/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking till we resolve the transitive dep comment
@rjduffner Please add |
@srikanthccv packaging dependency has been added to the setup.cfg. |
Description
The largest change between falcon 1.x and 2.x was the changing the placement of some exception args. This PR adds some logic to place those args in the correct places for all versions of falcon.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.