Skip to content

Commit 8de21c3

Browse files
tobespcsjanuary
authored andcommitted
Allow app id to be detected
1 parent 6b4443a commit 8de21c3

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,18 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*******************************************************************************/
16-
1716
var path = require("path")
17+
var main_filename = path.dirname(require.main.filename);
1818
var module_dir = path.dirname(module.filename)
1919
var os = require("os")
20-
//var serializer = require('./lib/serializer.js');
2120
var aspect = require('./lib/aspect.js');
2221
var request = require('./lib/request.js');
2322
var fs = require('fs');
24-
2523
var agent = require("./appmetrics")
2624
// Set the plugin search path
2725
agent.spath(path.join(module_dir, "plugins"))
28-
agent.start();
26+
// pass in the main file name for use in identifying the app in mqtt connection
27+
agent.start(main_filename);
2928

3029
var hcAPI = require("./appmetrics-api.js");
3130
var jsonProfilingMode = false;

src/appmetrics.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,13 @@ static bool initLoaderApi() {
289289

290290
NAN_METHOD(start) {
291291

292-
if (!running) {
293-
running = true;
292+
Local<String> value = info[0]->ToString();
293+
if (info.Length() > 0) {
294+
loaderApi->setProperty("com.ibm.diagnostics.healthcenter.mqtt.application.id", toStdString(value).c_str());
295+
}
296+
297+
if (!running) {
298+
running = true;
294299

295300
loaderApi->init();
296301

@@ -484,7 +489,6 @@ NAN_METHOD(sendControlCommand) {
484489

485490

486491
NAN_METHOD(localConnect) {
487-
488492
if (!isMonitorApiValid()) {
489493
Nan::ThrowError("Monitoring API is not initialized");
490494
return;

0 commit comments

Comments
 (0)