Skip to content

Commit

Permalink
DEV: permit dynamic metrics control
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael O'Brien committed Sep 9, 2021
1 parent 85e54a9 commit f70b04c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
3 changes: 0 additions & 3 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
senselogs License
===

MIT License

Copyright (c) 2019-2020 Michael O'Brien
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ But for all others, you can connect the redact function to any one of the NPM re

### SenseLogs Class API

The SenseLogs class provides the public API for SenseLogs and public properties..
The SenseLogs class provides the public API for SenseLogs and public properties.

### SenseLogs Constructor

Expand Down
2 changes: 0 additions & 2 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
SenseLogs TypeScript definitions
*/

import { MessageChannel } from "worker_threads";

type Destination = {
write: (log: SenseLogs, context: {}) => void
};
Expand Down
8 changes: 6 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,16 +430,20 @@ export default class SenseLogs {
/*
Emit a CloudWatch metic using the CloudWatch EMF format.
metrics('metrics', message, 'MyCompany/MyApp', {UserSessions: 1}, dimensions, {UserSessions: 'Count'})
metrics(chan, message, 'MyCompany/MyApp', {UserSessions: 1}, dimensions, {UserSessions: 'Count'})
*/
metrics(chan, message, namespace, values, dimensions = [[]], units = null) {
if (!this.#top.#filter.metrics) {
let top = this.#top
if (!top.#filter.metrics) {
return
}
/* istanbul ignore next */
if (!namespace || !values) {
throw new Error('Missing namespace or values')
}
if (!this.enabled(chan, 1)) {
return
}
let keys = Object.keys(values).filter(v => dimensions[0].indexOf(v) < 0)
let metrics = keys.map(name => {
let def = {Name: name}
Expand Down

0 comments on commit f70b04c

Please sign in to comment.