Skip to content

Commit

Permalink
update readme for v4 and remove semver for version feature flags (#3148)
Browse files Browse the repository at this point in the history
* update readme to include v4

* use version module instead of semver to match library version
  • Loading branch information
rochdev authored and nsavoire committed Jun 21, 2023
1 parent 440f73d commit abed941
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 30 deletions.
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions packages/datadog-instrumentations/src/jest.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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')
Expand Down Expand Up @@ -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'],
Expand Down
4 changes: 2 additions & 2 deletions packages/datadog-instrumentations/src/next.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions packages/datadog-plugin-jest/test/jasmine2.spec.js
Original file line number Diff line number Diff line change
@@ -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')
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions packages/datadog-plugin-next/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ 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
let port

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()
Expand Down
6 changes: 3 additions & 3 deletions packages/dd-trace/src/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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, () => {})
}

Expand Down Expand Up @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions packages/dd-trace/test/tracer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions version.js
Original file line number Diff line number Diff line change
@@ -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])
}

0 comments on commit abed941

Please sign in to comment.