-
Notifications
You must be signed in to change notification settings - Fork 251
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
Azure log exporter #668
Azure log exporter #668
Conversation
@@ -97,7 +106,7 @@ def stop(self, timeout=None): | |||
return time.time() - start_time # time taken to stop | |||
|
|||
|
|||
class AzureLogHandler(BaseLogHandler): | |||
class AzureLogHandler(TransportMixin, BaseLogHandler): |
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.
There's some duplicated behaviour in AzureLogHandler and the BaseExporter logic. Ideally we should have the logging behaviour (emit) inherited from logging.Handler, queue/Worker and export inherited from BaseExporter. Why are we not re-using the exporter logic if we are making the log "exporter"?
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're right, that's our goal. For more info please take a look at #642 #657.
Today the trace exporter has legacy issue that needs to be refactored (e.g. trace exporter has export
method which sends data to the queue, and emit
which actually export the data. what we want is to only have export
method, move queue and worker to the core opencensus library).
In this logging effort, we're trying to have a cleaner design, and later we'll refactor traces to follow this design.
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.
The fact that the mixin relies on the exporter's options
and storage
makes this kind of brittle. I think this is fine for now (and as you mentioned we need to refactor the exporters), but we should revisit this before moving it out of the package.
@@ -97,7 +106,7 @@ def stop(self, timeout=None): | |||
return time.time() - start_time # time taken to stop | |||
|
|||
|
|||
class AzureLogHandler(BaseLogHandler): | |||
class AzureLogHandler(TransportMixin, BaseLogHandler): |
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.
Should the exporters really be a child class of the Transporter? The two don't really have the "is-a" relationship used for inheritance. Maybe we should have transport be used as a service or utility instead?
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.
Here I took the mixin approach, so the log handler owns all the resources, transport mixin just provides the helper methods on top of these resources.
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.
First pass looks good, though I'm not too familiar with Azure data models.
except Exception: | ||
pass | ||
if response.status_code == 200: | ||
logger.info('Transmission succeeded: %s.', text) |
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.
Nit: I feel there's a bit too much logs in this class. Maybe consider reducing logs or using traces with a low sampling rate.
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.
This is at info level, which is intended for debugging only and off by default.
The default log level is WARNING.
This function should never throw exception. | ||
""" | ||
# TODO: prevent requests being tracked | ||
blacklist_hostnames = execution_context.get_opencensus_attr( |
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.
Not sure if it's a good idea to put this in the trace execution_context
? /cc @c24t WDYT?
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.
Long term goal is to avoid exporters to access execution_context directly, for more info, refer to #573.
In this PR, the code was extracted from the existing trace exporter.
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.
We started storing the blacklist in the context in #289, and probably should have caught it then. I think it's a problem for another PR.
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'll try to address it in a separate PR, there are similar scenarios which we need a consistent solution:
- How to prevent traces generated by trace exporters (e.g. during sending data via HTTP) being sent to trace exporter and cause infinite loop.
- How to prevent logs/exceptions generated by log exporters/handlers being emitted to the same log handlers and cause infinite loop.
My current thinking is to have the entire worker thread marked as "do not track", so all the spans/logs will have a special tag, and based on this tag we can filter these data out before sending them to exporters.
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.
Only minor comments, but let's review again before moving these into core.
This function should never throw exception. | ||
""" | ||
# TODO: prevent requests being tracked | ||
blacklist_hostnames = execution_context.get_opencensus_attr( |
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.
We started storing the blacklist in the context in #289, and probably should have caught it then. I think it's a problem for another PR.
break | ||
self = self.prototype | ||
self = self._default |
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 understand what's happening here.
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.
This is trying to mimic the JavaScript prototype behavior, traveling through the prototype chain and get all the key-value pairs.
Do you think assigning to self
is evil and we should have another variable?
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.
Maybe not evil, but certainly confusing.
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.
Got it, will give a better name in the next PR.
@@ -97,7 +106,7 @@ def stop(self, timeout=None): | |||
return time.time() - start_time # time taken to stop | |||
|
|||
|
|||
class AzureLogHandler(BaseLogHandler): | |||
class AzureLogHandler(TransportMixin, BaseLogHandler): |
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.
The fact that the mixin relies on the exporter's options
and storage
makes this kind of brittle. I think this is fine for now (and as you mentioned we need to refactor the exporters), but we should revisit this before moving it out of the package.
) | ||
execution_context.set_opencensus_attr( | ||
'blacklist_hostnames', | ||
['dc.services.visualstudio.com'], |
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.
May as well give this the constant treatment too.
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.
Will leave it for now. This will go away when we don't have exporters explicitly maintain the blacklist.
Object
andprototype
), useBaseObject
and_default
instead. (Addressing the comments left in Initial version of Azure extension #613 (comment)).