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 ocagent stats exporter. #617
Add ocagent stats exporter. #617
Conversation
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 can now use opencensus-proto
from Pypi (https://pypi.org/project/opencensus-proto/) instead of vendoring the proto-generated files. See #596 for an example.
contrib/opencensus-ext-ocagent/opencensus/ext/ocagent/proto/__init__.py
Outdated
Show resolved
Hide resolved
Ah I was worried it wouldn't be ready at this point; will go ahead and update. |
contrib/opencensus-ext-ocagent/opencensus/ext/ocagent/utils/__init__.py
Outdated
Show resolved
Hide resolved
Please also update the README and CHANGELOG, thanks! |
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.
Overall looks good, I've left some comments. Thanks.
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. Thanks!
One of the tests globally modifies channels created through grpc.insecure to always attach OpenCensusClientInterceptor. This is causing test_stats_exporter to pull in this interceptor as well. The grpc.StreamStreamClientInterceptor abstract class states stream interceptor method should return an object that's both a call (implementing the response iterator) and a future. However, OpenCensusClientInterceptor just returns a python generator, thus not respecting the defined interface. This in turn breaks all users (including api_core utils) that rely on opencensus-python/contrib/opencensus-ext-grpc/opencensus/ext/grpc/client_interceptor.py Lines 228 to 238 in c59a087
I've created a wrapper iterator that I now return here to ensure the current use cases work. In a followup, it'd be good to implement the current the |
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 minor style comments, but otherwise the changes look great. Thanks for adding this @prateekr.
The grpc.StreamStreamClientInterceptor abstract class states stream interceptor method should return an object that's both a call (implementing the response iterator) and a future.
Thanks for adding the class. Can you add a comment here describing why we need it? It is not at all obvious looking at the (opencensus) source.
What are the odds that this integration is going to break with an update to grpc seeing as this is an experimental API?
One of the tests globally modifies channels created through grpc.insecure to always attach OpenCensusClientInterceptor
Even if your class fixes test_stats_exporter
it sounds like we need to stop the other test from patching this globally!
contrib/opencensus-ext-ocagent/opencensus/ext/ocagent/stats_exporter/__init__.py
Outdated
Show resolved
Hide resolved
contrib/opencensus-ext-ocagent/opencensus/ext/ocagent/stats_exporter/__init__.py
Outdated
Show resolved
Hide resolved
contrib/opencensus-ext-ocagent/opencensus/ext/ocagent/stats_exporter/__init__.py
Show resolved
Hide resolved
contrib/opencensus-ext-ocagent/opencensus/ext/ocagent/stats_exporter/__init__.py
Outdated
Show resolved
Hide resolved
FYI the coverage check is failing for WrappedResponseIterator:
I don't see any problem with adding |
Not sure, but the grpc interceptor has been around for over two years now, so I imagine it's maturing. Also, I don't think the rpc stream return object class is experimental, so any potential changes will likely continue to return this. gRPC api breakages should be a lot easier to catch with the tests added in this PR for the grpc extension. |
Agreed, looks like contrib/opencensus-ext-google-cloud-clientlibs/tests/test_google_cloud_clientlibs_trace.py is an offender. I've patched it enough so the tests in this PR pass. Leaving a wholistic cleanup of this test to a future CL. |
So you imagine checking for a context var in the integrations and -- if it's set -- passing calls through to the wrapped library (e.g. If it's possible I'd prefer not to monkey patch libraries like this at all, but I understand one of the reasons to do this (and why other projects/libraries do bytecode manipulation) is to instrument e.g. grpc calls even when they're buried inside another library. I don't have any suggestions to address this that aren't colossal hacks. At least in this specific case the problem is that a test isn't cleaning up after itself. Even if the integration acted as a no-op during the test it would still be a problem that the integration was loaded at all. |
@prateekr once coverage is fixed this looks good to merge. |
Yes, at least we don't want to collect traces. We might need to collect metrics in some cases though.
Me too! I think the long term direction is encourage 3rd party framework/libraries adding these probes, rather than having OpenCensus reverse engineering and hacking in the probes.
Yup, this question is not specific to this PR. @prateekr's approach looks good to me within the PR context, and I've signed off. |
I think that's a good idea, and if we do implement a general purpose kill-switch for integrations it's probably something that we want in more than just the python client. |
No description provided.