Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
33b1d676
Commit
33b1d676
authored
Apr 19, 2021
by
Annie Ke
Committed by
Liam Horne
Apr 21, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add metrics.ts and use in base-service
parent
3514ae87
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
base-service.ts
packages/core-utils/src/base-service.ts
+3
-0
metrics.ts
packages/core-utils/src/common/metrics.ts
+31
-0
No files found.
packages/core-utils/src/base-service.ts
View file @
33b1d676
/* Imports: Internal */
/* Imports: Internal */
import
{
Logger
}
from
'
./common/logger
'
import
{
Logger
}
from
'
./common/logger
'
import
{
Metrics
}
from
'
./common/metrics
'
type
OptionSettings
<
TOptions
>
=
{
type
OptionSettings
<
TOptions
>
=
{
[
P
in
keyof
TOptions
]?:
{
[
P
in
keyof
TOptions
]?:
{
...
@@ -16,6 +17,7 @@ export class BaseService<T> {
...
@@ -16,6 +17,7 @@ export class BaseService<T> {
protected
name
:
string
protected
name
:
string
protected
options
:
T
protected
options
:
T
protected
logger
:
Logger
protected
logger
:
Logger
protected
metrics
:
Metrics
protected
initialized
:
boolean
=
false
protected
initialized
:
boolean
=
false
protected
running
:
boolean
=
false
protected
running
:
boolean
=
false
...
@@ -24,6 +26,7 @@ export class BaseService<T> {
...
@@ -24,6 +26,7 @@ export class BaseService<T> {
this
.
name
=
name
this
.
name
=
name
this
.
options
=
mergeDefaultOptions
(
options
,
optionSettings
)
this
.
options
=
mergeDefaultOptions
(
options
,
optionSettings
)
this
.
logger
=
new
Logger
({
name
})
this
.
logger
=
new
Logger
({
name
})
this
.
metrics
=
new
Metrics
({
prefix
:
name
})
}
}
/**
/**
...
...
packages/core-utils/src/common/metrics.ts
0 → 100644
View file @
33b1d676
import
prometheus
,
{
collectDefaultMetrics
,
DefaultMetricsCollectorConfiguration
,
Registry
,
}
from
'
prom-client
'
export
interface
MetricsOptions
{
prefix
:
string
labels
?:
Object
}
export
class
Metrics
{
options
:
MetricsOptions
client
:
typeof
prometheus
registry
:
Registry
constructor
(
options
:
MetricsOptions
)
{
this
.
options
=
options
const
metricsOptions
:
DefaultMetricsCollectorConfiguration
=
{
prefix
:
options
.
prefix
,
labels
:
options
.
labels
,
}
this
.
client
=
prometheus
this
.
registry
=
prometheus
.
register
// Collect default metrics (event loop lag, memory, file descriptors etc.)
collectDefaultMetrics
(
metricsOptions
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment