-
Notifications
You must be signed in to change notification settings - Fork 250
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 support to initialize azure exporters with proxies #902
Add support to initialize azure exporters with proxies #902
Conversation
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
@googlebot I fixed it. |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
I see the linting issues are causing CI to fail - I will fix those items now. I also see CI takes care of running tests against the python2 environment as well. |
contrib/opencensus-ext-azure/opencensus/ext/azure/common/__init__.py
Outdated
Show resolved
Hide resolved
@@ -42,6 +42,10 @@ def _transmit(self, envelopes): | |||
This function should never throw exception. | |||
""" | |||
try: | |||
proxies = None |
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.
Do you need this line?
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.
I set proxies to None because running a json.loads(None)
, if no proxies are passed in, results in an exception. Does that make sense?
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.
If self.options.proxy
is None, are you able to change it to an empty dict string?
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.
Great suggestion, I tested that we're able to send a request with proxies=json.loads("{}")
. I will update the code to reflect that by setting the default proxies option to be "{}"
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.
Awesome. Make sure to initialize it in process_options
instead of having a default {}
value for proxies.
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.
I found that I need to initialize that value to "{}"
in the Options map because even if we set it to a dictionary in process options , that options.proxies values ends up being converted to a string - I found this when running the unit tests.
So it seems we'd have to keep that json.loads behavior in transport.py to make sure that argument is correctly loaded as a dictionary.
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.
You don't set it to a dictionary in process options. You set it to a string with an empty dictionary like you've said: "{}"
.
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.
LGTM.
I've disabled the CircleCI checks since TravisCI is already testing everything we need. All you need to do is fix the build in TravisCI and then should be good to merge!
contrib/opencensus-ext-azure/opencensus/ext/azure/common/transport.py
Outdated
Show resolved
Hide resolved
contrib/opencensus-ext-azure/opencensus/ext/azure/common/transport.py
Outdated
Show resolved
Hide resolved
@skinamdar |
e3ef0cd
to
6f8d1d8
Compare
@@ -95,7 +95,7 @@ def __init__(self, *args, **kwargs): | |||
logging_sampling_rate=1.0, | |||
max_batch_size=100, | |||
minimum_retry_interval=60, # minimum retry interval in seconds | |||
proxy=None, | |||
proxies='{}', # string maps url schemes to the url of the proxies |
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.
I don't think I was clear in my previous explanation. You keep proxies=None in the constructor, but in process_options
you check if proxies is None and you set it to "{}"
in that function. This is similar to what we are doing for instrumentatoin_key
.
Also, can you add an entry into CHANGEOG.md under opencensus-ext-azure? |
cace381
to
b1d46e0
Compare
Currently blocked in travis ci for python2.7 and python3.4 builds due to #905 Still trying to investigate why the python3.7 build is failing since it's not clear from the logs |
@skinamdar |
b1d46e0
to
8606482
Compare
Awesome, I see the build passed now. Thank you @lzchen for helping fix the builds - can you confirm I'm all set to merge now then? |
@lzchen Thank you for merging the changes to master. Do you know when the next release of opencensus-ext-azure will be in pip so we can pull in these changes when developing? |
I'll probably do a release later next week. |
Sounds good, thank you. |
Context:
Proxy functionality when instantiating azure exporters is currently unsupported so I had created issue #896. To expedite this feature request, I created this PR which supports posting requests with proxies that are passed in.
Testing:
Tested locally to ensure proxy options were set.
Tested using nox 3.6 - all tests pass. Note that there are existing linting issues for files unrelated to this PR. To decouple changes, I did not address them in the PR. However, I can fix those linting issues if the maintainers prefer that in this PR.
Nox status
Additional Notes:
contrib/opencensus-ext-grpc
- I'm still troubleshooting that but wanted to create this PR as it's been tested with python3 at least. If the maintainers could help run this PR on their local machine with nox to ensure python2 compatibility that would be super appreciated as well.