diff --git a/Makefile b/Makefile
index 347d4866..01a36390 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION=1.3.3
+VERSION=1.3.4
default: build
diff --git a/README.md b/README.md
index fb695a94..f4a4eb3b 100644
--- a/README.md
+++ b/README.md
@@ -86,8 +86,8 @@ scrape_configs:
The docker images are available via:
```bash
-$ docker pull pambrose/prometheus-proxy:1.3.3
-$ docker pull pambrose/prometheus-agent:1.3.3
+$ docker pull pambrose/prometheus-proxy:1.3.4
+$ docker pull pambrose/prometheus-agent:1.3.4
```
Start the proxy and an agent in separate shells on your local machine:
@@ -96,14 +96,14 @@ Start the proxy and an agent in separate shells on your local machine:
$ docker run --rm -p 8082:8082 -p 8092:8092 -p 50051:50051 -p 8080:8080 \
-e HOSTNAME=${HOSTNAME} \
-e METRICS_ENABLED=true \
- pambrose/prometheus-proxy:1.3.3
+ pambrose/prometheus-proxy:1.3.4
```
```bash
$ docker run --rm -p 8083:8083 -p 8093:8093 \
-e HOSTNAME=${HOSTNAME} \
-e AGENT_CONFIG='https://raw.githubusercontent.com/pambrose/prometheus-proxy/master/examples/simple.conf' \
- pambrose/prometheus-agent:1.3.3
+ pambrose/prometheus-agent:1.3.4
```
Using the config file [simple.conf](https://raw.githubusercontent.com/pambrose/prometheus-proxy/master/examples/simple.conf),
diff --git a/bin/docker-agent.sh b/bin/docker-agent.sh
index fac64268..86488240 100755
--- a/bin/docker-agent.sh
+++ b/bin/docker-agent.sh
@@ -3,4 +3,4 @@
docker run --rm -p 8083:8083 -p 8093:8093 \
-e HOSTNAME=${HOSTNAME} \
-e AGENT_CONFIG='https://raw.githubusercontent.com/pambrose/prometheus-proxy/master/examples/simple.conf' \
- pambrose/prometheus-agent:1.3.3
\ No newline at end of file
+ pambrose/prometheus-agent:1.3.4
\ No newline at end of file
diff --git a/bin/docker-proxy.sh b/bin/docker-proxy.sh
index 97c6695c..fbacb5d7 100755
--- a/bin/docker-proxy.sh
+++ b/bin/docker-proxy.sh
@@ -3,4 +3,4 @@
docker run --rm -p 8082:8082 -p 8092:8092 -p 50051:50051 -p 8080:8080 \
-e HOSTNAME=${HOSTNAME} \
-e PROXY_CONFIG='https://raw.githubusercontent.com/pambrose/prometheus-proxy/master/examples/simple.conf' \
- pambrose/prometheus-proxy:1.3.3
\ No newline at end of file
+ pambrose/prometheus-proxy:1.3.4
\ No newline at end of file
diff --git a/docs/release.md b/docs/release.md
index dcfb4ac1..30ed63fa 100644
--- a/docs/release.md
+++ b/docs/release.md
@@ -6,20 +6,22 @@
3) Modify code
-4) Verify tests run cleanly before merge with: `make tests`
+4) Update the release date in *package-info.java*
-5) Check in branch and merge
+5) Verify tests run cleanly before merge with: `make tests`
-6) Go back to master
+6) Check in branch and merge
-7) Verify tests run cleanly after merge with: `make tests`
+7) Go back to master
-8) Build distro with: `make distro`
+8) Verify tests run cleanly after merge with: `make tests`
-9) Create release on github (https://github.com/pambrose/prometheus-proxy/releases) and
+9) Build distro with: `make distro`
+
+10) Create release on github (https://github.com/pambrose/prometheus-proxy/releases) and
upload the *target/distro/prometheus-proxy.jar* and *target/distro/prometheus-agent.jar* files.
-10) Build and push docker images with: `make docker-build docker-push`
+11) Build and push docker images with: `make docker-build docker-push`
-11) Update the *prometheus-proxy* and *prometheus-agent* repository descriptions
-on Docker hub (https://hub.docker.com) with the latest version of *README.md*.
\ No newline at end of file
+12) Update the *prometheus-proxy* and *prometheus-agent* repository descriptions
+on [Docker hub](https://hub.docker.com) with the latest version of *README.md*.
\ No newline at end of file
diff --git a/etc/compose/proxy.yml b/etc/compose/proxy.yml
index f61d4aa5..e944e8d0 100644
--- a/etc/compose/proxy.yml
+++ b/etc/compose/proxy.yml
@@ -1,6 +1,6 @@
prometheus-proxy:
autoredeploy: true
- image: 'pambrose/prometheus-proxy:1.3.3'
+ image: 'pambrose/prometheus-proxy:1.3.4'
ports:
- '8080:8080'
- '8082:8082'
diff --git a/pom.xml b/pom.xml
index 2840c0d3..bb44ad36 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,36 +22,36 @@
io.prometheus
prometheus-proxy
- 1.3.3-SNAPSHOT
+ 1.3.4-SNAPSHOT
- 1.2.21
+ 1.2.30
- 0.2.0
+ 0.3.0
1.72
- 1.3.2
+ 1.3.3
19.0
4.0.2
- 1.9.0
- 1.9.0
+ 1.10.0
+ 1.10.0
0.7.1
- 3.9.1
+ 3.10.0
3.5.1
0.5.1
2.7.1
9.4.6.v20170531
- 4.14.1
- 2.3.1
+ 4.17.0
+ 2.3.3
1.2.3
1.7.25
1.5.3
4.12
- 3.9.0
+ 3.9.1
2.0.0
2.6
@@ -63,7 +63,7 @@
1.8
1.8
- true
+ false
UTF-8
**/grpc/*.java
@@ -272,19 +272,6 @@
-
-
-
- never
-
-
- false
-
- central
- Central Repository
- https://repo.maven.apache.org/maven2
-
-
package
@@ -307,7 +294,6 @@
-
org.apache.maven.plugins
maven-enforcer-plugin
@@ -633,7 +619,7 @@
org.jacoco
jacoco-maven-plugin
- 0.7.9
+ 0.8.0
**/grpc/*.class
diff --git a/src/main/java/io/prometheus/Agent.kt b/src/main/java/io/prometheus/Agent.kt
index 3b42dcad..6e665785 100644
--- a/src/main/java/io/prometheus/Agent.kt
+++ b/src/main/java/io/prometheus/Agent.kt
@@ -56,15 +56,16 @@ import kotlin.properties.Delegates.notNull
class Agent(options: AgentOptions,
private val inProcessServerName: String = "",
testMode: Boolean = false,
- initBlock: (Agent.() -> Unit)? = null) : GenericService(options.configVals,
- newAdminConfig(options.adminEnabled,
- options.adminPort,
- options.configVals.agent.admin),
- newMetricsConfig(options.metricsEnabled,
- options.metricsPort,
- options.configVals.agent.metrics),
- newZipkinConfig(options.configVals.agent.internal.zipkin),
- testMode) {
+ initBlock: (Agent.() -> Unit)? = null) :
+ GenericService(options.configVals,
+ newAdminConfig(options.adminEnabled,
+ options.adminPort,
+ options.configVals.agent.admin),
+ newMetricsConfig(options.metricsEnabled,
+ options.metricsPort,
+ options.configVals.agent.metrics),
+ newZipkinConfig(options.configVals.agent.internal.zipkin),
+ testMode) {
private val pathContextMap = newConcurrentMap() // Map path to PathContext
private val heartbeatService = newFixedThreadPool(1)
private val initialConnectionLatch = CountDownLatch(1)
@@ -450,12 +451,10 @@ class Agent(options: AgentOptions,
val observer =
streamObserver {
- onNext { request ->
- readRequestsExecutorService.submit(readRequestAction(request))
- }
+ onNext { readRequestsExecutorService.submit(readRequestAction(it)) }
- onError { t ->
- val status = Status.fromThrowable(t)
+ onError {
+ val status = Status.fromThrowable(it)
logger.error { "Error in readRequestsFromProxy(): $status" }
disconnected.set(true)
}
@@ -473,12 +472,12 @@ class Agent(options: AgentOptions,
val observer =
asyncStub.writeResponsesToProxy(
streamObserver {
- onNext { _ ->
+ onNext {
// Ignore Empty return value
}
- onError { t ->
- val s = Status.fromThrowable(t)
+ onError {
+ val s = Status.fromThrowable(it)
logger.error { "Error in writeResponsesToProxyUntilDisconnected(): ${s.code} ${s.description}" }
disconnected.set(true)
}
diff --git a/src/main/java/io/prometheus/Proxy.kt b/src/main/java/io/prometheus/Proxy.kt
index ad53a30d..284cdd63 100644
--- a/src/main/java/io/prometheus/Proxy.kt
+++ b/src/main/java/io/prometheus/Proxy.kt
@@ -34,15 +34,16 @@ class Proxy(options: ProxyOptions,
proxyPort: Int = options.agentPort,
inProcessServerName: String = "",
testMode: Boolean = false,
- initBlock: (Proxy.() -> Unit)? = null) : GenericService(options.configVals,
- newAdminConfig(options.adminEnabled,
- options.adminPort,
- options.configVals.proxy.admin),
- newMetricsConfig(options.metricsEnabled,
- options.metricsPort,
- options.configVals.proxy.metrics),
- newZipkinConfig(options.configVals.proxy.internal.zipkin),
- testMode) {
+ initBlock: (Proxy.() -> Unit)? = null) :
+ GenericService(options.configVals,
+ newAdminConfig(options.adminEnabled,
+ options.adminPort,
+ options.configVals.proxy.admin),
+ newMetricsConfig(options.metricsEnabled,
+ options.metricsPort,
+ options.configVals.proxy.metrics),
+ newZipkinConfig(options.configVals.proxy.internal.zipkin),
+ testMode) {
val pathManager = PathManager(isTestMode)
val scrapeRequestManager = ScrapeRequestManager()
val agentContextManager = AgentContextManager()
diff --git a/src/main/java/io/prometheus/agent/AgentOptions.kt b/src/main/java/io/prometheus/agent/AgentOptions.kt
index 28b45f19..6c4d83b4 100644
--- a/src/main/java/io/prometheus/agent/AgentOptions.kt
+++ b/src/main/java/io/prometheus/agent/AgentOptions.kt
@@ -24,14 +24,10 @@ import io.prometheus.common.EnvVars
import io.prometheus.common.EnvVars.AGENT_CONFIG
import io.prometheus.common.EnvVars.PROXY_HOSTNAME
-class AgentOptions(argv: Array, exitOnMissingConfig: Boolean) : BaseOptions(Agent::class.java.name,
- argv,
- AGENT_CONFIG.name,
- exitOnMissingConfig) {
-
- constructor(args: List, exitOnMissingConfig: Boolean) : this(Iterables.toArray(args,
- String::class.java),
- exitOnMissingConfig)
+class AgentOptions(argv: Array, exitOnMissingConfig: Boolean) :
+ BaseOptions(Agent::class.java.name, argv, AGENT_CONFIG.name, exitOnMissingConfig) {
+ constructor(args: List, exitOnMissingConfig: Boolean) :
+ this(Iterables.toArray(args, String::class.java), exitOnMissingConfig)
@Parameter(names = ["-p", "--proxy"], description = "Proxy hostname")
var proxyHostname: String = ""
diff --git a/src/main/java/io/prometheus/common/GenericService.kt b/src/main/java/io/prometheus/common/GenericService.kt
index 95954fe6..e529062a 100644
--- a/src/main/java/io/prometheus/common/GenericService.kt
+++ b/src/main/java/io/prometheus/common/GenericService.kt
@@ -38,7 +38,9 @@ abstract class GenericService protected constructor(protected val genericConfigV
private val adminConfig: AdminConfig,
private val metricsConfig: MetricsConfig,
private val zipkinConfig: ZipkinConfig,
- val isTestMode: Boolean) : GenericExecutionThreadService(), Closeable {
+ val isTestMode: Boolean) :
+ GenericExecutionThreadService(),
+ Closeable {
protected val healthCheckRegistry = HealthCheckRegistry()
private val services = mutableListOf()
@@ -106,7 +108,7 @@ abstract class GenericService protected constructor(protected val genericConfigV
serviceManagerListener {
healthy { logger.info { "All $clazzName services healthy" } }
stopped { logger.info { "All $clazzName services stopped" } }
- failure { service -> logger.info { "$clazzName service failed: $service" } }
+ failure { logger.info { "$clazzName service failed: $it" } }
})
}
registerHealthChecks()
diff --git a/src/main/java/io/prometheus/common/MetricsService.kt b/src/main/java/io/prometheus/common/MetricsService.kt
index afcb30b8..c8765323 100644
--- a/src/main/java/io/prometheus/common/MetricsService.kt
+++ b/src/main/java/io/prometheus/common/MetricsService.kt
@@ -30,7 +30,8 @@ import org.eclipse.jetty.servlet.ServletHolder
class MetricsService(private val port: Int,
private val path: String,
- initBlock: (MetricsService.() -> Unit)? = null) : GenericIdleService() {
+ initBlock: (MetricsService.() -> Unit)? = null) :
+ GenericIdleService() {
private val server =
server(port) {
handler =
diff --git a/src/main/java/io/prometheus/common/SamplerGaugeCollector.kt b/src/main/java/io/prometheus/common/SamplerGaugeCollector.kt
index 72df6fc4..ceb037d2 100644
--- a/src/main/java/io/prometheus/common/SamplerGaugeCollector.kt
+++ b/src/main/java/io/prometheus/common/SamplerGaugeCollector.kt
@@ -22,7 +22,8 @@ class SamplerGaugeCollector(private val name: String,
private val help: String,
private val labelNames: List = emptyList(),
private val labelValues: List = emptyList(),
- private val data: () -> Double) : Collector() {
+ private val data: () -> Double) :
+ Collector() {
init {
register()
}
diff --git a/src/main/java/io/prometheus/common/ZipkinReporterService.kt b/src/main/java/io/prometheus/common/ZipkinReporterService.kt
index fe047d47..62cfac6c 100644
--- a/src/main/java/io/prometheus/common/ZipkinReporterService.kt
+++ b/src/main/java/io/prometheus/common/ZipkinReporterService.kt
@@ -25,7 +25,8 @@ import mu.KLogging
import zipkin2.reporter.AsyncReporter
import zipkin2.reporter.okhttp3.OkHttpSender
-class ZipkinReporterService(private val url: String, val initBlock: (ZipkinReporterService.() -> Unit)? = null) : GenericIdleService() {
+class ZipkinReporterService(private val url: String, val initBlock: (ZipkinReporterService.() -> Unit)? = null) :
+ GenericIdleService() {
private val sender = OkHttpSender.create(url)
private val reporter = AsyncReporter.create(sender)
diff --git a/src/main/java/io/prometheus/delegate/AtomicDelegates.kt b/src/main/java/io/prometheus/delegate/AtomicDelegates.kt
index 8e18c32f..bc639d46 100644
--- a/src/main/java/io/prometheus/delegate/AtomicDelegates.kt
+++ b/src/main/java/io/prometheus/delegate/AtomicDelegates.kt
@@ -21,15 +21,20 @@ import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
object AtomicDelegates {
- fun notNullReference(initValue: T? = null): ReadWriteProperty = NotNullAtomicReferenceDelegate(initValue)
- fun nullableReference(initValue: T? = null): ReadWriteProperty = NullableAtomicReferenceDelegate(initValue)
-}
+ fun notNullReference(initValue: T? = null): ReadWriteProperty =
+ NotNullAtomicReferenceDelegate(initValue)
+ fun nullableReference(initValue: T? = null): ReadWriteProperty =
+ NullableAtomicReferenceDelegate(initValue)
+}
private class NotNullAtomicReferenceDelegate(initValue: T? = null) : ReadWriteProperty {
private val atomicVal = AtomicReference(initValue)
- override operator fun getValue(thisRef: Any?, property: KProperty<*>) = atomicVal.get() ?: throw IllegalStateException("Property ${property.name} should be initialized before get.")
+ override operator fun getValue(thisRef: Any?, property: KProperty<*>) =
+ atomicVal.get()
+ ?: throw IllegalStateException("Property ${property.name} should be initialized before get.")
+
override operator fun setValue(thisRef: Any?, property: KProperty<*>, value: T) = atomicVal.set(value)
}
diff --git a/src/main/java/io/prometheus/package-info.java b/src/main/java/io/prometheus/package-info.java
index cfc9ef86..d6705ef5 100644
--- a/src/main/java/io/prometheus/package-info.java
+++ b/src/main/java/io/prometheus/package-info.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-@VersionAnnotation(version = "1.3.3", date = "1/??/18")
+@VersionAnnotation(version = "1.3.4", date = "3/2/18")
package io.prometheus;
import io.prometheus.common.VersionAnnotation;
\ No newline at end of file
diff --git a/src/main/java/io/prometheus/proxy/AgentContextCleanupService.kt b/src/main/java/io/prometheus/proxy/AgentContextCleanupService.kt
index f818f51e..52af48b8 100644
--- a/src/main/java/io/prometheus/proxy/AgentContextCleanupService.kt
+++ b/src/main/java/io/prometheus/proxy/AgentContextCleanupService.kt
@@ -24,8 +24,8 @@ import io.prometheus.guava.GenericExecutionThreadService
import io.prometheus.guava.genericServiceListener
import mu.KLogging
-class AgentContextCleanupService(private val proxy: Proxy, initBlock: (AgentContextCleanupService.() -> Unit)? = null) : GenericExecutionThreadService() {
-
+class AgentContextCleanupService(private val proxy: Proxy, initBlock: (AgentContextCleanupService.() -> Unit)? = null) :
+ GenericExecutionThreadService() {
init {
addListener(genericServiceListener(this, logger), MoreExecutors.directExecutor())
initBlock?.invoke(this)
diff --git a/src/main/java/io/prometheus/proxy/ProxyGrpcService.kt b/src/main/java/io/prometheus/proxy/ProxyGrpcService.kt
index a4d795d1..034a689e 100644
--- a/src/main/java/io/prometheus/proxy/ProxyGrpcService.kt
+++ b/src/main/java/io/prometheus/proxy/ProxyGrpcService.kt
@@ -36,7 +36,8 @@ import kotlin.properties.Delegates
class ProxyGrpcService private constructor(private val proxy: Proxy,
private val port: Int = -1,
- private val inProcessServerName: String = "") : GenericIdleService() {
+ private val inProcessServerName: String = "") :
+ GenericIdleService() {
val healthCheck =
healthCheck {
if (grpcServer.isShutdown || grpcServer.isShutdown)
@@ -93,7 +94,10 @@ class ProxyGrpcService private constructor(private val proxy: Proxy,
}
companion object : KLogging() {
- fun newProxyGrpcService(proxy: Proxy, port: Int) = ProxyGrpcService(proxy = proxy, port = port)
- fun newProxyGrpcService(proxy: Proxy, serverName: String) = ProxyGrpcService(proxy = proxy, inProcessServerName = serverName)
+ fun newProxyGrpcService(proxy: Proxy, port: Int) =
+ ProxyGrpcService(proxy = proxy, port = port)
+
+ fun newProxyGrpcService(proxy: Proxy, serverName: String) =
+ ProxyGrpcService(proxy = proxy, inProcessServerName = serverName)
}
}
diff --git a/src/main/java/io/prometheus/proxy/ProxyHttpService.kt b/src/main/java/io/prometheus/proxy/ProxyHttpService.kt
index af3d3751..d8d0eac6 100644
--- a/src/main/java/io/prometheus/proxy/ProxyHttpService.kt
+++ b/src/main/java/io/prometheus/proxy/ProxyHttpService.kt
@@ -146,7 +146,8 @@ class ProxyHttpService(private val proxy: Proxy, val port: Int) : GenericIdleSer
}
}
} finally {
- proxy.scrapeRequestManager.removeFromScrapeRequestMap(scrapeRequest.scrapeId) ?: logger.error { "Scrape request ${scrapeRequest.scrapeId} missing in map" }
+ proxy.scrapeRequestManager.removeFromScrapeRequestMap(scrapeRequest.scrapeId)
+ ?: logger.error { "Scrape request ${scrapeRequest.scrapeId} missing in map" }
}
logger.debug { "Results returned from $agentContext for $scrapeRequest" }
diff --git a/src/main/java/io/prometheus/proxy/ProxyServiceImpl.kt b/src/main/java/io/prometheus/proxy/ProxyServiceImpl.kt
index 6a269816..12b0de3e 100644
--- a/src/main/java/io/prometheus/proxy/ProxyServiceImpl.kt
+++ b/src/main/java/io/prometheus/proxy/ProxyServiceImpl.kt
@@ -167,17 +167,17 @@ internal class ProxyServiceImpl(private val proxy: Proxy) : ProxyServiceGrpc.Pro
override fun writeResponsesToProxy(responseObserver: StreamObserver): StreamObserver =
streamObserver {
- onNext { response ->
- proxy.scrapeRequestManager.getFromScrapeRequestMap(response.scrapeId)
+ onNext {
+ proxy.scrapeRequestManager.getFromScrapeRequestMap(it.scrapeId)
?.apply {
- scrapeResponse = response
+ scrapeResponse = it
markComplete()
agentContext.markActivity()
- } ?: logger.error { "Missing ScrapeRequestWrapper for scrape_id: ${response.scrapeId}" }
+ } ?: logger.error { "Missing ScrapeRequestWrapper for scrape_id: ${it.scrapeId}" }
}
- onError { t ->
- Status.fromThrowable(t)
+ onError {
+ Status.fromThrowable(it)
.let {
if (it !== Status.CANCELLED)
logger.info { "Error in writeResponsesToProxy(): $it" }
diff --git a/src/main/java/io/prometheus/proxy/ProxyTransportFilter.kt b/src/main/java/io/prometheus/proxy/ProxyTransportFilter.kt
index b010db32..2a8bfbc6 100644
--- a/src/main/java/io/prometheus/proxy/ProxyTransportFilter.kt
+++ b/src/main/java/io/prometheus/proxy/ProxyTransportFilter.kt
@@ -25,7 +25,8 @@ import mu.KLogging
class ProxyTransportFilter(private val proxy: Proxy) : ServerTransportFilter() {
private fun getRemoteAddr(attributes: Attributes) =
- attributes.keys().first { "remote-addr" == it.toString() }
+ attributes.keys()
+ .first { "remote-addr" == it.toString() }
?.let {
attributes.get(it)?.toString() ?: "Unknown"
} ?: "Unknown"
@@ -47,8 +48,8 @@ class ProxyTransportFilter(private val proxy: Proxy) : ServerTransportFilter() {
logger.info {
"Disconnected " +
if (agentContext != null)
- "from $agentContext"
- else
+ "from $agentContext"
+ else
"with invalid agentId: $agentId"
}
super.transportTerminated(attributes)
diff --git a/src/test/java/io/prometheus/CommonTests.kt b/src/test/java/io/prometheus/CommonTests.kt
index b663cf0a..1c1e0b73 100644
--- a/src/test/java/io/prometheus/CommonTests.kt
+++ b/src/test/java/io/prometheus/CommonTests.kt
@@ -136,7 +136,7 @@ object CommonTests : KLogging() {
val httpServer =
httpServer {
- initExceptionHandler { e -> sparkExceptionHandler(e, agentPort) }
+ initExceptionHandler { sparkExceptionHandler(it, agentPort) }
port(agentPort)
get("/$agentPath") { _, res ->
res.type("text/plain")
@@ -172,16 +172,16 @@ object CommonTests : KLogging() {
// Create the endpoints
IntStream.range(0, httpServerCount)
- .forEach { i ->
- val port = startingPort + i
+ .forEach {
+ val port = startingPort + it
httpServers +=
httpServer {
- initExceptionHandler { e -> sparkExceptionHandler(e, port) }
+ initExceptionHandler { sparkExceptionHandler(it, port) }
port(port)
threadPool(30, 10, 1000)
- get("/agent-$i") { _, res ->
+ get("/agent-$it") { _, res ->
res.type("text/plain")
- "value: $i"
+ "value: $it"
}
awaitInitialization()
}