applicationinsights
Version:
Microsoft Application Insights module for Node.js
37 lines • 1.96 kB
JavaScript
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.AzureFunctionsLoader = void 0;
const resources_1 = require("@opentelemetry/resources");
const agentLoader_1 = require("./agentLoader");
const diagnosticLogger_1 = require("./diagnostics/diagnosticLogger");
const statusLogger_1 = require("./diagnostics/statusLogger");
const azureFunctionsWriter_1 = require("./diagnostics/writers/azureFunctionsWriter");
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
class AzureFunctionsLoader extends agentLoader_1.AgentLoader {
constructor() {
super();
if (this._canLoad) {
// Azure Fn specific configuration
this._options.enableAutoCollectPerformance = false;
process.env["APPLICATION_INSIGHTS_NO_STANDARD_METRICS"] = "disable";
const resourceAttributes = {};
if (process.env.WEBSITE_SITE_NAME) {
resourceAttributes[semantic_conventions_1.SEMRESATTRS_SERVICE_NAME] =
process.env.WEBSITE_SITE_NAME;
}
if (process.env.WEBSITE_INSTANCE_ID) {
resourceAttributes[semantic_conventions_1.SEMRESATTRS_SERVICE_INSTANCE_ID] =
process.env.WEBSITE_INSTANCE_ID;
}
const resource = new resources_1.Resource(resourceAttributes);
this._options.resource = resource;
const writer = new azureFunctionsWriter_1.AzureFunctionsWriter(this._instrumentationKey);
this._diagnosticLogger = new diagnosticLogger_1.DiagnosticLogger(this._instrumentationKey, writer);
this._statusLogger = new statusLogger_1.StatusLogger(this._instrumentationKey, writer);
}
}
}
exports.AzureFunctionsLoader = AzureFunctionsLoader;
//# sourceMappingURL=azureFunctionsLoader.js.map
;