Skip to content

Commit

Permalink
add experimental tracing using a native event collector
Browse files Browse the repository at this point in the history
  • Loading branch information
rochdev committed Apr 20, 2024
1 parent c4c01e4 commit f939b4a
Show file tree
Hide file tree
Showing 16 changed files with 929 additions and 36 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/collector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Collector

on:
pull_request:
push:
branches: [master]
schedule:
- cron: '0 4 * * *'

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

# TODO: upstream jobs

jobs:
express:
runs-on: ubuntu-latest
env:
PLUGINS: express|body-parser|cookie-parser
NODE_OPTIONS: -r ./libdatadog-nodejs/global
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
- repository: https://github.com/DataDog/libdatadog-nodejs.git
- path: libdatadog-nodejs
- run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- run: npm run build
working-directory: ./libdatadog-nodejs
- uses: ./.github/actions/testagent/start
- uses: ./.github/actions/node/setup
- run: yarn install
- uses: ./.github/actions/node/oldest
- run: yarn test:plugins:ci
- uses: ./.github/actions/node/latest
- run: yarn test:plugins:ci
- if: always()
uses: ./.github/actions/testagent/logs
- uses: codecov/codecov-action@v3
34 changes: 34 additions & 0 deletions integration-tests/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,40 @@ class FakeAgent extends EventEmitter {
payload: msgpack.decode(req.body, { codec })
})
})
app.put('/v0.5/traces', (req, res) => {
if (req.body.length === 0) return res.status(200).send()
res.status(200).send({ rate_by_service: { 'service:,env:': 1 } })
const [strings, traces] = msgpack.decode(req.body, { codec })
this.emit('message', {
headers: req.headers,
payload: traces.map(trace => {
return trace.map(span => {
const meta = {}
const metrics = {}

Object.keys(span[9]).forEach(key => { meta[strings[key]] = strings[span[9][key]] })
Object.keys(span[10]).forEach(key => { metrics[strings[key]] = span[10][key] })

span = {
service: strings[span[0]],
name: strings[span[1]],
resource: strings[span[2]],
trace_id: span[3],
span_id: span[4],
parent_id: span[5],
start: span[6],
duration: span[7],
error: span[8],
meta,
metrics,
type: strings[span[11]]
}

return span
})
})
})
})
app.post('/profiling/v1/input', upload.any(), (req, res) => {
res.status(200).send()
this.emit('message', {
Expand Down
4 changes: 2 additions & 2 deletions packages/datadog-plugin-express/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1471,13 +1471,13 @@ describe('Plugin', () => {
})

describe('with configuration for middleware disabled', () => {
before(() => {
beforeEach(() => {
return agent.load(['express', 'http'], [{
middleware: false
}, { client: false }])
})

after(() => {
afterEach(() => {
return agent.close({ ritmReset: false })
})

Expand Down
Loading

0 comments on commit f939b4a

Please sign in to comment.