Skip to content

Commit 1b8c33d

Browse files
rochdevtlhunter
authored andcommitted
update readme for v4 and remove semver for version feature flags (#3148)
* update readme to include v4 * use version module instead of semver to match library version
1 parent 265a2bb commit 1b8c33d

File tree

8 files changed

+34
-30
lines changed

8 files changed

+34
-30
lines changed

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# `dd-trace`: Node.js APM Tracer Library
22

3-
[![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)
3+
[![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)
4+
[![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)
45
[![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)
56
[![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)
67
[![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:
2829
| :---: | :---: | :---: | :---: | :---: | :---: |
2930
| [`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 |
3031
| [`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 |
31-
| [`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 |
32+
| [`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 |
33+
| [`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 |
3234

33-
We currently maintain two release lines, namely `v2` and `v3`.
34-
Features and bug fixes that are merged are released to the `v3` line and, if appropriate, also the `v2` line.
35+
We currently maintain three release lines, namely `v2`, `v3` and `v4`.
36+
Features and bug fixes that are merged are released to the `v4` line and, if appropriate, also the `v2` and `v3` line.
3537

36-
For any new projects it is recommended to use the `v3` release line:
38+
For any new projects it is recommended to use the `v4` release line:
3739

3840
```sh
3941
$ npm install dd-trace
4042
$ yarn add dd-trace
4143
```
4244

43-
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.
45+
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.
4446
This is done by specifying the version when installing the package.
45-
Note that we also publish to npm using a `latest-node12` tag that can also be used for install:
47+
Note that we also publish to npm using a `latest-node12` and `latest-node14` tag that can also be used for install:
4648

4749
```sh
48-
$ npm install dd-trace@2
49-
$ yarn add dd-trace@2
50-
$ npm install dd-trace@latest-node12
51-
$ yarn add dd-trace@latest-node12
50+
$ npm install dd-trace@3
51+
$ yarn add dd-trace@3
52+
$ npm install dd-trace@latest-node14
53+
$ yarn add dd-trace@latest-node14
5254
```
5355

5456
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.

packages/datadog-instrumentations/src/jest.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
'use strict'
2-
const semver = require('semver')
32

43
const { addHook, channel, AsyncResource } = require('./helpers/instrument')
54
const shimmer = require('../../datadog-shimmer')
65
const log = require('../../dd-trace/src/log')
7-
const { version: ddTraceVersion } = require('../../../package.json')
86
const {
97
getCoveredFilenamesFromCoverage,
108
JEST_WORKER_TRACE_PAYLOAD_CODE,
@@ -18,6 +16,7 @@ const {
1816
getJestTestName,
1917
getJestSuitesToRun
2018
} = require('../../datadog-plugin-jest/src/util')
19+
const { DD_MAJOR } = require('../../../version')
2120

2221
const testSessionStartCh = channel('ci:jest:session:start')
2322
const testSessionFinishCh = channel('ci:jest:session:finish')
@@ -481,7 +480,7 @@ function jasmineAsyncInstallWraper (jasmineAsyncInstallExport, jestVersion) {
481480
}
482481
}
483482

484-
if (semver.lt(ddTraceVersion, '4.0.0')) {
483+
if (DD_MAJOR < 4) {
485484
addHook({
486485
name: 'jest-jasmine2',
487486
versions: ['>=24.8.0'],

packages/datadog-instrumentations/src/next.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
const { channel, addHook, AsyncResource } = require('./helpers/instrument')
66
const shimmer = require('../../datadog-shimmer')
7-
const { MAJOR } = require('../../../version')
7+
const { DD_MAJOR } = require('../../../version')
88

99
const startChannel = channel('apm:next:request:start')
1010
const finishChannel = channel('apm:next:request:finish')
@@ -171,7 +171,7 @@ addHook({ name: 'next', versions: ['>=11.1 <13.2'], file: 'dist/server/next-serv
171171

172172
addHook({
173173
name: 'next',
174-
versions: MAJOR >= 4 ? ['>=10.2 <11.1'] : ['>=9.5 <11.1'],
174+
versions: DD_MAJOR >= 4 ? ['>=10.2 <11.1'] : ['>=9.5 <11.1'],
175175
file: 'dist/next-server/server/next-server.js'
176176
}, nextServer => {
177177
const Server = nextServer.default

packages/datadog-plugin-jest/test/jasmine2.spec.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
'use strict'
22
const fs = require('fs')
33
const path = require('path')
4-
5-
const semver = require('semver')
64
const nock = require('nock')
75

86
const { ORIGIN_KEY, COMPONENT, ERROR_MESSAGE } = require('../../dd-trace/src/constants')
@@ -22,8 +20,9 @@ const {
2220
} = require('../../dd-trace/src/plugins/util/test')
2321

2422
const { version: ddTraceVersion } = require('../../../package.json')
23+
const { DD_MAJOR } = require('../../../version')
2524

26-
const describeFunction = semver.lt(ddTraceVersion, '4.0.0') ? describe : describe.skip
25+
const describeFunction = DD_MAJOR < 4 ? describe : describe.skip
2726

2827
describeFunction('Plugin', function () {
2928
this.retries(2)

packages/datadog-plugin-next/test/index.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ const { execSync, spawn } = require('child_process')
88
const agent = require('../../dd-trace/test/plugins/agent')
99
const { writeFileSync } = require('fs')
1010
const { satisfies } = require('semver')
11-
const { MAJOR } = require('../../../version')
11+
const { DD_MAJOR } = require('../../../version')
1212

1313
describe('Plugin', function () {
1414
let server
1515
let port
1616

1717
describe('next', () => {
1818
// TODO: Figure out why 10.x tests are failing.
19-
withVersions('next', 'next', MAJOR >= 4 && '>=11', version => {
19+
withVersions('next', 'next', DD_MAJOR >= 4 && '>=11', version => {
2020
const startServer = withConfig => {
2121
before(async () => {
2222
port = await getPort()

packages/dd-trace/src/tracer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { storage } = require('../../datadog-core')
77
const { isError } = require('./util')
88
const { setStartupLogConfig } = require('./startup-log')
99
const { ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants')
10-
const { MAJOR } = require('../../../version')
10+
const { DD_MAJOR } = require('../../../version')
1111

1212
const SPAN_TYPE = tags.SPAN_TYPE
1313
const RESOURCE_NAME = tags.RESOURCE_NAME
@@ -27,7 +27,7 @@ class DatadogTracer extends Tracer {
2727
childOf: this.scope().active()
2828
}, options)
2929

30-
if (!options.childOf && options.orphanable === false && MAJOR < 4) {
30+
if (!options.childOf && options.orphanable === false && DD_MAJOR < 4) {
3131
return fn(null, () => {})
3232
}
3333

@@ -82,7 +82,7 @@ class DatadogTracer extends Tracer {
8282
optionsObj = optionsObj.apply(this, arguments)
8383
}
8484

85-
if (optionsObj && optionsObj.orphanable === false && !tracer.scope().active() && MAJOR < 4) {
85+
if (optionsObj && optionsObj.orphanable === false && !tracer.scope().active() && DD_MAJOR < 4) {
8686
return fn.apply(this, arguments)
8787
}
8888

packages/dd-trace/test/tracer.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ const Config = require('../src/config')
88
const tags = require('../../../ext/tags')
99
const { expect } = require('chai')
1010
const { ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants')
11-
const { MAJOR } = require('../../../version')
11+
const { DD_MAJOR } = require('../../../version')
1212

1313
const SPAN_TYPE = tags.SPAN_TYPE
1414
const RESOURCE_NAME = tags.RESOURCE_NAME
1515
const SERVICE_NAME = tags.SERVICE_NAME
1616

17-
const describeOrphanable = MAJOR < 4 ? describe : describe.skip
17+
const describeOrphanable = DD_MAJOR < 4 ? describe : describe.skip
1818

1919
describe('Tracer', () => {
2020
let Tracer

version.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
'use strict'
22

3-
const matches = require('./package.json').version.match(/^(\d+)\.(\d+)\.(\d+)/)
3+
const ddMatches = require('./package.json').version.match(/^(\d+)\.(\d+)\.(\d+)/)
4+
const nodeMatches = process.versions.node.match(/^(\d+)\.(\d+)\.(\d+)/)
45

56
module.exports = {
6-
MAJOR: parseInt(matches[1]),
7-
MINOR: parseInt(matches[2]),
8-
PATCH: parseInt(matches[3])
7+
DD_MAJOR: parseInt(ddMatches[1]),
8+
DD_MINOR: parseInt(ddMatches[2]),
9+
DD_PATCH: parseInt(ddMatches[3]),
10+
NODE_MAJOR: parseInt(nodeMatches[1]),
11+
NODE_MINOR: parseInt(nodeMatches[2]),
12+
NODE_PATCH: parseInt(nodeMatches[3])
913
}

0 commit comments

Comments
 (0)