PNG IHDR ; IDATxܻn0K )(pA7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5 bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô!x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%tMז -lG6mrz2s%9s@-k9=)kB5\+͂ZsٲRn~GRCwIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL /F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ R IENDB` ## Classes
Object
object
Expose a metric of type: Counter.
Metric
](#Metric)
* [.counter(name)](#TX2.counter) ⇒ [Counter
](#Counter)
### TX2.action(action_name, [opts], fn)
Expose an action/function triggerable via PM2 or PM2.io
**Kind**: static method of [TX2
](#TX2)
| Param | Type | Description |
| --- | --- | --- |
| action_name | string
| Name of the action |
| [opts] | object
| Optional parameter |
| fn | function
| Function to be called |
**Example** *(Action without arguments)*
```js
tx2.action('run_query', (cb) => {
cb({ success: true })
})
```
**Example** *(Action with arguments)*
```js
tx2.action('run_query', arg1, (cb) => {
cb({ success: arg1 })
})
```
### TX2.event(name, data)
Sends an Event
**Kind**: static method of [TX2
](#TX2)
| Param | Type | Description |
| --- | --- | --- |
| name | string
| Name of the event |
| data | object
| Metadata attached to the event |
**Example**
```js
tx2.event('event-name', { multi: 'data' })
```
### TX2.issue(err)
Sends an Issue
**Kind**: static method of [TX2
](#TX2)
| Param | Type | Description |
| --- | --- | --- |
| err | string
\| Error
| Error object or string to notify |
**Example**
```js
tx2.issue(new Error('bad error')
```
### TX2.metric(name, [function]) ⇒ [Metric
](#Metric)
Expose a Metric
**Kind**: static method of [TX2
](#TX2)
**Returns**: [Metric
](#Metric) - A metrics object
| Param | Type | Description |
| --- | --- | --- |
| name | string
| Name of the metric |
| [function] | function
| Optional function to trigger every second to retrieve updated value |
**Example**
```js
tx2.metric('metric_name', () => obj.value)
```
**Example**
```js
tx2.metric('metric_name', 'unit', () => obj.value)
```
**Example**
```js
let mn = tx2.metric('metric_name')
mn.set(20)
```
### TX2.counter(name) ⇒ [Counter
](#Counter)
Expose a Metric of type: Counter. By calling .inc() or .dec() you update that value
**Kind**: static method of [TX2
](#TX2)
| Param | Type | Description |
| --- | --- | --- |
| name | string
| Name of the Metric |
## Metric : Object
**Kind**: global typedef
**Properties**
| Name | Type | Description |
| --- | --- | --- |
| val | function
| Return the current value |
| set | function
| Set value |
## Counter : object
Expose a metric of type: Counter.
**Kind**: global typedef
**Properties**
| Name | Type | Description |
| --- | --- | --- |
| inc | function
| Increment value |
| dev | function
| Decrement value |