diff --git a/packages/datadog-plugin-fetch/test/index.spec.js b/packages/datadog-plugin-fetch/test/index.spec.js index 0d25e3a78d4..d23067f6355 100644 --- a/packages/datadog-plugin-fetch/test/index.spec.js +++ b/packages/datadog-plugin-fetch/test/index.spec.js @@ -6,10 +6,12 @@ const tags = require('../../../ext/tags') const { expect } = require('chai') const { storage } = require('../../datadog-core') const { ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants') +const { DD_MAJOR } = require('../../../version') const HTTP_REQUEST_HEADERS = tags.HTTP_REQUEST_HEADERS const HTTP_RESPONSE_HEADERS = tags.HTTP_RESPONSE_HEADERS +const SERVICE_NAME = DD_MAJOR < 3 ? 'test-http-client' : 'test' const describe = globalThis.fetch ? globalThis.describe : globalThis.describe.skip describe('Plugin', () => { @@ -52,7 +54,7 @@ describe('Plugin', () => { getPort().then(port => { agent .use(traces => { - expect(traces[0][0]).to.have.property('service', 'test') + expect(traces[0][0]).to.have.property('service', SERVICE_NAME) expect(traces[0][0]).to.have.property('type', 'http') expect(traces[0][0]).to.have.property('resource', 'GET') expect(traces[0][0].meta).to.have.property('span.kind', 'client') @@ -79,7 +81,7 @@ describe('Plugin', () => { getPort().then(port => { agent .use(traces => { - expect(traces[0][0]).to.have.property('service', 'test') + expect(traces[0][0]).to.have.property('service', SERVICE_NAME) expect(traces[0][0]).to.have.property('type', 'http') expect(traces[0][0]).to.have.property('resource', 'GET') expect(traces[0][0].meta).to.have.property('span.kind', 'client') @@ -106,7 +108,7 @@ describe('Plugin', () => { getPort().then(port => { agent .use(traces => { - expect(traces[0][0]).to.have.property('service', 'test') + expect(traces[0][0]).to.have.property('service', SERVICE_NAME) expect(traces[0][0]).to.have.property('type', 'http') expect(traces[0][0]).to.have.property('resource', 'GET') expect(traces[0][0].meta).to.have.property('span.kind', 'client') @@ -390,7 +392,7 @@ describe('Plugin', () => { getPort().then(port => { agent .use(traces => { - expect(traces[0][0]).to.have.property('service', 'test') + expect(traces[0][0]).to.have.property('service', SERVICE_NAME) }) .then(done) .catch(done) diff --git a/packages/datadog-plugin-http/test/client.spec.js b/packages/datadog-plugin-http/test/client.spec.js index 20b499e8244..243f37ca462 100644 --- a/packages/datadog-plugin-http/test/client.spec.js +++ b/packages/datadog-plugin-http/test/client.spec.js @@ -10,10 +10,12 @@ const { storage } = require('../../datadog-core') const key = fs.readFileSync(path.join(__dirname, './ssl/test.key')) const cert = fs.readFileSync(path.join(__dirname, './ssl/test.crt')) const { ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants') +const { DD_MAJOR } = require('../../../version') const HTTP_REQUEST_HEADERS = tags.HTTP_REQUEST_HEADERS const HTTP_RESPONSE_HEADERS = tags.HTTP_RESPONSE_HEADERS const NODE_MAJOR = parseInt(process.versions.node.split('.')[0]) +const SERVICE_NAME = DD_MAJOR < 3 ? 'test-http-client' : 'test' describe('Plugin', () => { let express @@ -64,7 +66,7 @@ describe('Plugin', () => { getPort().then(port => { agent .use(traces => { - expect(traces[0][0]).to.have.property('service', 'test') + expect(traces[0][0]).to.have.property('service', SERVICE_NAME) expect(traces[0][0]).to.have.property('type', 'http') expect(traces[0][0]).to.have.property('resource', 'GET') expect(traces[0][0].meta).to.have.property('span.kind', 'client') @@ -121,7 +123,7 @@ describe('Plugin', () => { getPort().then(port => { agent .use(traces => { - expect(traces[0][0]).to.have.property('service', 'test') + expect(traces[0][0]).to.have.property('service', SERVICE_NAME) expect(traces[0][0]).to.have.property('type', 'http') expect(traces[0][0]).to.have.property('resource', 'CONNECT') expect(traces[0][0].meta).to.have.property('span.kind', 'client') @@ -166,7 +168,7 @@ describe('Plugin', () => { getPort().then(port => { agent .use(traces => { - expect(traces[0][0]).to.have.property('service', 'test') + expect(traces[0][0]).to.have.property('service', SERVICE_NAME) expect(traces[0][0]).to.have.property('type', 'http') expect(traces[0][0]).to.have.property('resource', 'GET') expect(traces[0][0].meta).to.have.property('span.kind', 'client') @@ -825,7 +827,7 @@ describe('Plugin', () => { getPort().then(port => { agent .use(traces => { - expect(traces[0][0]).to.have.property('service', 'test') + expect(traces[0][0]).to.have.property('service', SERVICE_NAME) }) .then(done) .catch(done) diff --git a/packages/datadog-plugin-http2/test/client.spec.js b/packages/datadog-plugin-http2/test/client.spec.js index 410eb6ac09b..312594923f9 100644 --- a/packages/datadog-plugin-http2/test/client.spec.js +++ b/packages/datadog-plugin-http2/test/client.spec.js @@ -8,9 +8,11 @@ const tags = require('../../../ext/tags') const key = fs.readFileSync(path.join(__dirname, './ssl/test.key')) const cert = fs.readFileSync(path.join(__dirname, './ssl/test.crt')) const { ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants') +const { DD_MAJOR } = require('../../../version') const HTTP_REQUEST_HEADERS = tags.HTTP_REQUEST_HEADERS const HTTP_RESPONSE_HEADERS = tags.HTTP_RESPONSE_HEADERS +const SERVICE_NAME = DD_MAJOR < 3 ? 'test-http-client' : 'test' describe('Plugin', () => { let http2 @@ -63,7 +65,7 @@ describe('Plugin', () => { getPort().then(port => { agent .use(traces => { - expect(traces[0][0]).to.have.property('service', 'test') + expect(traces[0][0]).to.have.property('service', SERVICE_NAME) expect(traces[0][0]).to.have.property('type', 'http') expect(traces[0][0]).to.have.property('resource', 'GET') expect(traces[0][0].meta).to.have.property('span.kind', 'client')