@@ -43,13 +43,11 @@ import * as scanner from './io/scanner';
4343import * as SourceMapper from './io/sourcemapper' ;
4444import * as debugapi from './v8/debugapi' ;
4545
46- const pjson = require ( '../../../package.json' ) ;
47-
4846import * as assert from 'assert' ;
4947
5048import * as stackdriver from '../types/stackdriver' ;
5149import { DebugAgentConfig } from './config' ;
52- import { Debug } from '../client/stackdriver/debug' ;
50+ import { Debug , PackageInfo } from '../client/stackdriver/debug' ;
5351import { Logger } from '../types/common' ;
5452import { DebugApi } from './v8/debugapi' ;
5553
@@ -161,8 +159,10 @@ export class Debuglet extends EventEmitter {
161159 this . fetcherActive_ = false ;
162160
163161 /** @private {common.logger} */
164- this . logger_ = new common . logger (
165- { level : common . logger . LEVELS [ this . config_ . logLevel ] , tag : pjson . name } ) ;
162+ this . logger_ = new common . logger ( {
163+ level : common . logger . LEVELS [ this . config_ . logLevel ] ,
164+ tag : this . debug_ . packageInfo . name
165+ } ) ;
166166
167167 /** @private {DebugletApi} */
168168 this . controller_ = new Controller ( this . debug_ ) ;
@@ -315,7 +315,8 @@ export class Debuglet extends EventEmitter {
315315 that . debuggee_ = Debuglet . createDebuggee (
316316 // TODO: Address the case when `id` is `undefined`.
317317 project , id as string , that . config_ . serviceContext , sourceContext ,
318- onGCP , that . config_ . description , undefined ) ;
318+ onGCP , that . debug_ . packageInfo , that . config_ . description ,
319+ undefined ) ;
319320 that . scheduleRegistration_ ( 0 /* immediately */ ) ;
320321 that . emit ( 'started' ) ;
321322 } ) ;
@@ -332,21 +333,22 @@ export class Debuglet extends EventEmitter {
332333 serviceContext :
333334 { service ?: string , version ?: string , minorVersion_ ?: string } ,
334335 sourceContext : { [ key : string ] : string } , onGCP : boolean ,
335- description ?: string , errorMessage ?: string ) : Debuggee {
336+ packageInfo : PackageInfo , description ?: string ,
337+ errorMessage ?: string ) : Debuggee {
336338 const cwd = process . cwd ( ) ;
337339 const mainScript = path . relative ( cwd , process . argv [ 1 ] ) ;
338340
339341 const version = 'google.com/node-' + ( onGCP ? 'gcp' : 'standalone' ) + '/v' +
340- pjson . version ;
342+ packageInfo . version ;
341343 let desc = process . title + ' ' + mainScript ;
342344
343345 const labels : { [ key : string ] : string } = {
344346 'main script' : mainScript ,
345347 'process.title' : process . title ,
346348 'node version' : process . versions . node ,
347349 'V8 version' : process . versions . v8 ,
348- 'agent.name' : pjson . name ,
349- 'agent.version' : pjson . version ,
350+ 'agent.name' : packageInfo . name ,
351+ 'agent.version' : packageInfo . version ,
350352 'projectid' : projectId
351353 } ;
352354
@@ -392,7 +394,8 @@ export class Debuglet extends EventEmitter {
392394 agentVersion : version ,
393395 labels : labels ,
394396 statusMessage : statusMessage ,
395- sourceContexts : [ sourceContext ]
397+ sourceContexts : [ sourceContext ] ,
398+ packageInfo : packageInfo
396399 } ;
397400 return new Debuggee ( properties ) ;
398401 }
0 commit comments