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 TrackAvailability method #429

Closed
Orekhov opened this issue Sep 25, 2018 · 2 comments
Closed

Add TrackAvailability method #429

Orekhov opened this issue Sep 25, 2018 · 2 comments

Comments

@Orekhov
Copy link

Orekhov commented Sep 25, 2018

TrackAvailability method is very useful in cases when availability tests feature can't be used. It is available in the .NET package, but is missing in node.js.

This method is very valuable to have in node.js as this platform is used a lot for writing tests. (We already have a few cases, where it is required)

@OsvaldoRosado
Copy link
Member

It would be great to add this!

In the meantime while a method is not available to generate an Availability telemetry item for you, you can construct one manually using the SDK's exposed contracts. Here's a rough example:

const appInsights = require("applicationinsights");

appInsights.setup("IKEY").start();

const availabilityTelemetry = new appInsights.Contracts.AvailabilityData();
availabilityTelemetry.id = (Math.random() * 100000).toString();
availabilityTelemetry.name = "Test Availability";
availabilityTelemetry.duration = "00.00:00:1.300000";
availabilityTelemetry.success = true;
availabilityTelemetry.runLocation = "My location";
availabilityTelemetry.message = "Sample diagnostic message";
availabilityTelemetry.measurements = {};
availabilityTelemetry.properties = {'Custom property': 'Value'};

const availabilityData = new appInsights.Contracts.Data();
availabilityData.baseData = availabilityTelemetry;
availabilityData.baseType = "AvailabilityData";

const availabilityEnvelope = new appInsights.Contracts.Envelope();
availabilityEnvelope.data = availabilityData;
availabilityEnvelope.time = new Date().toISOString();
availabilityEnvelope.ver = 1;
availabilityEnvelope.iKey = appInsights.defaultClient.config.instrumentationKey;
availabilityEnvelope.name = "Microsoft.ApplicationInsights.Availability";

appInsights.defaultClient.channel.send(availabilityEnvelope);

For any of the fields used above, your IDE should give you inline documentation for what the field is used for, and what formatting it expects (such as the string format for the duration field).

@devaradhanm
Copy link
Contributor

@OsvaldoRosado , is there any update on this issue?

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

No branches or pull requests

4 participants