From db1b826c5e497d623e42fc46a523f3698fce725f Mon Sep 17 00:00:00 2001 From: rochdev Date: Fri, 12 May 2023 11:32:32 -0400 Subject: [PATCH 1/2] update readme to include v4 --- README.md | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index ee22f8ee62d..71c9ca046c7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # `dd-trace`: Node.js APM Tracer Library -[![npm v3](https://img.shields.io/npm/v/dd-trace/latest?color=blue&label=dd-trace%40v3&logo=npm)](https://www.npmjs.com/package/dd-trace) +[![npm v4](https://img.shields.io/npm/v/dd-trace/latest?color=blue&label=dd-trace%40v4&logo=npm)](https://www.npmjs.com/package/dd-trace) +[![npm v3](https://img.shields.io/npm/v/dd-trace/latest-node14?color=blue&label=dd-trace%40v3&logo=npm)](https://www.npmjs.com/package/dd-trace/v/latest-node12) [![npm v2](https://img.shields.io/npm/v/dd-trace/latest-node12?color=blue&label=dd-trace%40v2&logo=npm)](https://www.npmjs.com/package/dd-trace/v/latest-node12) [![npm dev](https://img.shields.io/npm/v/dd-trace/dev?color=orange&label=dd-trace%40dev&logo=npm)](https://www.npmjs.com/package/dd-trace/v/dev) [![codecov](https://codecov.io/gh/DataDog/dd-trace-js/branch/master/graph/badge.svg)](https://codecov.io/gh/DataDog/dd-trace-js) @@ -28,27 +29,28 @@ Most of the documentation for `dd-trace` is available on these webpages: | :---: | :---: | :---: | :---: | :---: | :---: | | [`v1`](https://github.com/DataDog/dd-trace-js/tree/v1.x) | ![npm v1](https://img.shields.io/npm/v/dd-trace/legacy-v1?color=white&label=%20&style=flat-square) | `>= v12` | **End of Life** | 2021-07-13 | 2022-02-25 | | [`v2`](https://github.com/DataDog/dd-trace-js/tree/v2.x) | ![npm v2](https://img.shields.io/npm/v/dd-trace/latest-node12?color=white&label=%20&style=flat-square) | `>= v12` | **Maintenance** | 2022-01-28 | 2023-08-15 | -| [`v3`](https://github.com/DataDog/dd-trace-js/tree/v3.x) | ![npm v3](https://img.shields.io/npm/v/dd-trace/latest?color=white&label=%20&style=flat-square) | `>= v14` | **Current** | 2022-08-15 | Unknown | +| [`v3`](https://github.com/DataDog/dd-trace-js/tree/v3.x) | ![npm v3](https://img.shields.io/npm/v/dd-trace/latest-node14?color=white&label=%20&style=flat-square) | `>= v14` | **Maintenance** | 2022-08-15 | 2024-05-15 | +| [`v4`](https://github.com/DataDog/dd-trace-js/tree/v4.x) | ![npm v4](https://img.shields.io/npm/v/dd-trace/latest?color=white&label=%20&style=flat-square) | `>= v16` | **Current** | 2023-05-12 | Unknown | -We currently maintain two release lines, namely `v2` and `v3`. -Features and bug fixes that are merged are released to the `v3` line and, if appropriate, also the `v2` line. +We currently maintain three release lines, namely `v2`, `v3` and `v4`. +Features and bug fixes that are merged are released to the `v4` line and, if appropriate, also the `v2` and `v3` line. -For any new projects it is recommended to use the `v3` release line: +For any new projects it is recommended to use the `v4` release line: ```sh $ npm install dd-trace $ yarn add dd-trace ``` -However, existing projects that already use the `v2` release line, or projects that need to support Node.js v12, may use the `v2` release line. +However, existing projects that already use the `v2` or `v3` release lines, or projects that need to support EOL versions of Node.js, may continue to use these release lines. This is done by specifying the version when installing the package. -Note that we also publish to npm using a `latest-node12` tag that can also be used for install: +Note that we also publish to npm using a `latest-node12` and `latest-node14` tag that can also be used for install: ```sh -$ npm install dd-trace@2 -$ yarn add dd-trace@2 -$ npm install dd-trace@latest-node12 -$ yarn add dd-trace@latest-node12 +$ npm install dd-trace@3 +$ yarn add dd-trace@3 +$ npm install dd-trace@latest-node14 +$ yarn add dd-trace@latest-node14 ``` Any backwards-breaking functionality that is introduced into the library will result in an increase of the major version of the library and therefore a new release line. From b0f4b9f7da31e63e063882341e139d14a100ded6 Mon Sep 17 00:00:00 2001 From: rochdev Date: Fri, 12 May 2023 11:51:51 -0400 Subject: [PATCH 2/2] use version module instead of semver to match library version --- packages/datadog-instrumentations/src/jest.js | 5 ++--- packages/datadog-instrumentations/src/next.js | 4 ++-- packages/datadog-plugin-jest/test/jasmine2.spec.js | 5 ++--- packages/datadog-plugin-next/test/index.spec.js | 4 ++-- packages/dd-trace/src/tracer.js | 6 +++--- packages/dd-trace/test/tracer.spec.js | 4 ++-- version.js | 12 ++++++++---- 7 files changed, 21 insertions(+), 19 deletions(-) diff --git a/packages/datadog-instrumentations/src/jest.js b/packages/datadog-instrumentations/src/jest.js index 3f942466d60..88f8ca05787 100644 --- a/packages/datadog-instrumentations/src/jest.js +++ b/packages/datadog-instrumentations/src/jest.js @@ -1,10 +1,8 @@ 'use strict' -const semver = require('semver') const { addHook, channel, AsyncResource } = require('./helpers/instrument') const shimmer = require('../../datadog-shimmer') const log = require('../../dd-trace/src/log') -const { version: ddTraceVersion } = require('../../../package.json') const { getCoveredFilenamesFromCoverage, JEST_WORKER_TRACE_PAYLOAD_CODE, @@ -18,6 +16,7 @@ const { getJestTestName, getJestSuitesToRun } = require('../../datadog-plugin-jest/src/util') +const { DD_MAJOR } = require('../../../version') const testSessionStartCh = channel('ci:jest:session:start') const testSessionFinishCh = channel('ci:jest:session:finish') @@ -481,7 +480,7 @@ function jasmineAsyncInstallWraper (jasmineAsyncInstallExport, jestVersion) { } } -if (semver.lt(ddTraceVersion, '4.0.0')) { +if (DD_MAJOR < 4) { addHook({ name: 'jest-jasmine2', versions: ['>=24.8.0'], diff --git a/packages/datadog-instrumentations/src/next.js b/packages/datadog-instrumentations/src/next.js index d1342701f8f..360c18e9f29 100644 --- a/packages/datadog-instrumentations/src/next.js +++ b/packages/datadog-instrumentations/src/next.js @@ -4,7 +4,7 @@ const { channel, addHook, AsyncResource } = require('./helpers/instrument') const shimmer = require('../../datadog-shimmer') -const { MAJOR } = require('../../../version') +const { DD_MAJOR } = require('../../../version') const startChannel = channel('apm:next:request:start') const finishChannel = channel('apm:next:request:finish') @@ -171,7 +171,7 @@ addHook({ name: 'next', versions: ['>=11.1 <13.2'], file: 'dist/server/next-serv addHook({ name: 'next', - versions: MAJOR >= 4 ? ['>=10.2 <11.1'] : ['>=9.5 <11.1'], + versions: DD_MAJOR >= 4 ? ['>=10.2 <11.1'] : ['>=9.5 <11.1'], file: 'dist/next-server/server/next-server.js' }, nextServer => { const Server = nextServer.default diff --git a/packages/datadog-plugin-jest/test/jasmine2.spec.js b/packages/datadog-plugin-jest/test/jasmine2.spec.js index c8d4d200590..49c8ac5029c 100644 --- a/packages/datadog-plugin-jest/test/jasmine2.spec.js +++ b/packages/datadog-plugin-jest/test/jasmine2.spec.js @@ -1,8 +1,6 @@ 'use strict' const fs = require('fs') const path = require('path') - -const semver = require('semver') const nock = require('nock') const { ORIGIN_KEY, COMPONENT, ERROR_MESSAGE } = require('../../dd-trace/src/constants') @@ -22,8 +20,9 @@ const { } = require('../../dd-trace/src/plugins/util/test') const { version: ddTraceVersion } = require('../../../package.json') +const { DD_MAJOR } = require('../../../version') -const describeFunction = semver.lt(ddTraceVersion, '4.0.0') ? describe : describe.skip +const describeFunction = DD_MAJOR < 4 ? describe : describe.skip describeFunction('Plugin', function () { this.retries(2) diff --git a/packages/datadog-plugin-next/test/index.spec.js b/packages/datadog-plugin-next/test/index.spec.js index 7eca4d2b55c..800eda4f6a1 100644 --- a/packages/datadog-plugin-next/test/index.spec.js +++ b/packages/datadog-plugin-next/test/index.spec.js @@ -8,7 +8,7 @@ const { execSync, spawn } = require('child_process') const agent = require('../../dd-trace/test/plugins/agent') const { writeFileSync } = require('fs') const { satisfies } = require('semver') -const { MAJOR } = require('../../../version') +const { DD_MAJOR } = require('../../../version') describe('Plugin', function () { let server @@ -16,7 +16,7 @@ describe('Plugin', function () { describe('next', () => { // TODO: Figure out why 10.x tests are failing. - withVersions('next', 'next', MAJOR >= 4 && '>=11', version => { + withVersions('next', 'next', DD_MAJOR >= 4 && '>=11', version => { const startServer = withConfig => { before(async () => { port = await getPort() diff --git a/packages/dd-trace/src/tracer.js b/packages/dd-trace/src/tracer.js index 7c0c1a417b6..934a2a6a4e2 100644 --- a/packages/dd-trace/src/tracer.js +++ b/packages/dd-trace/src/tracer.js @@ -7,7 +7,7 @@ const { storage } = require('../../datadog-core') const { isError } = require('./util') const { setStartupLogConfig } = require('./startup-log') const { ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants') -const { MAJOR } = require('../../../version') +const { DD_MAJOR } = require('../../../version') const SPAN_TYPE = tags.SPAN_TYPE const RESOURCE_NAME = tags.RESOURCE_NAME @@ -27,7 +27,7 @@ class DatadogTracer extends Tracer { childOf: this.scope().active() }, options) - if (!options.childOf && options.orphanable === false && MAJOR < 4) { + if (!options.childOf && options.orphanable === false && DD_MAJOR < 4) { return fn(null, () => {}) } @@ -82,7 +82,7 @@ class DatadogTracer extends Tracer { optionsObj = optionsObj.apply(this, arguments) } - if (optionsObj && optionsObj.orphanable === false && !tracer.scope().active() && MAJOR < 4) { + if (optionsObj && optionsObj.orphanable === false && !tracer.scope().active() && DD_MAJOR < 4) { return fn.apply(this, arguments) } diff --git a/packages/dd-trace/test/tracer.spec.js b/packages/dd-trace/test/tracer.spec.js index 3a760ff9e8c..a19cd71ad1e 100644 --- a/packages/dd-trace/test/tracer.spec.js +++ b/packages/dd-trace/test/tracer.spec.js @@ -8,13 +8,13 @@ const Config = require('../src/config') const tags = require('../../../ext/tags') const { expect } = require('chai') const { ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants') -const { MAJOR } = require('../../../version') +const { DD_MAJOR } = require('../../../version') const SPAN_TYPE = tags.SPAN_TYPE const RESOURCE_NAME = tags.RESOURCE_NAME const SERVICE_NAME = tags.SERVICE_NAME -const describeOrphanable = MAJOR < 4 ? describe : describe.skip +const describeOrphanable = DD_MAJOR < 4 ? describe : describe.skip describe('Tracer', () => { let Tracer diff --git a/version.js b/version.js index 34f05f3fb82..63fc5e5ce9e 100644 --- a/version.js +++ b/version.js @@ -1,9 +1,13 @@ 'use strict' -const matches = require('./package.json').version.match(/^(\d+)\.(\d+)\.(\d+)/) +const ddMatches = require('./package.json').version.match(/^(\d+)\.(\d+)\.(\d+)/) +const nodeMatches = process.versions.node.match(/^(\d+)\.(\d+)\.(\d+)/) module.exports = { - MAJOR: parseInt(matches[1]), - MINOR: parseInt(matches[2]), - PATCH: parseInt(matches[3]) + DD_MAJOR: parseInt(ddMatches[1]), + DD_MINOR: parseInt(ddMatches[2]), + DD_PATCH: parseInt(ddMatches[3]), + NODE_MAJOR: parseInt(nodeMatches[1]), + NODE_MINOR: parseInt(nodeMatches[2]), + NODE_PATCH: parseInt(nodeMatches[3]) }