Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
szegedi committed Oct 25, 2024
1 parent 9618c26 commit 1b6dade
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions packages/dd-trace/test/profiling/exporters/agent.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,43 @@ describe('exporters/agent', function () {
waitForResponse
])
})

it('should not retry on 4xx errors', async function () {
const exporter = newAgentExporter({ url, logger: { debug: () => {}, error: () => {} } })
const start = new Date()
const end = new Date()
const tags = { foo: 'bar' }

const [wall, space] = await Promise.all([
createProfile(['wall', 'microseconds']),
createProfile(['space', 'bytes'])
])

const profiles = {
wall,
space
}

let tries = 0
const json = JSON.stringify({ error: 'some error' })
app.post('/profiling/v1/input', upload.any(), (_, res) => {
tries++
const data = Buffer.from(json)
res.writeHead(400, {
'content-type': 'application/json',
'content-length': data.length
})
res.end(data)
})

try {
await exporter.export({ profiles, start, end, tags })
throw new Error('should have thrown')
} catch (err) {
expect(err.message).to.equal('HTTP Error 400')
}
expect(tries).to.equal(1)
})
})

describe('using ipv6', () => {
Expand Down

0 comments on commit 1b6dade

Please sign in to comment.