Conversation
|
|
||
|
|
||
| class AzureLogHandler(BaseLogHandler): | ||
| class AzureLogHandler(TransportMixin, BaseLogHandler): |
There was a problem hiding this comment.
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.
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.
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.
|
|
||
|
|
||
| class AzureLogHandler(BaseLogHandler): | ||
| class AzureLogHandler(TransportMixin, BaseLogHandler): |
There was a problem hiding this comment.
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.
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.
songy23
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
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.
c24t
left a comment
There was a problem hiding this comment.
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.
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.
| if self._default == self: | ||
| break | ||
| self = self.prototype | ||
| self = self._default |
There was a problem hiding this comment.
I don't understand what's happening here.
There was a problem hiding this comment.
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.
Maybe not evil, but certainly confusing.
There was a problem hiding this comment.
Got it, will give a better name in the next PR.
|
|
||
|
|
||
| class AzureLogHandler(BaseLogHandler): | ||
| class AzureLogHandler(TransportMixin, BaseLogHandler): |
There was a problem hiding this comment.
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.
May as well give this the constant treatment too.
There was a problem hiding this comment.
Will leave it for now. This will go away when we don't have exporters explicitly maintain the blacklist.
Objectandprototype), useBaseObjectand_defaultinstead. (Addressing the comments left in Initial version of Azure extension #613 (comment)).