Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
DEMO
spring-boot
Commits
0e4b66a3
Commit
0e4b66a3
authored
Mar 31, 2021
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.3.x' into 2.4.x
Closes gh-25844
parents
586ce00e
1a84b061
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
27 deletions
+4
-27
PrometheusPushGatewayManager.java
...trics/export/prometheus/PrometheusPushGatewayManager.java
+3
-13
PrometheusPushGatewayManagerTests.java
.../export/prometheus/PrometheusPushGatewayManagerTests.java
+1
-14
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManager.java
View file @
0e4b66a3
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
21
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -16,7 +16,6 @@
package
org
.
springframework
.
boot
.
actuate
.
metrics
.
export
.
prometheus
;
import
java.net.UnknownHostException
;
import
java.time.Duration
;
import
java.util.Map
;
import
java.util.concurrent.Executors
;
...
...
@@ -31,7 +30,6 @@ import org.apache.commons.logging.LogFactory;
import
org.springframework.scheduling.TaskScheduler
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
;
import
org.springframework.util.Assert
;
import
org.springframework.util.StringUtils
;
/**
* Class that can be used to manage the pushing of metrics to a {@link PushGateway
...
...
@@ -107,16 +105,8 @@ public class PrometheusPushGatewayManager {
try
{
this
.
pushGateway
.
pushAdd
(
this
.
registry
,
this
.
job
,
this
.
groupingKey
);
}
catch
(
UnknownHostException
ex
)
{
String
host
=
ex
.
getMessage
();
String
message
=
"Unable to locate prometheus push gateway host"
+
(
StringUtils
.
hasLength
(
host
)
?
" '"
+
host
+
"'"
:
""
)
+
". No longer attempting metrics publication to this host"
;
logger
.
error
(
message
,
ex
);
shutdown
(
ShutdownOperation
.
NONE
);
}
catch
(
Throwable
ex
)
{
logger
.
error
(
"Unable to push
metrics to Prometheus Pushgateway"
,
ex
);
logger
.
warn
(
"Unexpected exception thrown while pushing
metrics to Prometheus Pushgateway"
,
ex
);
}
}
...
...
@@ -125,7 +115,7 @@ public class PrometheusPushGatewayManager {
this
.
pushGateway
.
delete
(
this
.
job
,
this
.
groupingKey
);
}
catch
(
Throwable
ex
)
{
logger
.
error
(
"Unable to delete metrics from Prometheu
s Pushgateway"
,
ex
);
logger
.
warn
(
"Unexpected exception thrown while deleting metrics from Promethue
s Pushgateway"
,
ex
);
}
}
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManagerTests.java
View file @
0e4b66a3
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -16,7 +16,6 @@
package
org
.
springframework
.
boot
.
actuate
.
metrics
.
export
.
prometheus
;
import
java.net.UnknownHostException
;
import
java.time.Duration
;
import
java.util.Collections
;
import
java.util.Map
;
...
...
@@ -166,18 +165,6 @@ class PrometheusPushGatewayManagerTests {
verifyNoInteractions
(
this
.
pushGateway
);
}
@Test
void
pushWhenUnknownHostExceptionIsThrownDoesShutdown
()
throws
Exception
{
givenScheduleAtFixedRateWithReturnFuture
();
new
PrometheusPushGatewayManager
(
this
.
pushGateway
,
this
.
registry
,
this
.
scheduler
,
this
.
pushRate
,
"job"
,
this
.
groupingKey
,
null
);
verify
(
this
.
scheduler
).
scheduleAtFixedRate
(
this
.
task
.
capture
(),
eq
(
this
.
pushRate
));
willThrow
(
new
UnknownHostException
(
"foo"
)).
given
(
this
.
pushGateway
).
pushAdd
(
this
.
registry
,
"job"
,
this
.
groupingKey
);
this
.
task
.
getValue
().
run
();
verify
(
this
.
future
).
cancel
(
false
);
}
@Test
void
pushDoesNotThrowException
()
throws
Exception
{
new
PrometheusPushGatewayManager
(
this
.
pushGateway
,
this
.
registry
,
this
.
scheduler
,
this
.
pushRate
,
"job"
,
...
...
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