@@ -8,8 +8,9 @@ import { SpanStatusCode } from '@opentelemetry/api';
88import { ExportResultCode } from '@opentelemetry/core' ;
99import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc' ;
1010import * as opentelemetry from '@opentelemetry/sdk-node' ;
11- import { BasicTracerProvider , InMemorySpanExporter , SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base' ;
12- import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions' ;
11+ import { InMemorySpanExporter , SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base' ;
12+ import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node' ;
13+ import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions' ;
1314import test from 'ava' ;
1415import { v4 as uuid4 } from 'uuid' ;
1516import { Connection , WorkflowClient } from '@temporalio/client' ;
@@ -234,8 +235,8 @@ if (RUN_INTEGRATION_TESTS) {
234235 try {
235236 const spans = Array < opentelemetry . tracing . ReadableSpan > ( ) ;
236237
237- const staticResource = new opentelemetry . resources . Resource ( {
238- [ SemanticResourceAttributes . SERVICE_NAME ] : 'ts-test-otel-worker' ,
238+ const staticResource = opentelemetry . resources . resourceFromAttributes ( {
239+ [ ATTR_SERVICE_NAME ] : 'ts-test-otel-worker' ,
239240 } ) ;
240241 const traceExporter : opentelemetry . tracing . SpanExporter = {
241242 export ( spans_ , resultCallback ) {
@@ -283,98 +284,102 @@ if (RUN_INTEGRATION_TESTS) {
283284 const originalSpan = spans . find ( ( { name } ) => name === `${ SpanName . WORKFLOW_START } ${ SPAN_DELIMITER } smorgasbord` ) ;
284285 t . true ( originalSpan !== undefined ) ;
285286 t . log (
286- spans . map ( ( span ) => ( { name : span . name , parentSpanId : span . parentSpanId , spanId : span . spanContext ( ) . spanId } ) )
287+ spans . map ( ( span ) => ( {
288+ name : span . name ,
289+ parentSpanContext : span . parentSpanContext ,
290+ spanId : span . spanContext ( ) . spanId ,
291+ } ) )
287292 ) ;
288293
289294 const firstExecuteSpan = spans . find (
290- ( { name, parentSpanId } ) =>
295+ ( { name, parentSpanContext } ) =>
291296 name === `${ SpanName . WORKFLOW_EXECUTE } ${ SPAN_DELIMITER } smorgasbord` &&
292- parentSpanId === originalSpan ?. spanContext ( ) . spanId
297+ parentSpanContext === originalSpan ?. spanContext ( )
293298 ) ;
294299 t . true ( firstExecuteSpan !== undefined ) ;
295300 t . true ( firstExecuteSpan ! . status . code === SpanStatusCode . OK ) ;
296301
297302 const continueAsNewSpan = spans . find (
298- ( { name, parentSpanId } ) =>
303+ ( { name, parentSpanContext } ) =>
299304 name === `${ SpanName . CONTINUE_AS_NEW } ${ SPAN_DELIMITER } smorgasbord` &&
300- parentSpanId === firstExecuteSpan ?. spanContext ( ) . spanId
305+ parentSpanContext === firstExecuteSpan ?. spanContext ( )
301306 ) ;
302307 t . true ( continueAsNewSpan !== undefined ) ;
303308 t . true ( continueAsNewSpan ! . status . code === SpanStatusCode . OK ) ;
304309
305310 const parentExecuteSpan = spans . find (
306- ( { name, parentSpanId } ) =>
311+ ( { name, parentSpanContext } ) =>
307312 name === `${ SpanName . WORKFLOW_EXECUTE } ${ SPAN_DELIMITER } smorgasbord` &&
308- parentSpanId === continueAsNewSpan ?. spanContext ( ) . spanId
313+ parentSpanContext === continueAsNewSpan ?. spanContext ( )
309314 ) ;
310315 t . true ( parentExecuteSpan !== undefined ) ;
311316 const firstActivityStartSpan = spans . find (
312- ( { name, parentSpanId } ) =>
317+ ( { name, parentSpanContext } ) =>
313318 name === `${ SpanName . ACTIVITY_START } ${ SPAN_DELIMITER } fakeProgress` &&
314- parentSpanId === parentExecuteSpan ?. spanContext ( ) . spanId
319+ parentSpanContext === parentExecuteSpan ?. spanContext ( )
315320 ) ;
316321 t . true ( firstActivityStartSpan !== undefined ) ;
317322
318323 const firstActivityExecuteSpan = spans . find (
319- ( { name, parentSpanId } ) =>
324+ ( { name, parentSpanContext } ) =>
320325 name === `${ SpanName . ACTIVITY_EXECUTE } ${ SPAN_DELIMITER } fakeProgress` &&
321- parentSpanId === firstActivityStartSpan ?. spanContext ( ) . spanId
326+ parentSpanContext === firstActivityStartSpan ?. spanContext ( )
322327 ) ;
323328 t . true ( firstActivityExecuteSpan !== undefined ) ;
324329
325330 const secondActivityStartSpan = spans . find (
326- ( { name, parentSpanId } ) =>
331+ ( { name, parentSpanContext } ) =>
327332 name === `${ SpanName . ACTIVITY_START } ${ SPAN_DELIMITER } queryOwnWf` &&
328- parentSpanId === parentExecuteSpan ?. spanContext ( ) . spanId
333+ parentSpanContext === parentExecuteSpan ?. spanContext ( )
329334 ) ;
330335 t . true ( secondActivityStartSpan !== undefined ) ;
331336
332337 const secondActivityExecuteSpan = spans . find (
333- ( { name, parentSpanId } ) =>
338+ ( { name, parentSpanContext } ) =>
334339 name === `${ SpanName . ACTIVITY_EXECUTE } ${ SPAN_DELIMITER } queryOwnWf` &&
335- parentSpanId === secondActivityStartSpan ?. spanContext ( ) . spanId
340+ parentSpanContext === secondActivityStartSpan ?. spanContext ( )
336341 ) ;
337342 t . true ( secondActivityExecuteSpan !== undefined ) ;
338343
339344 const childWorkflowStartSpan = spans . find (
340- ( { name, parentSpanId } ) =>
345+ ( { name, parentSpanContext } ) =>
341346 name === `${ SpanName . CHILD_WORKFLOW_START } ${ SPAN_DELIMITER } signalTarget` &&
342- parentSpanId === parentExecuteSpan ?. spanContext ( ) . spanId
347+ parentSpanContext === parentExecuteSpan ?. spanContext ( )
343348 ) ;
344349 t . true ( childWorkflowStartSpan !== undefined ) ;
345350
346351 const childWorkflowExecuteSpan = spans . find (
347- ( { name, parentSpanId } ) =>
352+ ( { name, parentSpanContext } ) =>
348353 name === `${ SpanName . WORKFLOW_EXECUTE } ${ SPAN_DELIMITER } signalTarget` &&
349- parentSpanId === childWorkflowStartSpan ?. spanContext ( ) . spanId
354+ parentSpanContext === childWorkflowStartSpan ?. spanContext ( )
350355 ) ;
351356 t . true ( childWorkflowExecuteSpan !== undefined ) ;
352357
353358 const signalChildWithUnblockSpan = spans . find (
354- ( { name, parentSpanId } ) =>
359+ ( { name, parentSpanContext } ) =>
355360 name === `${ SpanName . WORKFLOW_SIGNAL } ${ SPAN_DELIMITER } unblock` &&
356- parentSpanId === parentExecuteSpan ?. spanContext ( ) . spanId
361+ parentSpanContext === parentExecuteSpan ?. spanContext ( )
357362 ) ;
358363 t . true ( signalChildWithUnblockSpan !== undefined ) ;
359364
360365 const localActivityStartSpan = spans . find (
361- ( { name, parentSpanId } ) =>
366+ ( { name, parentSpanContext } ) =>
362367 name === `${ SpanName . ACTIVITY_START } ${ SPAN_DELIMITER } echo` &&
363- parentSpanId === parentExecuteSpan ?. spanContext ( ) . spanId
368+ parentSpanContext === parentExecuteSpan ?. spanContext ( )
364369 ) ;
365370 t . true ( localActivityStartSpan !== undefined ) ;
366371
367372 const localActivityExecuteSpan = spans . find (
368- ( { name, parentSpanId } ) =>
373+ ( { name, parentSpanContext } ) =>
369374 name === `${ SpanName . ACTIVITY_EXECUTE } ${ SPAN_DELIMITER } echo` &&
370- parentSpanId === localActivityStartSpan ?. spanContext ( ) . spanId
375+ parentSpanContext === localActivityStartSpan ?. spanContext ( )
371376 ) ;
372377 t . true ( localActivityExecuteSpan !== undefined ) ;
373378
374379 const activityStartedSignalSpan = spans . find (
375- ( { name, parentSpanId } ) =>
380+ ( { name, parentSpanContext } ) =>
376381 name === `${ SpanName . WORKFLOW_SIGNAL } ${ SPAN_DELIMITER } activityStarted` &&
377- parentSpanId === firstActivityExecuteSpan ?. spanContext ( ) . spanId
382+ parentSpanContext === firstActivityExecuteSpan ?. spanContext ( )
378383 ) ;
379384 t . true ( activityStartedSignalSpan !== undefined ) ;
380385
@@ -396,8 +401,8 @@ if (RUN_INTEGRATION_TESTS) {
396401 try {
397402 const oTelUrl = 'http://127.0.0.1:4317' ;
398403 const exporter = new OTLPTraceExporter ( { url : oTelUrl } ) ;
399- const staticResource = new opentelemetry . resources . Resource ( {
400- [ SemanticResourceAttributes . SERVICE_NAME ] : 'ts-test-otel-worker' ,
404+ const staticResource = opentelemetry . resources . resourceFromAttributes ( {
405+ [ ATTR_SERVICE_NAME ] : 'ts-test-otel-worker' ,
401406 } ) ;
402407 const otel = new opentelemetry . NodeSDK ( {
403408 resource : staticResource ,
@@ -440,8 +445,7 @@ if (RUN_INTEGRATION_TESTS) {
440445
441446 test ( 'instrumentation: Error status includes message and records exception' , async ( t ) => {
442447 const memoryExporter = new InMemorySpanExporter ( ) ;
443- const provider = new BasicTracerProvider ( ) ;
444- provider . addSpanProcessor ( new SimpleSpanProcessor ( memoryExporter ) ) ;
448+ const provider = new NodeTracerProvider ( { spanProcessors : [ new SimpleSpanProcessor ( memoryExporter ) ] } ) ;
445449 provider . register ( ) ;
446450 const tracer = provider . getTracer ( 'test-error-tracer' ) ;
447451
0 commit comments