@@ -45,7 +45,12 @@ describe('opentelemetry', () => {
4545 const timeout = 5000
4646
4747 before ( async ( ) => {
48- sandbox = await createSandbox ( )
48+ sandbox = await createSandbox ( [
49+ '@opentelemetry/api' ,
50+ '@opentelemetry/sdk-node' ,
51+ // Needed because sdk-node doesn't start a tracer without an exporter
52+ '@opentelemetry/exporter-jaeger'
53+ ] )
4954 cwd = sandbox . folder
5055 agent = await new FakeAgent ( ) . start ( )
5156 } )
@@ -102,4 +107,23 @@ describe('opentelemetry', () => {
102107 assert . strictEqual ( ddSpan . parent_id . toString ( ) , otelSpan . span_id . toString ( ) )
103108 } )
104109 } )
110+
111+ it ( 'should auto-instrument @opentelemetry/sdk-node' , async ( ) => {
112+ proc = fork ( join ( cwd , 'opentelemetry/env-var.js' ) , {
113+ cwd,
114+ env : {
115+ DD_TRACE_AGENT_PORT : agent . port
116+ }
117+ } )
118+ return check ( agent , proc , timeout , ( { payload } ) => {
119+ // Should have a single trace with a single span
120+ assert . strictEqual ( payload . length , 1 )
121+ const [ trace ] = payload
122+ assert . strictEqual ( trace . length , 1 )
123+ const [ span ] = trace
124+
125+ // Should be the expected otel span
126+ assert . strictEqual ( span . name , 'otel-sub' )
127+ } )
128+ } )
105129} )
0 commit comments