This repository was archived by the owner on Sep 17, 2025. It is now read-only.
Implement custom events in Azure#925
Merged
lzchen merged 5 commits intocensus-instrumentation:masterfrom Jun 29, 2020
Merged
Conversation
aabmass
approved these changes
Jun 29, 2020
Member
aabmass
left a comment
There was a problem hiding this comment.
LGTM! I noticed a lot of this is just refactoring, so it's understandable if you don't wanna tweak old code I nit'ed
| def _export(self, batch, event=None): # pragma: NO COVER | ||
| try: | ||
| if batch: | ||
| envelopes = [self.log_record_to_envelope(x) for x in batch] |
Member
There was a problem hiding this comment.
If apply_telemetry_processors() just needs an iterable, could use generator
Suggested change
| envelopes = [self.log_record_to_envelope(x) for x in batch] | |
| envelopes = (self.log_record_to_envelope(x) for x in batch) |
| envelope.tags['ai.operation.id'] = getattr( | ||
| record, | ||
| 'traceId', | ||
| '00000000000000000000000000000000', |
| ) | ||
| envelope.tags['ai.operation.parentId'] = '|{}.{}.'.format( | ||
| envelope.tags['ai.operation.id'], | ||
| getattr(record, 'spanId', '0000000000000000'), |
| from opencensus.ext.azure.common import Options | ||
| instrumentation_key = Options._default.instrumentation_key | ||
| Options._default.instrumentation_key = None | ||
| self.assertRaises(ValueError, lambda: log_exporter.AzureEventHandler()) |
Comment on lines
+323
to
+324
| 'key_1': 'value_1', | ||
| 'key_2': 'value_2' |
Comment on lines
+443
to
+448
| logger = logging.getLogger(self.id()) | ||
| handler = log_exporter.AzureEventHandler( | ||
| instrumentation_key='12345678-1234-5678-abcd-12345678abcd', | ||
| logging_sampling_rate=0.0, | ||
| ) | ||
| logger.addHandler(handler) |
Member
There was a problem hiding this comment.
nit could stick this in a contextmanager since it appears a few times and (I guess) you need to remember handler.close()
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Send
customEventtelemetry to Azure in exactly the same way astracetelemetry but using a different log handler instead (AzureEventHandler). We usually will recommend customers to use two separate loggers in this case if they want bothtraceandcustomEvent.