Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
metrics
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libs
metrics
Merge requests
!1
Master to main
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
Master to main
master
into
main
Overview
0
Commits
41
Pipelines
2
Changes
8
Merged
Sigmund, Dominik
requested to merge
master
into
main
1 year ago
Overview
0
Commits
41
Pipelines
2
Changes
8
0
0
Merge request reports
Viewing commit
c158e070
Prev
Next
Show latest version
8 files
+
145
−
22
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
8
c158e070
Almost Done
· c158e070
Sigmund, Dominik
authored
5 years ago
examples/src/app.ts
0 → 100755
+
60
−
0
View file @ 797ae40b
Edit in single-file editor
Open in Web IDE
'
use strict
'
import
*
as
http
from
'
http
'
import
*
as
express
from
'
express
'
import
{
Metrics
,
MetricType
}
from
'
../../dist/index
'
class
App
{
public
app
:
express
.
Application
private
readonly
router
:
express
.
Router
public
readonly
server
:
http
.
Server
private
readonly
metrics
:
Metrics
constructor
(
port
:
number
)
{
this
.
app
=
express
()
this
.
router
=
express
.
Router
()
this
.
metrics
=
new
Metrics
({
ignore
:
[
'
/bar
'
],
disableErrorCounter
:
false
,
disableRouteCounter
:
false
,
disableDurationCounter
:
false
,
disableDefaultMetrics
:
false
,
disableClientCounter
:
false
})
this
.
metrics
.
addCustomMetric
({
name
:
'
sometest
'
,
help
:
'
Some Test Metric
'
},
MetricType
.
COUNTER
)
this
.
router
.
use
(
this
.
metrics
.
collect
)
this
.
router
.
get
(
'
/favicon.ico
'
,
(
req
,
res
)
=>
res
.
status
(
204
))
// No Favicon here
this
.
router
.
get
(
'
/foo
'
,
(
req
:
express
.
Request
,
res
:
express
.
Response
)
=>
{
res
.
status
(
200
).
send
(
'
foo
'
)
})
this
.
router
.
get
(
'
/bar
'
,
(
req
:
express
.
Request
,
res
:
express
.
Response
)
=>
{
this
.
metrics
.
customMetrics
[
"
sometest
"
].
inc
()
res
.
status
(
200
).
send
(
'
bar
'
)
})
this
.
router
.
get
(
'
/404
'
,
(
req
:
express
.
Request
,
res
:
express
.
Response
)
=>
{
res
.
status
(
404
).
end
()
})
this
.
router
.
get
(
'
/401
'
,
(
req
:
express
.
Request
,
res
:
express
.
Response
)
=>
{
res
.
status
(
401
).
end
()
})
this
.
router
.
get
(
'
/_metrics
'
,
this
.
metrics
.
endpoint
)
this
.
app
.
use
(
this
.
router
)
this
.
server
=
http
.
createServer
(
this
.
app
)
this
.
server
.
listen
(
port
)
console
.
log
(
`metrics-example is running on Port
${
port
as
number
}
`
)
}
}
export
default
App
Loading