Skip to content

Commit

Permalink
adds pending specs for pipeline and stream
Browse files Browse the repository at this point in the history
  • Loading branch information
flovilmart committed Jan 31, 2022
1 parent 7b51211 commit e0f306f
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/datadog-plugin-undici/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,10 @@ module.exports = [
patch.call(this, undici, 'upgrade', tracer, config)
patch.call(this, undici, 'connect', tracer, config)
patch.call(this, undici, 'fetch', tracer, config)
patch.call(this, undici, 'pipeline', tracer, config)
patch.call(this, undici, 'stream', tracer, config)
patch.call(this, undici.Client.prototype, 'request', tracer, config)

// Stream take different args arguments
// patch.call(this, undici, 'stream', tracer, config)
this.unpatch = diagnostics.call(this, tracer, config)
}
}
Expand Down
69 changes: 69 additions & 0 deletions packages/datadog-plugin-undici/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ describe('undici', () => {
})
})
})

it('should do automatic instrumentation for connect', (done) => {
const app = express()

Expand Down Expand Up @@ -145,6 +146,74 @@ describe('undici', () => {
})
})
})

xit('should do automatic instrumentation for pipeline', (done) => {
const app = express()

app.get('/user', (_, res) => {
res.status(200).send()
})

getPort().then((port) => {
agent
.use((traces) => {
console.log(traces)
expect(traces[0][0]).to.have.property(
'service',
'test-http-client'
)
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')
expect(traces[0][0].meta).to.have.property(
'http.url',
`http://localhost:${port}/user`
)
expect(traces[0][0].meta).to.have.property('http.method', 'GET')
})
.then(done)
.catch(done)

appListener = server(app, port, () => {
undici.pipeline(`http://localhost:${port}/user`, (pipe) => {
console.log(pipe)
})
})
})
})

xit('should do automatic instrumentation for stream', (done) => {
const app = express()

app.connect('/user', (_, res) => {
res.status(200).send()
})

getPort().then((port) => {
agent
.use((traces) => {
console.log(traces)
expect(traces[0][0]).to.have.property(
'service',
'test-http-client'
)
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')
expect(traces[0][0].meta).to.have.property(
'http.url',
`http://localhost:${port}/user`
)
expect(traces[0][0].meta).to.have.property('http.method', 'GET')
})
.then(done)
.catch(done)

appListener = server(app, port, () => {
undici.stream(`http://localhost:${port}/user`)
})
})
})
})

describe('without configuration', () => {
Expand Down

0 comments on commit e0f306f

Please sign in to comment.