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

Add support for exporting Custom Events to Azure App Insights.#814

Closed
ivaramme wants to merge 1 commit intocensus-instrumentation:masterfrom
ivaramme:azure-custom-events
Closed

Add support for exporting Custom Events to Azure App Insights.#814
ivaramme wants to merge 1 commit intocensus-instrumentation:masterfrom
ivaramme:azure-custom-events

Conversation

@ivaramme
Copy link
Copy Markdown
Contributor

This PR enables sending Custom Events to Application Insights (Azure) from an application by creating a new logging exporter with the expected data structure used by App Insights for this feature.

Custom Events in App Insights are a special type of structured, searchable data points reflecting an event or action. An event must contain an event name and optionally a set of properties (in the form of dictionaries) that are attached to that entry.

@ivaramme ivaramme requested a review from lzchen as a code owner November 11, 2019 15:53
@googlebot
Copy link
Copy Markdown

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@googlebot
Copy link
Copy Markdown

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

time=utils.timestamp_to_iso_str(record.created),
)

envelope.name = "Microsoft.ApplicationInsights.Event"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought we decided to use Logs as the actual telemetry type? This would be Message data.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But wouldn't that log the data as "searchable text" in the logs table (https://github.com/microsoft/ApplicationInsights-Home/blob/master/EndpointSpecs/Schemas/Bond/MessageData.bond#L6)?

The event definition is different (and this link might be outdated) and more resonant to what we are trying to accomplish here (custom events): https://github.com/microsoft/ApplicationInsights-Home/blob/master/EndpointSpecs/Schemas/Bond/EventData.bond#L5

Maybe I'm missing something, please let me know.

from opencensus.ext.azure.log_exporter import AzureLogHandler


class AzureEventHandler(AzureLogHandler):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think we need another handler type if we are going to be using Message telemetry type. We can leverage the already existing AzureLogHandler and place the new "properties" logic in there.

def __init__(self, **options):
super(AzureEventHandler, self).__init__(**options)

def log_record_to_envelope(self, record):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think adding an example of how this works in examples.logs will help. As well, updating the example in the README and adding an excerpt of this feature will be good.

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.

Please see my comments.

Enable exporter for custom  events using the same logging pipeline available in OC.
@ivaramme ivaramme force-pushed the azure-custom-events branch from be61bfc to cc517ea Compare November 27, 2019 02:36
@lzchen
Copy link
Copy Markdown
Contributor

lzchen commented Dec 6, 2019

Closed due to [#822 ]

@lzchen lzchen closed this Dec 6, 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