Skip to content

Commit

Permalink
hotfix: updated OS agent, edited pm2 config to not need env var
Browse files Browse the repository at this point in the history
  • Loading branch information
adnanrahic committed Jan 22, 2020
1 parent f3176b7 commit 78f936d
Show file tree
Hide file tree
Showing 4 changed files with 215 additions and 39 deletions.
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ Please note the use of double "_" for nested properties
export SPM_LOG_LEVEL=error
export SPM_LOG_TO_CONSOLE=true
export HTTPS_PROXY=http://my-local-proxy-server
# if you are using PM2
export PM2=true

## Changing API endpoints for Sematext Cloud EU

Expand Down Expand Up @@ -120,11 +118,7 @@ require('spm-agent-nodejs')
```

## With PM2
Add an additional environment variable to your environment or `.env` file to enable PM2 monitoring.

```env
PM2=true
```
Use the absolute path to your `.env` file to enable PM2 monitoring.

```js
// load env vars if you're using dotenv
Expand All @@ -133,7 +127,6 @@ require('dotenv').config({ path: '/absolute/path/to/your/project/.env' })
require('spm-agent-nodejs')
```


# Results

- _[Top Node.js Metrics to Watch](https://blog.sematext.com/top-nodejs-metrics-to-watch/)
Expand Down
6 changes: 3 additions & 3 deletions lib/processAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const { Agent, Config } = require('spm-agent')
const pidUsageTree = require('pidusage-tree')
const fs = require('fs')
const execProcess = require('child_process').spawnSync
const pm2Enabled = /^true/i.test(process.env.PM2)
const pm2Enabled = process.env.NODE_APP_INSTANCE !== undefined
const infraToken = Config.tokens.infra

const getThreadCount = function (processId) {
Expand All @@ -26,7 +26,7 @@ const getThreadCount = function (processId) {
threadCount = Number(threadCountLine[1])
}
} catch (err) {
// console.error(err)
console.error(err)
}
}
if (/win/i.test(process.platform)) {
Expand All @@ -48,7 +48,7 @@ const getThreadCount = function (processId) {
threadCount = darwinTc - 1 // remove headline
}
} catch (darwinErr) {
// console.error(darwinErr)
console.error(darwinErr)
}
}
return threadCount
Expand Down
Loading

0 comments on commit 78f936d

Please sign in to comment.