File tree 2 files changed +18
-0
lines changed
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -417,6 +417,12 @@ export class GrpcService extends Service {
417
417
418
418
this . maxRetries = options . maxRetries ;
419
419
this . userAgent = util . getUserAgentFromPackageJson ( config . packageJson ) ;
420
+
421
+ if ( this . providedUserAgent ) {
422
+ this . userAgent = `${ this . providedUserAgent } ${ this . userAgent } ` ;
423
+ }
424
+ options [ 'grpc.primary_user_agent' ] = this . userAgent ;
425
+
420
426
this . activeServiceMap_ = new Map ( ) ;
421
427
this . protos = { } ;
422
428
const protoServices = config . protoServices ;
Original file line number Diff line number Diff line change @@ -402,6 +402,18 @@ describe('GrpcService', () => {
402
402
assert . strictEqual ( grpcService . userAgent , userAgent ) ;
403
403
} ) ;
404
404
405
+ it ( 'should set the primary_user_agent from user-agent' , ( ) => {
406
+ const userAgent = 'user-agent/0.0.0' ;
407
+
408
+ getUserAgentFromPackageJsonOverride = packageJson => {
409
+ assert . strictEqual ( packageJson , CONFIG . packageJson ) ;
410
+ return userAgent ;
411
+ } ;
412
+
413
+ new GrpcService ( CONFIG , OPTIONS ) ;
414
+ assert . strictEqual ( OPTIONS [ 'grpc.primary_user_agent' ] , userAgent ) ;
415
+ } ) ;
416
+
405
417
it ( 'should localize the service' , ( ) => {
406
418
assert . deepStrictEqual (
407
419
Object . keys ( grpcService . protos ) ,
You can’t perform that action at this time.
0 commit comments