@@ -278,6 +278,8 @@ Object.keys(versions).forEach(function(version) {
278278 var client ;
279279 var shouldTraceArgs : any [ ] = [ ] ;
280280 describe ( version , function ( ) {
281+ const skipFor1_6 = version === 'grpc1_6' ? it . skip : it ;
282+
281283 before ( function ( ) {
282284 // Set up to record invocations of shouldTrace
283285 shimmer . wrap ( TracingPolicy , 'createTracePolicy' , function ( original ) {
@@ -356,16 +358,6 @@ Object.keys(versions).forEach(function(version) {
356358 } ) ;
357359 } ) ;
358360
359- it ( 'should propagate context' , function ( done ) {
360- common . runInTransaction ( function ( endTransaction ) {
361- callUnary ( client , grpc , { } , function ( ) {
362- assert . ok ( common . hasContext ( ) ) ;
363- endTransaction ( ) ;
364- done ( ) ;
365- } ) ;
366- } ) ;
367- } ) ;
368-
369361 it ( 'should accurately measure time for client streaming requests' , function ( done ) {
370362 var start = Date . now ( ) ;
371363 common . runInTransaction ( function ( endTransaction ) {
@@ -431,6 +423,39 @@ Object.keys(versions).forEach(function(version) {
431423 } ) ;
432424 } ) ;
433425
426+ // Older versions of gRPC (<1.7) do not add original names.
427+ skipFor1_6 ( 'should trace client requests using the original method name' , ( done ) => {
428+ common . runInTransaction ( ( endTransaction ) => {
429+ // The original method name is TestUnary.
430+ client . TestUnary ( { n : 10 } , ( err , result ) => {
431+ assert . ifError ( err ) ;
432+ assert . strictEqual ( result . n , 10 ) ;
433+ endTransaction ( ) ;
434+ var assertTraceProperties = function ( predicate ) {
435+ var trace = common . getMatchingSpan ( predicate ) ;
436+ assert . ok ( trace ) ;
437+ assert . strictEqual ( trace . labels . argument , '{"n":10}' ) ;
438+ assert . strictEqual ( trace . labels . result , '{"n":10}' ) ;
439+ } ;
440+ assertTraceProperties ( grpcClientPredicate ) ;
441+ assertTraceProperties ( grpcServerOuterPredicate ) ;
442+ // Check that a child span was created in gRPC root span
443+ assert . ok ( common . getMatchingSpan ( grpcServerInnerPredicate ) ) ;
444+ done ( ) ;
445+ } ) ;
446+ } ) ;
447+ } ) ;
448+
449+ it ( 'should propagate context' , function ( done ) {
450+ common . runInTransaction ( function ( endTransaction ) {
451+ callUnary ( client , grpc , { } , function ( ) {
452+ assert . ok ( common . hasContext ( ) ) ;
453+ endTransaction ( ) ;
454+ done ( ) ;
455+ } ) ;
456+ } ) ;
457+ } ) ;
458+
434459 it ( 'should not break if no parent transaction' , function ( done ) {
435460 callUnary ( client , grpc , { } , function ( ) {
436461 assert . strictEqual ( common . getMatchingSpans ( grpcClientPredicate ) . length , 0 ) ;
0 commit comments