Skip to content

Commit

Permalink
Revert "Introduce service naming framework (#2941)" (#3093)
Browse files Browse the repository at this point in the history
This reverts commit 1de7a30.
  • Loading branch information
jbertran authored and Jordi Bertran de Balanda committed May 4, 2023
1 parent b33feac commit 8aa9fd6
Show file tree
Hide file tree
Showing 44 changed files with 116 additions and 810 deletions.
1 change: 0 additions & 1 deletion packages/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"expect": true,
"sinon": true,
"proxyquire": true,
"withNamingSchema": true,
"withVersions": true,
"withExports": true
},
Expand Down
4 changes: 3 additions & 1 deletion packages/datadog-plugin-amqp10/src/consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ class Amqp10ConsumerPlugin extends ConsumerPlugin {
const source = getShortName(link)
const address = getAddress(link)

this.startSpan({
this.startSpan('amqp.receive', {
service: this.config.service || `${this.tracer._service}-amqp`,
resource: ['receive', source].filter(v => v).join(' '),
type: 'worker',
kind: 'consumer',
meta: {
'amqp.link.source.address': source,
'amqp.link.role': 'receiver',
Expand Down
4 changes: 3 additions & 1 deletion packages/datadog-plugin-amqp10/src/producer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ class Amqp10ProducerPlugin extends ProducerPlugin {
const address = getAddress(link)
const target = getShortName(link)

this.startSpan({
this.startSpan('amqp.send', {
service: this.config.service || `${this.tracer._service}-amqp`,
resource: ['send', target].filter(v => v).join(' '),
kind: 'producer',
meta: {
'amqp.link.target.address': target,
'amqp.link.role': 'sender',
Expand Down
33 changes: 7 additions & 26 deletions packages/datadog-plugin-amqp10/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
const agent = require('../../dd-trace/test/plugins/agent')
const { ERROR_MESSAGE, ERROR_STACK, ERROR_TYPE } = require('../../dd-trace/src/constants')

const namingSchema = require('./naming')

describe('Plugin', () => {
let tracer
let client
Expand Down Expand Up @@ -65,8 +63,8 @@ describe('Plugin', () => {
.use(traces => {
const span = traces[0][0]

expect(span).to.have.property('name', namingSchema.send.opName)
expect(span).to.have.property('service', namingSchema.send.serviceName)
expect(span).to.have.property('name', 'amqp.send')
expect(span).to.have.property('service', 'test-amqp')
expect(span).to.have.property('resource', 'send amq.topic')
expect(span).to.not.have.property('type')
expect(span.meta).to.have.property('span.kind', 'producer')
Expand All @@ -86,6 +84,7 @@ describe('Plugin', () => {

sender.send({ key: 'value' })
})

it('should handle errors', done => {
let error

Expand Down Expand Up @@ -124,21 +123,15 @@ describe('Plugin', () => {
expect(promise).to.have.property('value')
})
})

withNamingSchema(
() => sender.send({ key: 'value' }),
() => namingSchema.send.opName,
() => namingSchema.send.serviceName
)
})

describe('when consuming messages', () => {
it('should do automatic instrumentation', done => {
agent
.use(traces => {
const span = traces[0][0]
expect(span).to.have.property('name', namingSchema.receive.opName)
expect(span).to.have.property('service', namingSchema.receive.serviceName)
expect(span).to.have.property('name', 'amqp.receive')
expect(span).to.have.property('service', 'test-amqp')
expect(span).to.have.property('resource', 'receive amq.topic')
expect(span).to.have.property('type', 'worker')
expect(span.meta).to.have.property('span.kind', 'consumer')
Expand Down Expand Up @@ -170,18 +163,12 @@ describe('Plugin', () => {

sender.send({ key: 'value' })
})

withNamingSchema(
() => sender.send({ key: 'value' }),
() => namingSchema.receive.opName,
() => namingSchema.receive.serviceName
)
})
})

describe('with configuration', () => {
beforeEach(() => {
agent.reload('amqp10', { service: 'test-custom-name' })
agent.reload('amqp10', { service: 'test' })

const amqp = require(`../../../versions/amqp10@${version}`).get()

Expand All @@ -205,19 +192,13 @@ describe('Plugin', () => {
.use(traces => {
const span = traces[0][0]

expect(span).to.have.property('service', 'test-custom-name')
expect(span).to.have.property('service', 'test')
}, 2)
.then(done)
.catch(done)

sender.send({ key: 'value' })
})

withNamingSchema(
() => sender.send({ key: 'value' }),
() => namingSchema.receive.opName,
() => 'test-custom-name'
)
})
})
})
Expand Down
24 changes: 0 additions & 24 deletions packages/datadog-plugin-amqp10/test/naming.js

This file was deleted.

7 changes: 3 additions & 4 deletions packages/datadog-plugin-amqplib/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ const { getResourceName } = require('./util')

class AmqplibClientPlugin extends ClientPlugin {
static get id () { return 'amqplib' }
static get type () { return 'messaging' }
static get operation () { return 'command' }

start ({ channel = {}, method, fields }) {
if (method === 'basic.deliver' || method === 'basic.get') return
if (method === 'basic.publish') return

const stream = (channel.connection && channel.connection.stream) || {}
const span = this.startSpan(this.operationName(), {
service: this.config.service || this.serviceName(),
const span = this.startSpan('amqp.command', {
service: this.config.service || `${this.tracer._service}-amqp`,
resource: getResourceName(method, fields),
kind: this.constructor.kind,
kind: 'client',
meta: {
'out.host': stream._host,
[CLIENT_PORT_KEY]: stream.remotePort,
Expand Down
4 changes: 3 additions & 1 deletion packages/datadog-plugin-amqplib/src/consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ class AmqplibConsumerPlugin extends ConsumerPlugin {

const childOf = extract(this.tracer, message)

this.startSpan({
this.startSpan('amqp.command', {
childOf,
service: this.config.service || `${this.tracer._service}-amqp`,
resource: getResourceName(method, fields),
kind: 'consumer',
type: 'worker',
meta: {
'amqp.queue': fields.queue,
Expand Down
4 changes: 3 additions & 1 deletion packages/datadog-plugin-amqplib/src/producer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ class AmqplibProducerPlugin extends ProducerPlugin {
if (method !== 'basic.publish') return

const stream = (channel.connection && channel.connection.stream) || {}
const span = this.startSpan({
const span = this.startSpan('amqp.command', {
service: this.config.service || `${this.tracer._service}-amqp`,
resource: getResourceName(method, fields),
kind: 'producer',
meta: {
'out.host': stream._host,
[CLIENT_PORT_KEY]: stream.remotePort,
Expand Down
55 changes: 10 additions & 45 deletions packages/datadog-plugin-amqplib/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
const agent = require('../../dd-trace/test/plugins/agent')
const { ERROR_MESSAGE, ERROR_STACK, ERROR_TYPE } = require('../../dd-trace/src/constants')

const namingSchema = require('./naming')

describe('Plugin', () => {
let tracer
let connection
Expand Down Expand Up @@ -57,8 +55,8 @@ describe('Plugin', () => {
agent
.use(traces => {
const span = traces[0][0]
expect(span).to.have.property('name', namingSchema.controlPlane.opName)
expect(span).to.have.property('service', namingSchema.controlPlane.serviceName)
expect(span).to.have.property('name', 'amqp.command')
expect(span).to.have.property('service', 'test-amqp')
expect(span).to.have.property('resource', 'queue.declare test')
expect(span).to.not.have.property('type')
expect(span.meta).to.have.property('span.kind', 'client')
Expand All @@ -77,8 +75,8 @@ describe('Plugin', () => {
.use(traces => {
const span = traces[0][0]

expect(span).to.have.property('name', namingSchema.controlPlane.opName)
expect(span).to.have.property('service', namingSchema.controlPlane.serviceName)
expect(span).to.have.property('name', 'amqp.command')
expect(span).to.have.property('service', 'test-amqp')
expect(span).to.have.property('resource', 'queue.delete test')
expect(span).to.not.have.property('type')
expect(span.meta).to.have.property('span.kind', 'client')
Expand Down Expand Up @@ -115,12 +113,6 @@ describe('Plugin', () => {
error = e
}
})

withNamingSchema(
() => channel.assertQueue('test', {}, () => {}),
() => namingSchema.controlPlane.opName,
() => namingSchema.controlPlane.serviceName
)
})

describe('when publishing messages', () => {
Expand All @@ -129,8 +121,8 @@ describe('Plugin', () => {
.use(traces => {
const span = traces[0][0]

expect(span).to.have.property('name', namingSchema.send.opName)
expect(span).to.have.property('service', namingSchema.send.serviceName)
expect(span).to.have.property('name', 'amqp.command')
expect(span).to.have.property('service', 'test-amqp')
expect(span).to.have.property('resource', 'basic.publish exchange routingKey')
expect(span).to.not.have.property('type')
expect(span.meta).to.have.property('out.host', 'localhost')
Expand Down Expand Up @@ -168,15 +160,6 @@ describe('Plugin', () => {
error = e
}
})

withNamingSchema(
() => {
channel.assertExchange('exchange', 'direct', {}, () => {})
channel.publish('exchange', 'routingKey', Buffer.from('content'))
},
() => namingSchema.send.opName,
() => namingSchema.send.serviceName
)
})

describe('when consuming messages', () => {
Expand All @@ -187,8 +170,8 @@ describe('Plugin', () => {
agent
.use(traces => {
const span = traces[0][0]
expect(span).to.have.property('name', namingSchema.receive.opName)
expect(span).to.have.property('service', namingSchema.receive.serviceName)
expect(span).to.have.property('name', 'amqp.command')
expect(span).to.have.property('service', 'test-amqp')
expect(span).to.have.property('resource', `basic.deliver ${queue}`)
expect(span).to.have.property('type', 'worker')
expect(span.meta).to.have.property('span.kind', 'consumer')
Expand Down Expand Up @@ -253,18 +236,6 @@ describe('Plugin', () => {
})
})
})

withNamingSchema(
() => {
channel.assertQueue('', {}, (err, ok) => {
if (err) return
channel.sendToQueue(ok.queue, Buffer.from('content'))
channel.consume(ok.queue, () => {}, {}, (err, ok) => {})
})
},
() => namingSchema.receive.opName,
() => namingSchema.receive.serviceName
)
})
})

Expand All @@ -289,7 +260,7 @@ describe('Plugin', () => {

describe('with configuration', () => {
before(() => {
return agent.load('amqplib', { service: 'test-custom-service' })
return agent.load('amqplib', { service: 'test' })
})

after(() => {
Expand All @@ -315,20 +286,14 @@ describe('Plugin', () => {
it('should be configured with the correct values', done => {
agent
.use(traces => {
expect(traces[0][0]).to.have.property('service', 'test-custom-service')
expect(traces[0][0]).to.have.property('service', 'test')
expect(traces[0][0]).to.have.property('resource', 'queue.declare test')
}, 2)
.then(done)
.catch(done)

channel.assertQueue('test', {}, () => {})
})

withNamingSchema(
() => channel.assertQueue('test', {}, () => {}),
() => namingSchema.controlPlane.opName,
() => 'test-custom-service'
)
})
})
})
Expand Down
34 changes: 0 additions & 34 deletions packages/datadog-plugin-amqplib/test/naming.js

This file was deleted.

7 changes: 3 additions & 4 deletions packages/datadog-plugin-google-cloud-pubsub/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ const ClientPlugin = require('../../dd-trace/src/plugins/client')

class GoogleCloudPubsubClientPlugin extends ClientPlugin {
static get id () { return 'google-cloud-pubsub' }
static get type () { return 'messaging' }
static get operation () { return 'request' }

start ({ request, api, projectId }) {
if (api === 'publish') return

this.startSpan(this.operationName(), {
service: this.config.service || this.serviceName(),
this.startSpan('pubsub.request', {
service: this.config.service || `${this.tracer._service}-pubsub`,
resource: [api, request.name].filter(x => x).join(' '),
kind: this.constructor.kind,
kind: 'client',
meta: {
'pubsub.method': api,
'gcloud.project_id': projectId
Expand Down
4 changes: 3 additions & 1 deletion packages/datadog-plugin-google-cloud-pubsub/src/consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ class GoogleCloudPubsubConsumerPlugin extends ConsumerPlugin {
const topic = subscription.metadata && subscription.metadata.topic
const childOf = this.tracer.extract('text_map', message.attributes) || null

this.startSpan({
this.startSpan('pubsub.receive', {
childOf,
service: this.config.service,
resource: topic,
kind: 'consumer',
type: 'worker',
meta: {
'gcloud.project_id': subscription.pubsub.projectId,
Expand Down
Loading

0 comments on commit 8aa9fd6

Please sign in to comment.