Repository: microsoft/ApplicationInsights-node.js
Pull request #1187 (2023-08-15 01:42:19)

[Beta] Files restructure to align with Azure Monitor Distro


Patch:
diff --git a/src/agent/agentLoader.ts b/src/agent/agentLoader.ts
index 36e6f76..23a32fa 100644
--- a/src/agent/agentLoader.ts
+++ b/src/agent/agentLoader.ts
@@ -3,7 +3,7 @@
 
 import { ManagedIdentityCredential } from "@azure/identity";
 import { AzureMonitorOpenTelemetryClient } from "@azure/monitor-opentelemetry";
-import { Util } from "../shim/util";
+import { Util } from "../shared/util";
 import { ConsoleWriter } from "./diagnostics/writers/consoleWriter";
 import { DiagnosticLogger } from "./diagnostics/diagnosticLogger";
 import { StatusLogger } from "./diagnostics/statusLogger";
diff --git a/src/agent/diagnostics/writers/consoleWriter.ts b/src/agent/diagnostics/writers/consoleWriter.ts
index 3d52d41..8332bd6 100644
--- a/src/agent/diagnostics/writers/consoleWriter.ts
+++ b/src/agent/diagnostics/writers/consoleWriter.ts
@@ -1,7 +1,7 @@
 // Copyright (c) Microsoft Corporation.
 // Licensed under the MIT license.
 
-import { Util } from "../../../shim/util";
+import { Util } from "../../../shared/util";
 import { IAgentLogger } from "../../types";
 
 export class ConsoleWriter implements IAgentLogger {
diff --git a/src/agent/diagnostics/writers/fileWriter.ts b/src/agent/diagnostics/writers/fileWriter.ts
index 563843b..2bed573 100644
--- a/src/agent/diagnostics/writers/fileWriter.ts
+++ b/src/agent/diagnostics/writers/fileWriter.ts
@@ -5,7 +5,7 @@ import * as path from "path";
 import * as fs from "fs";
 import { makeStatusDirs, renameCurrentFile } from "./fileHelpers";
 import { IAgentLogger } from "../../types";
-import { Util } from "../../../shim/util";
+import { Util } from "../../../shared/util";
 
 export interface FileWriterOptions {
     append: boolean; // Overwrite or append on file write (false)
diff --git a/src/applicationInsightsClient.ts b/src/applicationInsightsClient.ts
index cafee7a..0f7faeb 100644
--- a/src/applicationInsightsClient.ts
+++ b/src/applicationInsightsClient.ts
@@ -2,7 +2,7 @@
 // Licensed under the MIT license.
 
 import { ApplicationInsightsConfig } from "./applicationInsightsConfig";
-import { Logger } from "./shim/logging";
+import { Logger } from "./shared/logging";
 import { AzureMonitorOpenTelemetryClient, AzureMonitorOpenTelemetryOptions } from "@azure/monitor-opentelemetry";
 
 /** 
diff --git a/src/shim/autoCollection/console.ts b/src/logs/console.ts
similarity index 92%
rename from src/shim/autoCollection/console.ts
rename to src/logs/console.ts
index 8bcb994..73ff097 100644
--- a/src/shim/autoCollection/console.ts
+++ b/src/logs/console.ts
@@ -1,6 +1,6 @@
-import { LogInstrumentationsConfig } from "../../types";
+import { LogInstrumentationsConfig } from "../types";
 import { enablePublishers } from "./diagnostic-channel/initialization";
-import { TelemetryClient } from "../telemetryClient";
+import { TelemetryClient } from "../shim/telemetryClient";
 enablePublishers();
 
 export class AutoCollectConsole {
diff --git a/src/shim/autoCollection/diagnostic-channel/bunyan.sub.ts b/src/logs/diagnostic-channel/bunyan.sub.ts
similarity index 93%
rename from src/shim/autoCollection/diagnostic-channel/bunyan.sub.ts
rename to src/logs/diagnostic-channel/bunyan.sub.ts
index 3927bae..81fee81 100644
--- a/src/shim/autoCollection/diagnostic-channel/bunyan.sub.ts
+++ b/src/logs/diagnostic-channel/bunyan.sub.ts
@@ -2,8 +2,8 @@
 // Licensed under the MIT license. See LICENSE file in the project root for details.
 import { channel, IStandardEvent, trueFilter } from "diagnostic-channel";
 import { bunyan } from "diagnostic-channel-publishers";
-import { KnownSeverityLevel } from "../../../declarations/generated";
-import { TelemetryClient } from "../../telemetryClient";
+import { KnownSeverityLevel } from "../../declarations/generated";
+import { TelemetryClient } from "../../shim/telemetryClient";
 
 let clients: TelemetryClient[] = [];
 
diff --git a/src/shim/autoCollection/diagnostic-channel/console.sub.ts b/src/logs/diagnostic-channel/console.sub.ts
similarity index 92%
rename from src/shim/autoCollection/diagnostic-channel/console.sub.ts
rename to src/logs/diagnostic-channel/console.sub.ts
index 6969e05..e350868 100644
--- a/src/shim/autoCollection/diagnostic-channel/console.sub.ts
+++ b/src/logs/diagnostic-channel/console.sub.ts
@@ -2,8 +2,8 @@
 // Licensed under the MIT license. See LICENSE file in the project root for details.
 import { channel, IStandardEvent, trueFilter } from "diagnostic-channel";
 import { console as consolePub } from "diagnostic-channel-publishers";
-import { KnownSeverityLevel } from "../../../declarations/generated";
-import { TelemetryClient } from "../../telemetryClient";
+import { KnownSeverityLevel } from "../../declarations/generated";
+import { TelemetryClient } from "../../shim/telemetryClient";
 
 let clients: TelemetryClient[] = [];
 
diff --git a/src/shim/autoCollection/diagnostic-channel/initialization.ts b/src/logs/diagnostic-channel/initialization.ts
similarity index 95%
rename from src/shim/autoCollection/diagnostic-channel/initialization.ts
rename to src/logs/diagnostic-channel/initialization.ts
index 61257a4..b6db3da 100644
--- a/src/shim/autoCollection/diagnostic-channel/initialization.ts
+++ b/src/logs/diagnostic-channel/initialization.ts
@@ -3,7 +3,7 @@
 
 // Don't reference modules from these directly. Use only for types.
 import * as DiagChannelPublishers from "diagnostic-channel-publishers";
-import { Logger } from "../../logging";
+import { Logger } from "../../shared/logging";
 
 const TAG = "DiagnosticChannel";
 let isInitialized = false;
diff --git a/src/shim/autoCollection/diagnostic-channel/winston.sub.ts b/src/logs/diagnostic-channel/winston.sub.ts
similarity index 95%
rename from src/shim/autoCollection/diagnostic-channel/winston.sub.ts
rename to src/logs/diagnostic-channel/winston.sub.ts
index 47dfc4b..cf9e381 100644
--- a/src/shim/autoCollection/diagnostic-channel/winston.sub.ts
+++ b/src/logs/diagnostic-channel/winston.sub.ts
@@ -2,8 +2,8 @@
 // Licensed under the MIT license. See LICENSE file in the project root for details.
 import { channel, IStandardEvent, trueFilter } from "diagnostic-channel";
 import { winston } from "diagnostic-channel-publishers";
-import { KnownSeverityLevel } from "../../../declarations/generated";
-import { TelemetryClient } from "../../telemetryClient";
+import { KnownSeverityLevel } from "../../declarations/generated";
+import { TelemetryClient } from "../../shim/telemetryClient";
 
 let clients: TelemetryClient[] = [];
 
diff --git a/src/shim/autoCollection/exceptions.ts b/src/logs/exceptions.ts
similarity index 98%
rename from src/shim/autoCollection/exceptions.ts
rename to src/logs/exceptions.ts
index 772e900..ca8764d 100644
--- a/src/shim/autoCollection/exceptions.ts
+++ b/src/logs/exceptions.ts
@@ -1,5 +1,5 @@
-import { Util } from "../util";
-import { TelemetryClient } from "../telemetryClient";
+import { Util } from "../shared/util";
+import { TelemetryClient } from "../shim/telemetryClient";
 
 type ExceptionHandle = "uncaughtExceptionMonitor" | "uncaughtException" | "unhandledRejection";
 const UNCAUGHT_EXCEPTION_MONITOR_HANDLER_NAME: ExceptionHandle = "uncaughtExceptionMonitor";
diff --git a/src/shim/autoCollection/nativeMetrics.ts b/src/metrics/nativeMetrics.ts
similarity index 99%
rename from src/shim/autoCollection/nativeMetrics.ts
rename to src/metrics/nativeMetrics.ts
index cd7fe92..47ebfb8 100644
--- a/src/shim/autoCollection/nativeMetrics.ts
+++ b/src/metrics/nativeMetrics.ts
@@ -10,7 +10,7 @@ import {
     PeriodicExportingMetricReaderOptions,
 } from "@opentelemetry/sdk-metrics";
 import { Histogram, Meter, ObservableGauge, ObservableResult } from "@opentelemetry/api";
-import { Logger } from "../logging";
+import { Logger } from "../shared/logging";
 
 /**
  * Azure Monitor Native Metrics
diff --git a/src/shim/configuration/internal.ts b/src/shared/configuration/internal.ts
similarity index 100%
rename from src/shim/configuration/internal.ts
rename to src/shared/configuration/internal.ts
diff --git a/src/shim/configuration/jsonConfig.ts b/src/shared/configuration/jsonConfig.ts
similarity index 100%
rename from src/shim/configuration/jsonConfig.ts
rename to src/shared/configuration/jsonConfig.ts
diff --git a/src/shim/logging/index.ts b/src/shared/logging/index.ts
similarity index 100%
rename from src/shim/logging/index.ts
rename to src/shared/logging/index.ts
diff --git a/src/shim/logging/internalAzureLogger.ts b/src/shared/logging/internalAzureLogger.ts
similarity index 100%
rename from src/shim/logging/internalAzureLogger.ts
rename to src/shared/logging/internalAzureLogger.ts
diff --git a/src/shim/logging/logger.ts b/src/shared/logging/logger.ts
similarity index 100%
rename from src/shim/logging/logger.ts
rename to src/shared/logging/logger.ts
diff --git a/src/shim/util/configHelper.ts b/src/shared/util/configHelper.ts
similarity index 100%
rename from src/shim/util/configHelper.ts
rename to src/shared/util/configHelper.ts
diff --git a/src/shim/util/contextTagKeys.ts b/src/shared/util/contextTagKeys.ts
similarity index 100%
rename from src/shim/util/contextTagKeys.ts
rename to src/shared/util/contextTagKeys.ts
diff --git a/src/shim/util/fileSystemHelper.ts b/src/shared/util/fileSystemHelper.ts
similarity index 100%
rename from src/shim/util/fileSystemHelper.ts
rename to src/shared/util/fileSystemHelper.ts
diff --git a/src/shim/util/index.ts b/src/shared/util/index.ts
similarity index 100%
rename from src/shim/util/index.ts
rename to src/shared/util/index.ts
diff --git a/src/shim/util/util.ts b/src/shared/util/util.ts
similarity index 100%
rename from src/shim/util/util.ts
rename to src/shared/util/util.ts
diff --git a/src/shim/NodeClient.ts b/src/shim/NodeClient.ts
index 86ccb48..ab9e29c 100644
--- a/src/shim/NodeClient.ts
+++ b/src/shim/NodeClient.ts
@@ -1,4 +1,4 @@
-import { Logger } from "./logging";
+import { Logger } from "../shared/logging";
 import { Contracts, TelemetryClient } from "./shim-applicationinsights";
 
 class NodeClient extends TelemetryClient {
diff --git a/src/shim/configuration/config.ts b/src/shim/config.ts
similarity index 97%
rename from src/shim/configuration/config.ts
rename to src/shim/config.ts
index 5f537e4..a141a97 100644
--- a/src/shim/configuration/config.ts
+++ b/src/shim/config.ts
@@ -1,9 +1,9 @@
-import { DistributedTracingModes, IConfig, IDisabledExtendedMetrics, IWebInstrumentationConfig } from "../types";
+import { DistributedTracingModes, IConfig, IDisabledExtendedMetrics, IWebInstrumentationConfig } from "./types";
 import http = require("http");
 import https = require("https");
 import azureCoreAuth = require("@azure/core-auth");
-import { Logger } from "../logging";
-import constants = require("../../declarations/constants");
+import { Logger } from "../shared/logging";
+import constants = require("../declarations/constants");
 
 class config implements IConfig {
 
diff --git a/src/shim/context.ts b/src/shim/context.ts
index b60f1fe..30a2133 100644
--- a/src/shim/context.ts
+++ b/src/shim/context.ts
@@ -1,4 +1,4 @@
-﻿import ContextTagKeys = require("./util/contextTagKeys");
+﻿import ContextTagKeys = require("../shared/util/contextTagKeys");
 
 export class Context {
     public keys: ContextTagKeys;
diff --git a/src/shim/correlationContextManager.ts b/src/shim/correlationContextManager.ts
index 888ddb5..7a70493 100644
--- a/src/shim/correlationContextManager.ts
+++ b/src/shim/correlationContextManager.ts
@@ -4,7 +4,7 @@ import { context, SpanContext, trace, Context } from "@opentelemetry/api";
 import { TraceState } from "@opentelemetry/core";
 import { Span } from "@opentelemetry/sdk-trace-base";
 import { ICorrelationContext, ITraceparent, ITracestate, HttpRequest, ICustomProperties } from "./types";
-import { Logger } from "./logging";
+import { Logger } from "../shared/logging";
 import * as azureFunctionsTypes from "@azure/functions";
 
 export class CorrelationContextManager {
diff --git a/src/shim/shim-applicationinsights.ts b/src/shim/shim-applicationinsights.ts
index 627a811..32a8254 100644
--- a/src/shim/shim-applicationinsights.ts
+++ b/src/shim/shim-applicationinsights.ts
@@ -3,13 +3,13 @@ import { DiagLogLevel, SpanContext } from "@opentelemetry/api";
 import { CorrelationContextManager } from "./correlationContextManager";
 import * as azureFunctionsTypes from "@azure/functions";
 import { Span } from "@opentelemetry/sdk-trace-base";
-import { Logger } from "./logging";
+import { Logger } from "../shared/logging";
 import { ICorrelationContext, HttpRequest, DistributedTracingModes } from "./types";
 import { TelemetryClient } from "./telemetryClient";
 import * as Contracts from "../declarations/contracts";
 import { ApplicationInsightsOptions } from "../types";
 import { HttpInstrumentationConfig } from "@opentelemetry/instrumentation-http";
-import ConfigHelper = require("./util/configHelper");
+import ConfigHelper = require("../shared/util/configHelper");
 
 // We export these imports so that SDK users may use these classes directly.
 // They're exposed using "export import" so that types are passed along as expected
diff --git a/src/shim/telemetryClient.ts b/src/shim/telemetryClient.ts
index 847f43f..b5f0ab5 100644
--- a/src/shim/telemetryClient.ts
+++ b/src/shim/telemetryClient.ts
@@ -10,17 +10,17 @@ import { SemanticAttributes } from "@opentelemetry/semantic-conventions";
 import * as Contracts from "../declarations/contracts";
 import { AvailabilityData, TelemetryItem as Envelope, KnownSeverityLevel, MessageData, MonitorDomain, PageViewData, TelemetryEventData, TelemetryExceptionData, TelemetryExceptionDetails } from "../declarations/generated";
 import { Context } from "./context";
-import { Logger } from "./logging";
-import { Util } from "./util";
-import { AutoCollectConsole } from "./autoCollection/console";
-import { AutoCollectExceptions, parseStack } from "./autoCollection/exceptions";
+import { Logger } from "../shared/logging";
+import { Util } from "../shared/util";
+import { AutoCollectConsole } from "../logs/console";
+import { AutoCollectExceptions, parseStack } from "../logs/exceptions";
 import { ApplicationInsightsOptions, ExtendedMetricType } from "../types";
-import { InternalConfig } from "./configuration/internal";
+import { InternalConfig } from "../shared/configuration/internal";
 import { IConfig } from "../shim/types";
-import Config = require("./configuration/config");
+import Config = require("./config");
 import { dispose, Configuration, _setupCalled } from "./shim-applicationinsights";
 import { HttpInstrumentationConfig } from "@opentelemetry/instrumentation-http";
-import ConfigHelper = require("./util/configHelper");
+import ConfigHelper = require("../shared/util/configHelper");
 
 /**
  * Application Insights telemetry client provides interface to track telemetry items, register telemetry initializers and


Test patch:
diff --git a/test/unitTests/shim/autoCollection/bunyan.tests.ts b/test/unitTests/logs/bunyan.tests.ts
similarity index 92%
rename from test/unitTests/shim/autoCollection/bunyan.tests.ts
rename to test/unitTests/logs/bunyan.tests.ts
index 510e109..a13b9b3 100644
--- a/test/unitTests/shim/autoCollection/bunyan.tests.ts
+++ b/test/unitTests/logs/bunyan.tests.ts
@@ -3,10 +3,10 @@ import * as sinon from "sinon";
 import { channel } from "diagnostic-channel";
 import { bunyan } from "diagnostic-channel-publishers";
 
-import { enable, dispose } from "../../../../src/shim/autoCollection/diagnostic-channel/bunyan.sub";
-import { Util } from "../../../../src/shim/util";
-import { TelemetryClient } from "../../../../src";
-import { ApplicationInsightsOptions } from "../../../../src/types";
+import { enable, dispose } from "../../../src/logs/diagnostic-channel/bunyan.sub";
+import { Util } from "../../../src/shared/util";
+import { TelemetryClient } from "../../../src";
+import { ApplicationInsightsOptions } from "../../../src/types";
 
 describe("diagnostic-channel/bunyan", () => {
     let sandbox: sinon.SinonSandbox;
diff --git a/test/unitTests/shim/autoCollection/console.tests.ts b/test/unitTests/logs/console.tests.ts
similarity index 94%
rename from test/unitTests/shim/autoCollection/console.tests.ts
rename to test/unitTests/logs/console.tests.ts
index 2e18a38..9837f14 100644
--- a/test/unitTests/shim/autoCollection/console.tests.ts
+++ b/test/unitTests/logs/console.tests.ts
@@ -3,9 +3,9 @@ import * as sinon from "sinon";
 import { channel } from "diagnostic-channel";
 import { console } from "diagnostic-channel-publishers";
 
-import { enable, dispose } from "../../../../src/shim/autoCollection/diagnostic-channel/console.sub";
-import { TelemetryClient } from "../../../../src";
-import { ApplicationInsightsOptions } from "../../../../src/types";
+import { enable, dispose } from "../../../src/logs/diagnostic-channel/console.sub";
+import { TelemetryClient } from "../../../src";
+import { ApplicationInsightsOptions } from "../../../src/types";
 
 describe("AutoCollection/Console", () => {
     let sandbox: sinon.SinonSandbox;
diff --git a/test/unitTests/shim/autoCollection/exceptions.tests.ts b/test/unitTests/logs/exceptions.tests.ts
similarity index 96%
rename from test/unitTests/shim/autoCollection/exceptions.tests.ts
rename to test/unitTests/logs/exceptions.tests.ts
index 99d18f4..366690a 100644
--- a/test/unitTests/shim/autoCollection/exceptions.tests.ts
+++ b/test/unitTests/logs/exceptions.tests.ts
@@ -1,7 +1,7 @@
 import * as assert from "assert";
 import * as sinon from "sinon";
 
-import { AutoCollectExceptions } from "../../../../src/shim/autoCollection/exceptions";
+import { AutoCollectExceptions } from "../../../src/logs/exceptions";
 
 describe("AutoCollection/Exceptions", () => {
     let sandbox: sinon.SinonSandbox;
diff --git a/test/unitTests/shim/autoCollection/winston.tests.ts b/test/unitTests/logs/winston.tests.ts
similarity index 93%
rename from test/unitTests/shim/autoCollection/winston.tests.ts
rename to test/unitTests/logs/winston.tests.ts
index 2df15bd..0201b34 100644
--- a/test/unitTests/shim/autoCollection/winston.tests.ts
+++ b/test/unitTests/logs/winston.tests.ts
@@ -3,9 +3,9 @@ import * as sinon from "sinon";
 import { channel } from "diagnostic-channel";
 import { winston } from "diagnostic-channel-publishers";
 
-import { enable, dispose } from "../../../../src/shim/autoCollection/diagnostic-channel/winston.sub";
-import { TelemetryClient } from "../../../../src";
-import { ApplicationInsightsOptions } from "../../../../src/types";
+import { enable, dispose } from "../../../src/logs/diagnostic-channel/winston.sub";
+import { TelemetryClient } from "../../../src";
+import { ApplicationInsightsOptions } from "../../../src/types";
 
 describe("diagnostic-channel/winston", () => {
     let sandbox: sinon.SinonSandbox;
diff --git a/test/unitTests/shared/logging.tests.ts b/test/unitTests/shared/logging.tests.ts
index d854faf..a93cbbc 100644
--- a/test/unitTests/shared/logging.tests.ts
+++ b/test/unitTests/shared/logging.tests.ts
@@ -2,7 +2,7 @@ import { diag, DiagLogLevel } from "@opentelemetry/api";
 import * as assert from "assert";
 import * as sinon from "sinon";
 
-import { Logger } from "../../../src/shim/logging";
+import { Logger } from "../../../src/shared/logging";
 
 describe("Library/Logger", () => {
     let sandbox: sinon.SinonSandbox;
diff --git a/test/unitTests/shared/util.tests.ts b/test/unitTests/shared/util.tests.ts
index 6f97e14..266bd61 100644
--- a/test/unitTests/shared/util.tests.ts
+++ b/test/unitTests/shared/util.tests.ts
@@ -1,7 +1,7 @@
 ﻿import * as assert from "assert";
 import * as sinon from "sinon";
 
-import { Util } from "../../../src/shim/util";
+import { Util } from "../../../src/shared/util";
 
 describe("Library/Util", () => {
     let sandbox: sinon.SinonSandbox;
diff --git a/test/unitTests/shim/config.tests.ts b/test/unitTests/shim/config.tests.ts
index 73f3acc..b37e675 100644
--- a/test/unitTests/shim/config.tests.ts
+++ b/test/unitTests/shim/config.tests.ts
@@ -2,10 +2,9 @@ import assert = require('assert');
 import sinon = require('sinon');
 import { TelemetryClient } from '../../../applicationinsights';
 import { HttpInstrumentationConfig } from '@opentelemetry/instrumentation-http';
-import { CorrelationContextManager } from '../../../src/shim/correlationContextManager';
 const applicationInsights = require('../../../applicationinsights');
 import azureCoreAuth = require("@azure/core-auth");
-import { Logger } from "../../../src/shim/logging"
+import { Logger } from "../../../src/shared/logging"
 import { DiagLogLevel } from '@opentelemetry/api';
 
 class TestTokenCredential implements azureCoreAuth.TokenCredential {