Skip to content

Commit

Permalink
Skip OTel auto-instrumentation test as sdk-node does not support Node…
Browse files Browse the repository at this point in the history
….js 12 (#3277)
  • Loading branch information
Stephen Belanger authored Jun 21, 2023
1 parent 7fe9023 commit 2780cb3
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions integration-tests/opentelemetry.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { FakeAgent, createSandbox } = require('./helpers')
const { fork } = require('child_process')
const { join } = require('path')
const { assert } = require('chai')
const { satisfies } = require('semver')

function check (agent, proc, timeout, onMessage = () => { }) {
return Promise.all([
Expand Down Expand Up @@ -45,12 +46,15 @@ describe('opentelemetry', () => {
const timeout = 5000

before(async () => {
sandbox = await createSandbox([
'@opentelemetry/api',
'@opentelemetry/sdk-node',
const dependencies = [
'@opentelemetry/api'
]
if (satisfies(process.version.slice(1), '>=14')) {
dependencies.push('@opentelemetry/sdk-node')
// Needed because sdk-node doesn't start a tracer without an exporter
'@opentelemetry/exporter-jaeger'
])
dependencies.push('@opentelemetry/exporter-jaeger')
}
sandbox = await createSandbox(dependencies)
cwd = sandbox.folder
agent = await new FakeAgent().start()
})
Expand Down Expand Up @@ -108,22 +112,24 @@ describe('opentelemetry', () => {
})
})

it('should auto-instrument @opentelemetry/sdk-node', async () => {
proc = fork(join(cwd, 'opentelemetry/env-var.js'), {
cwd,
env: {
DD_TRACE_AGENT_PORT: agent.port
}
if (satisfies(process.version.slice(1), '>=14')) {
it('should auto-instrument @opentelemetry/sdk-node', async () => {
proc = fork(join(cwd, 'opentelemetry/env-var.js'), {
cwd,
env: {
DD_TRACE_AGENT_PORT: agent.port
}
})
return check(agent, proc, timeout, ({ payload }) => {
// Should have a single trace with a single span
assert.strictEqual(payload.length, 1)
const [trace] = payload
assert.strictEqual(trace.length, 1)
const [span] = trace

// Should be the expected otel span
assert.strictEqual(span.name, 'otel-sub')
})
})
return check(agent, proc, timeout, ({ payload }) => {
// Should have a single trace with a single span
assert.strictEqual(payload.length, 1)
const [trace] = payload
assert.strictEqual(trace.length, 1)
const [span] = trace

// Should be the expected otel span
assert.strictEqual(span.name, 'otel-sub')
})
})
}
})

0 comments on commit 2780cb3

Please sign in to comment.