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 BotTelemetry instrumentation and utilities #662

Merged
merged 38 commits into from
Dec 5, 2018
Merged

Conversation

benbrown
Copy link
Contributor

@benbrown benbrown commented Nov 27, 2018

Fixes #629
Fixes #628
Fixes #627
Fixes #626
Fixes #624

Description

Adds Application Insight support in Waterfall Dialogs, and exposes an interface for creating custom telemetry clients.

Specific Changes

In botbuilder-core:

  • Adds a new BotTelemetryClient interface, as well as a NullBotTelemetryClient which implements this interface as a noop and provides a default implementation for use in Dialogs.

In botbuilder-dialogs:

  • Adds a telemetryClient field to the dialog class which defaults to a NullButTelemetryClient. Can be set to any object that implements the interface, including botbuilder-applicationinsights below.
  • Adds calls to trackEvent for each WaterfallDialog step and at the end of each WaterfallDialog.

In botbuilder-applicationinsights:

  • Adds an implementation of BotTelemetryClient backed by Application Insights. This module wraps the applicationinsights module and handles the somewhat ugly instantiation of that library.
  • Also exposes a ApplicationInsightsContextWebserverMiddleware function, a middleware which can be used by Restify or Express to handle necessary context-setting operations.

Testing

To your bot application, add:

const { ApplicationInsightsTelemetryClient, ApplicationInsightsWebserverMiddleware } = require('botbuilder-applicationinsights');

Before any other modules are imported into your application, call:

const appInsightsClient = new ApplicationInsightsTelemetryClient(process.env.instrumentationKey);

After setting up your webserver, add:

server.use(ApplicationInsightsWebserverMiddleware);

And finally, to any dialog you want to track, add:

mainDialog.telemetryClient = appInsightsClient;

@benbrown
Copy link
Contributor Author

benbrown commented Nov 27, 2018

Still need to:

  • Verify that the correlation data is lining up with data from with channel service
  • Write unit tests

@benbrown
Copy link
Contributor Author

I have verified that, when used alongside the ABS channel service and the samples enabled with AppInsights, all the data is properly correlated by user and session. Seems correct!

@coveralls
Copy link

coveralls commented Nov 28, 2018

Pull Request Test Coverage Report for Build 2394

  • 35 of 44 (79.55%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 82.26%

Changes Missing Coverage Covered Lines Changed/Added Lines %
libraries/botbuilder-dialogs/src/dialog.ts 3 4 75.0%
libraries/botbuilder-dialogs/src/componentDialog.ts 1 4 25.0%
libraries/botbuilder-dialogs/src/dialogSet.ts 1 6 16.67%
Totals Coverage Status
Change from base Build 2392: 0.0%
Covered Lines: 2705
Relevant Lines: 3165

💛 - Coveralls

@daveta
Copy link
Contributor

daveta commented Nov 28, 2018

    state.values = {};

New instanceId probably generated/added to state in here.


Refers to: libraries/botbuilder-dialogs/src/waterfallDialog.ts:139 in b75bf42. [](commit_id = b75bf42, deletion_comment = False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants