@@ -22,13 +22,17 @@ var request = require('./lib/request.js');
2222var fs = require ( 'fs' ) ;
2323var nodereport = require ( 'nodereport' ) ;
2424var agent = require ( "./appmetrics" )
25- // Set the plugin search path
25+
2626agent . spath ( path . join ( module_dir , "plugins" ) )
27- // pass in the main file name for use in identifying the app in mqtt connection
28- agent . start ( main_filename ) ;
27+
2928
3029var hcAPI = require ( "./appmetrics-api.js" ) ;
3130var jsonProfilingMode = false ;
31+ var propertyMappings = { 'mqttPort' :'com.ibm.diagnostics.healthcenter.mqtt.broker.port' ,
32+ 'mqttHost' :'com.ibm.diagnostics.healthcenter.mqtt.broker.host' ,
33+ 'applicationID' :'com.ibm.diagnostics.healthcenter.mqtt.application.id' ,
34+ 'mqtt' :'com.ibm.diagnostics.healthcenter.mqtt' ,
35+ 'profiling' :'com.ibm.diagnostics.healthcenter.data.profiling' } ;
3236
3337/*
3438 * Load module probes into probes array by searching the probes directory.
@@ -239,7 +243,9 @@ module.exports.emit = function (topic, data) {
239243
240244// Export monitor() API for consuming data in-process
241245module . exports . monitor = function ( ) {
246+
242247 if ( typeof ( this . api ) == 'undefined' ) {
248+ agent . start ( ) ;
243249 this . api = hcAPI . getAPI ( agent , module . exports ) ;
244250 }
245251 return this . api ;
@@ -251,6 +257,16 @@ module.exports.configure = function(options) {
251257 options = options || { } ;
252258 this . strongTracerInstrument =
253259 options . strongTracer ? options . strongTracer . tracer : null ;
260+ for ( var key in options ) {
261+ if ( propertyMappings [ key ] ) {
262+ agent . setOptions ( propertyMappings [ key ] , options [ key ] ) ;
263+ } else {
264+ agent . setOptions ( key , options [ key ] ) ;
265+ }
266+ }
267+
268+ // If user has not specified application ID, use main filename
269+ main_filename = options . applicationID ? options . applicationID : main_filename ;
254270} ;
255271
256272module . exports . transactionLink = function ( linkName , callback ) {
@@ -266,11 +282,14 @@ module.exports.getJSONProfilingMode = function() {
266282 return jsonProfilingMode ;
267283}
268284
285+ module . exports . start = function ( ) {
286+ agent . setOptions ( propertyMappings [ 'applicationID' ] , main_filename ) ;
287+ agent . start ( ) ;
288+ }
269289module . exports . nodereport = function ( ) {
270290 return nodereport ;
271291}
272292
273293module . exports . writeHeapSnapshot = function ( ) {
274294 return require ( 'heapdump' ) . writeSnapshot . apply ( null , arguments ) ;
275295}
276-
0 commit comments