Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
imghost-backend
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Janne Mareike Koschinski
imghost-backend
Commits
78aa2cbc
Verified
Commit
78aa2cbc
authored
3 years ago
by
Janne Mareike Koschinski
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup metric handling
Signed-off-by:
Janne Mareike Koschinski
<
janne@kuschku.de
>
parent
3aa4d594
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#2567
passed
3 years ago
Stage: build
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
main.go
+5
-1
5 additions, 1 deletion
main.go
process.go
+4
-4
4 additions, 4 deletions
process.go
redis.go
+1
-1
1 addition, 1 deletion
redis.go
with
10 additions
and
6 deletions
main.go
+
5
−
1
View file @
78aa2cbc
...
...
@@ -16,6 +16,8 @@ var queueGauge = promauto.NewGaugeVec(
},
[]
string
{
"state"
},
)
var
queueGaugeQueued
=
queueGauge
.
WithLabelValues
(
"queued"
)
var
queueGaugeInProgress
=
queueGauge
.
WithLabelValues
(
"inProgress"
)
var
imageCounter
=
promauto
.
NewCounterVec
(
prometheus
.
CounterOpts
{
...
...
@@ -24,6 +26,8 @@ var imageCounter = promauto.NewCounterVec(
},
[]
string
{
"result"
},
)
var
imageCounterSuccess
=
imageCounter
.
WithLabelValues
(
"success"
)
var
imageCounterFailure
=
imageCounter
.
WithLabelValues
(
"failure"
)
var
imageProcessDuration
=
promauto
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"imghost_process_duration"
,
...
...
@@ -47,7 +51,7 @@ func main() {
})
go
serveQueue
(
client
,
config
.
ImageQueue
,
func
(
value
string
)
{
queueGauge
.
WithLabelValues
(
"q
ueued
"
)
.
Dec
()
queueGauge
Q
ueued
.
Dec
()
ProcessImage
(
&
config
,
client
,
value
)
})
if
err
:=
http
.
ListenAndServe
(
":2112"
,
nil
);
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
process.go
+
4
−
4
View file @
78aa2cbc
...
...
@@ -14,8 +14,8 @@ func trackTime(start time.Time, function func(time.Duration)) {
}
func
ProcessImage
(
config
*
Config
,
client
*
redis
.
Client
,
value
string
)
{
queueGauge
.
WithLabelValues
(
"in_p
rogress
"
)
.
Inc
()
defer
queueGauge
.
WithLabelValues
(
"in_p
rogress
"
)
.
Dec
()
queueGauge
InP
rogress
.
Inc
()
defer
queueGauge
InP
rogress
.
Dec
()
defer
trackTime
(
time
.
Now
(),
func
(
duration
time
.
Duration
)
{
imageProcessDuration
.
Add
(
float64
(
duration
.
Milliseconds
()))
})
...
...
@@ -35,14 +35,14 @@ func ProcessImage(config *Config, client *redis.Client, value string) {
}
if
len
(
errors
)
!=
0
{
imageCounter
.
WithLabelValues
(
"error"
)
.
Inc
()
imageCounter
Failure
.
Inc
()
returnResult
(
config
,
client
,
Result
{
Id
:
image
.
Id
,
Success
:
false
,
Errors
:
errorMessages
,
})
}
else
{
imageCounter
.
WithLabelValues
(
"s
uccess
"
)
.
Inc
()
imageCounter
S
uccess
.
Inc
()
returnResult
(
config
,
client
,
Result
{
Id
:
image
.
Id
,
Success
:
true
,
...
...
This diff is collapsed.
Click to expand it.
redis.go
+
1
−
1
View file @
78aa2cbc
...
...
@@ -11,7 +11,7 @@ func serveQueue(client *redis.Client, queue string, function func(value string))
element
:=
client
.
BLPop
(
0
,
fmt
.
Sprintf
(
"queue:%s"
,
queue
))
if
len
(
element
.
Val
())
==
2
{
value
:=
element
.
Val
()[
1
]
queueGauge
.
Inc
()
queueGauge
Queued
.
Inc
()
go
function
(
value
)
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment