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

[monitor] Move @azure/monitor-opentelemetry-exporter to ESM/vitest #31448

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2ff6a6f
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Oct 17, 2024
4d4e44e
Migration: Update test config
mpodwysocki Oct 17, 2024
392e30b
Migration: Clean up files
mpodwysocki Oct 17, 2024
5eae0b6
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Oct 17, 2024
c4cc2c1
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Oct 17, 2024
d396a65
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Oct 17, 2024
5eb0da4
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Oct 17, 2024
453d1ee
Migration: Apply codemod: "addViHelper"
mpodwysocki Oct 17, 2024
e34ebfa
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Oct 17, 2024
8b89491
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Oct 17, 2024
7386408
Migration: rushx format
mpodwysocki Oct 17, 2024
ac2ac9e
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Oct 17, 2024
23ebb71
Migration: Update test config
mpodwysocki Oct 17, 2024
1d336a8
Migration: Clean up files
mpodwysocki Oct 17, 2024
58a6b9f
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Oct 17, 2024
a56f40b
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Oct 17, 2024
380cb85
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Oct 17, 2024
ad9c328
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Oct 17, 2024
642f270
Migration: Apply codemod: "addViHelper"
mpodwysocki Oct 17, 2024
c8447e1
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Oct 17, 2024
5d0f416
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Oct 17, 2024
2673079
Migration: rushx format
mpodwysocki Oct 17, 2024
2bca5ca
[monitor] migrate to ESM/vitest
mpodwysocki Oct 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 78 additions & 8 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "types/src/index.d.ts",
"mainEntryPointFilePath": "dist/esm/index.d.ts",
"docModel": {
"enabled": true
},
Expand All @@ -11,7 +11,7 @@
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "",
"publicTrimmedFilePath": "./types/monitor-opentelemetry-exporter.d.ts"
"publicTrimmedFilePath": "dist/monitor-opentelemetry-exporter.d.ts"
},
"messages": {
"tsdocMessageReporting": {
Expand Down
61 changes: 40 additions & 21 deletions sdk/monitor/monitor-opentelemetry-exporter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@
"sdk-type": "client",
"version": "1.0.0-beta.26",
"description": "Application Insights exporter for the OpenTelemetry JavaScript (Node.js) SDK",
"main": "dist/index.js",
"module": "dist-esm/src/index.js",
"types": "types/monitor-opentelemetry-exporter.d.ts",
"main": "./dist/commonjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/commonjs/index.d.ts",
"scripts": {
"build": "npm run build:node && npm run build:browser && dev-tool run extract-api",
"build:browser": "echo skipped",
"build:node": "tsc -p . && dev-tool run bundle --browser-test=false",
"build": "npm run clean && dev-tool run build-package && dev-tool run extract-api",
"build:samples": "echo Obsolete.",
"build:test": "tsc -p . && dev-tool run bundle --browser-test=false",
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"clean": "rimraf --glob dist-esm types dist",
"execute:samples": "dev-tool samples run samples-dev",
"extract-api": "tsc -p . && dev-tool run extract-api",
"extract-api": "dev-tool run build-package && dev-tool run extract-api",
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"generate:client": "autorest --typescript ./swagger/README.md",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
Expand All @@ -32,20 +29,15 @@
"test:node": "npm run clean && npm run build:test && npm run unit-test:node",
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"unit-test:browser": "echo skipped",
"unit-test:node": "dev-tool run test:node-tsx-ts -- --timeout 1200000 \"test/internal/**/*.test.ts\"",
"unit-test:node:debug": "dev-tool run test:node-tsx-ts -- --timeout 1200000 \"test/internal/**/*.test.ts\"",
"unit-test:node": "dev-tool run test:vitest",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to add a mod to do this automatically, but do note that the timeouts need to be copied over manually. Mocha had one timeout but vitest has test-timeout and hook-timeout so either one might need to be updated

"update-snippets": "echo skipped"
},
"engines": {
"node": ">=18.0.0"
},
"files": [
"dist-esm/src/",
"dist/src/",
"browser/src/",
"types/monitor-opentelemetry-exporter.d.ts",
"dist/",
"README.md",
"SECURITY.md",
"LICENSE"
],
"license": "MIT",
Expand Down Expand Up @@ -81,24 +73,25 @@
}
},
"devDependencies": {
"@azure-tools/test-utils-vitest": "^1.0.0",
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@microsoft/api-extractor": "^7.31.1",
"@opentelemetry/instrumentation": "^0.53.0",
"@opentelemetry/instrumentation-http": "^0.53.0",
"@opentelemetry/sdk-trace-node": "^1.26.0",
"@types/mocha": "^10.0.0",
"@types/node": "^18.0.0",
"@vitest/browser": "^2.1.3",
"@vitest/coverage-istanbul": "^2.1.3",
"cross-env": "^7.0.2",
"dotenv": "^16.0.0",
"eslint": "^9.9.0",
"mocha": "^10.0.0",
"nock": "^13.5.4",
"nyc": "^17.0.0",
"playwright": "^1.48.1",
"rimraf": "^5.0.5",
"sinon": "^17.0.0",
"tsx": "^4.7.1",
"typescript": "~5.6.2"
"typescript": "~5.6.2",
"vitest": "^2.1.3"
},
"dependencies": {
"@azure/core-auth": "^1.3.0",
Expand All @@ -124,5 +117,31 @@
"opentelemetry",
"exporter",
"cloud"
]
],
"type": "module",
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
},
"dialects": [
"esm",
"commonjs"
],
"selfLink": false
},
"browser": "./dist/browser/index.js",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ let clientTracer: Tracer;
setupOpenTelemetry();

// Open Telemetry setup need to happen before http library is loaded
import http from "http";
import http from "node:http";

/*********************************************************************
* HTTP SERVER SETUP
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

export * from "./Constants";
export * from "./Constants.js";
4 changes: 2 additions & 2 deletions sdk/monitor/monitor-opentelemetry-exporter/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { TokenCredential } from "@azure/core-auth";
import { ServiceApiVersion } from "./Declarations/Constants";
import { ApplicationInsightsClientOptionalParams } from "./generated";
import { ServiceApiVersion } from "./Declarations/Constants.js";
import { ApplicationInsightsClientOptionalParams } from "./generated/index.js";

/**
* Provides configuration options for AzureMonitorTraceExporter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// Licensed under the MIT License.

import { diag } from "@opentelemetry/api";
import { ConnectionStringParser } from "../utils/connectionStringParser";
import { AzureMonitorExporterOptions } from "../config";
import { ConnectionStringParser } from "../utils/connectionStringParser.js";
import { AzureMonitorExporterOptions } from "../config.js";
import {
DEFAULT_BREEZE_ENDPOINT,
ENV_CONNECTION_STRING,
LEGACY_ENV_DISABLE_STATSBEAT,
} from "../Declarations/Constants";
} from "../Declarations/Constants.js";

/**
* Azure Monitor OpenTelemetry Trace Exporter.
Expand Down
10 changes: 5 additions & 5 deletions sdk/monitor/monitor-opentelemetry-exporter/src/export/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// Licensed under the MIT License.
import { context, diag } from "@opentelemetry/api";
import { ExportResult, ExportResultCode, suppressTracing } from "@opentelemetry/core";
import { AzureMonitorBaseExporter } from "./base";
import { TelemetryItem as Envelope } from "../generated";
import { logToEnvelope } from "../utils/logUtils";
import { AzureMonitorExporterOptions } from "../config";
import { AzureMonitorBaseExporter } from "./base.js";
import { TelemetryItem as Envelope } from "../generated/index.js";
import { logToEnvelope } from "../utils/logUtils.js";
import { AzureMonitorExporterOptions } from "../config.js";

import type { ReadableLogRecord, LogRecordExporter } from "@opentelemetry/sdk-logs";
import { HttpSender } from "../platform";
import { HttpSender } from "../platform/index.js";

/**
* Azure Monitor OpenTelemetry Log Exporter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
ResourceMetrics,
} from "@opentelemetry/sdk-metrics";
import { ExportResult, ExportResultCode, suppressTracing } from "@opentelemetry/core";
import { AzureMonitorBaseExporter } from "./base";
import { TelemetryItem as Envelope } from "../generated";
import { resourceMetricsToEnvelope } from "../utils/metricUtils";
import { AzureMonitorExporterOptions } from "../config";
import { HttpSender } from "../platform";
import { AzureMonitorBaseExporter } from "./base.js";
import { TelemetryItem as Envelope } from "../generated/index.js";
import { resourceMetricsToEnvelope } from "../utils/metricUtils.js";
import { AzureMonitorExporterOptions } from "../config.js";
import { HttpSender } from "../platform/index.js";

/**
* Azure Monitor OpenTelemetry Metric Exporter.
Expand Down
Loading
Loading