microsoft / ApplicationInsights-node.js

Microsoft Application Insights SDK for Node.js
MIT License
325 stars 140 forks source link

"Test" mode for telemetry (i.e. write telemetry to console)? #744

Open philliphoff opened 3 years ago

philliphoff commented 3 years ago

Is there a "test" mode for the gathering of telemetry that doesn't require setting a AI key for an existing Azure resource? That is, is there a way to see what AI would log (perhaps in the [debugging] console) without having to deploy anything to Azure?

The .NET SDK for Application Insights operates that way, where if a AI key is omitted then telemetry is logged to the console instead. This is useful for "inner loop" testing of applications as features and telemetry are added.

hectorhdzg commented 3 years ago

@philliphoff there is a plan for this SDK to fully support Open Telemetry next semester, as part of that console OpenTelemetry exporter would be available more info here

PaulWild commented 2 years ago

Is this something that is still on the roadmap? I ask as this issue has been open for a while and I was looking for this functionality.

hectorhdzg commented 2 years ago

@philliphoff Following code will achieve what you are looking for with current version of the SDK

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

appInsights.defaultClient.addTelemetryProcessor((envelope) => {
    console.log(envelope);
    return false; // Data will not be sent
});
jpolvora commented 2 years ago

"123" as AI key Is valid ? @hectorhdzg or perhaps applications insights will be disabled as is an invalid key ?

hectorhdzg commented 2 years ago

@jpolvora regex validating the iKey is available [here](https://github.com/microsoft/ApplicationInsights-node.js/blob/develop/Library/Config.ts#L198, "123" is not valid but you can use dummy ones like "00000000-0000-0000-0000-000000000000", the important part here would be the telemetry processors preventing all telemetry to be sent.