Skip to content
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 optional custom properties to logging messages. #822

Merged

Conversation

ivaramme
Copy link
Contributor

The idea behind this PR is to allow users to track additional information to logging actions by simply adding to the default properties, any additional metadata passed by the user in the form of a dictionary.

The usage of this would look like this:

import logging

from opencensus.ext.azure.log_exporter import AzureLogHandler

logger = logging.getLogger(__name__)
# TODO: set APPLICATIONINSIGHTS_CONNECTION_STRING as environment variable.
logger.addHandler(AzureLogHandler())
logger.warning('action', {'key-1': 'value-1', 'key-2': 'value2'})

Once this data is uploaded to App Insights, you can search in the traces table by keys included in the customDimensions column like this:

traces
| where customDimensions.key-1 == "value-1"
| limit 50
| order by timestamp desc 

This is a good option instead of using Custom Events which is not currently supported in Open Census.

Copy link
Contributor

@lzchen lzchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just a few comments.

@ivaramme ivaramme force-pushed the azure-logging-custom-properties branch 2 times, most recently from 82a59ad to f6ebee7 Compare November 22, 2019 04:28
Include a dictionary with custom properties with the logging message
whenever they are present. These properties could be later searched from
 the Log Analytics workspace from the "traces" table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants