-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tldraw application level metrics (#4663)
* add tldraw application level metrics --------- Co-authored-by: Tomasz Wiaderek <[email protected]>
- Loading branch information
Showing
7 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './metrics.service'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { Gauge, register } from 'prom-client'; | ||
|
||
@Injectable() | ||
export class MetricsService { | ||
private numberOfUsersOnServerCounter: Gauge<string>; | ||
|
||
private numberOfBoardsOnServerCounter: Gauge<string>; | ||
|
||
constructor() { | ||
this.numberOfUsersOnServerCounter = new Gauge({ | ||
name: 'sc_tldraw_users', | ||
help: 'Number of active users per pod', | ||
}); | ||
|
||
this.numberOfBoardsOnServerCounter = new Gauge({ | ||
name: 'sc_tldraw_boards', | ||
help: 'Number of active boards per pod', | ||
}); | ||
|
||
register.registerMetric(this.numberOfUsersOnServerCounter); | ||
register.registerMetric(this.numberOfBoardsOnServerCounter); | ||
} | ||
|
||
public incrementNumberOfUsersOnServerCounter(): void { | ||
this.numberOfUsersOnServerCounter.inc(); | ||
} | ||
|
||
public decrementNumberOfUsersOnServerCounter(): void { | ||
this.numberOfUsersOnServerCounter.dec(); | ||
} | ||
|
||
public incrementNumberOfBoardsOnServerCounter(): void { | ||
this.numberOfBoardsOnServerCounter.inc(); | ||
} | ||
|
||
public decrementNumberOfBoardsOnServerCounter(): void { | ||
this.numberOfBoardsOnServerCounter.dec(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters