Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Add optional custom properties to logging messages.#822

Merged
lzchen merged 1 commit intocensus-instrumentation:masterfrom
ivaramme:azure-logging-custom-properties
Nov 26, 2019
Merged

Add optional custom properties to logging messages.#822
lzchen merged 1 commit intocensus-instrumentation:masterfrom
ivaramme:azure-logging-custom-properties

Conversation

@ivaramme
Copy link
Copy Markdown
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
Copy Markdown
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.
@ivaramme ivaramme force-pushed the azure-logging-custom-properties branch from f6ebee7 to 2a75efe Compare November 26, 2019 01:01
@lzchen lzchen merged commit 49495ae into census-instrumentation:master Nov 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants