Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f46aa7c1
Commit
f46aa7c1
authored
Sep 28, 2020
by
Matthias Käppler
Committed by
Alessio Caiazza
Sep 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add image scaler duration Prometheus metric
parent
5a2a990f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
9 deletions
+47
-9
changelogs/unreleased/mk-more-image-scaler-prometheus-metrics.yml
...gs/unreleased/mk-more-image-scaler-prometheus-metrics.yml
+5
-0
internal/imageresizer/image_resizer.go
internal/imageresizer/image_resizer.go
+42
-9
No files found.
changelogs/unreleased/mk-more-image-scaler-prometheus-metrics.yml
0 → 100644
View file @
f46aa7c1
---
title
:
Add image scaler duration histogram
merge_request
:
614
author
:
type
:
other
internal/imageresizer/image_resizer.go
View file @
f46aa7c1
...
...
@@ -65,24 +65,52 @@ var httpClient = &http.Client{
Transport
:
httpTransport
,
}
const
(
namespace
=
"gitlab_workhorse"
subsystem
=
"image_resize"
)
var
(
imageResizeConcurrencyLimitExceeds
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"gitlab_workhorse_image_resize_concurrency_limit_exceeds_total"
,
Help
:
"Amount of image resizing requests that exceeded the maximum allowed scaler processes"
,
Namespace
:
namespace
,
Subsystem
:
subsystem
,
Name
:
"concurrency_limit_exceeds_total"
,
Help
:
"Amount of image resizing requests that exceeded the maximum allowed scaler processes"
,
},
)
imageResizeProcesses
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Name
:
"gitlab_workhorse_image_resize_processes"
,
Help
:
"Amount of image resizing scaler processes working now"
,
Namespace
:
namespace
,
Subsystem
:
subsystem
,
Name
:
"processes"
,
Help
:
"Amount of image resizing scaler processes working now"
,
},
)
imageResizeCompleted
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"gitlab_workhorse_image_resize_completed_total"
,
Help
:
"Amount of image resizing processes successfully completed"
,
Namespace
:
namespace
,
Subsystem
:
subsystem
,
Name
:
"completed_total"
,
Help
:
"Amount of image resizing processes sucessfully completed"
,
},
)
imageResizeDurations
=
prometheus
.
NewHistogramVec
(
prometheus
.
HistogramOpts
{
Namespace
:
namespace
,
Subsystem
:
subsystem
,
Name
:
"duration_seconds"
,
Help
:
"Total seconds spent serving image resizing requests"
,
Buckets
:
[]
float64
{
0.050
,
/* 50ms */
0.1
,
/* 100ms */
0.2
,
/* 200ms */
0.4
,
/* 400ms */
0.8
,
/* 800ms */
1.6
,
/* 1600ms */
},
},
[]
string
{
"content_type"
,
"width"
},
)
)
...
...
@@ -90,6 +118,7 @@ func init() {
prometheus
.
MustRegister
(
imageResizeConcurrencyLimitExceeds
)
prometheus
.
MustRegister
(
imageResizeProcesses
)
prometheus
.
MustRegister
(
imageResizeCompleted
)
prometheus
.
MustRegister
(
imageResizeDurations
)
}
// This Injecter forks into a dedicated scaler process to resize an image identified by path or URL
...
...
@@ -135,11 +164,17 @@ func (r *resizer) Inject(w http.ResponseWriter, req *http.Request, paramsData st
w
.
Header
()
.
Del
(
"Content-Length"
)
bytesWritten
,
err
:=
serveImage
(
imageReader
,
w
,
resizeCmd
)
if
err
!=
nil
{
handleFailedCommand
(
w
,
req
,
bytesWritten
,
err
,
logFields
(
bytesWritten
))
return
}
if
resizeCmd
!=
nil
{
widthLabelVal
:=
strconv
.
Itoa
(
int
(
params
.
Width
))
imageResizeDurations
.
WithLabelValues
(
params
.
ContentType
,
widthLabelVal
)
.
Observe
(
time
.
Since
(
start
)
.
Seconds
())
}
logger
.
WithFields
(
*
logFields
(
bytesWritten
))
.
Printf
(
"ImageResizer: Success"
)
}
...
...
@@ -153,9 +188,7 @@ func serveImage(r io.Reader, w io.Writer, resizeCmd *exec.Cmd) (int64, error) {
}
if
resizeCmd
!=
nil
{
if
err
=
resizeCmd
.
Wait
();
err
!=
nil
{
return
bytesWritten
,
err
}
return
bytesWritten
,
resizeCmd
.
Wait
()
}
return
bytesWritten
,
nil
...
...
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