Skip to content

Commit

Permalink
1.8.4
Browse files Browse the repository at this point in the history
* Fix memory leak in http requests
  • Loading branch information
pambrose authored Sep 3, 2020
1 parent ea2cee8 commit 4e6be6a
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 36 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=1.8.3
VERSION=1.8.4

default: compile

Expand All @@ -24,13 +24,13 @@ config:

distro: clean compile jars

docker-build:
build-docker:
docker build -f ./etc/docker/proxy.df -t pambrose/prometheus-proxy:${VERSION} .
docker build -f ./etc/docker/proxy.df -t pambrose/prometheus-proxy:latest .
docker build -f ./etc/docker/agent.df -t pambrose/prometheus-agent:${VERSION} .
docker build -f ./etc/docker/agent.df -t pambrose/prometheus-agent:latest .

docker-push:
push-docker:
docker push pambrose/prometheus-proxy:${VERSION}
docker push pambrose/prometheus-proxy:latest
docker push pambrose/prometheus-agent:${VERSION}
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ scrape_configs:
The docker images are available via:
```bash
docker pull pambrose/prometheus-proxy:1.8.3
docker pull pambrose/prometheus-agent:1.8.3
docker pull pambrose/prometheus-proxy:1.8.4
docker pull pambrose/prometheus-agent:1.8.4
```

Start a proxy container with:
Expand All @@ -107,15 +107,15 @@ Start a proxy container with:
docker run --rm -p 8082:8082 -p 8092:8092 -p 50051:50051 -p 8080:8080 \
--env ADMIN_ENABLED=true \
--env METRICS_ENABLED=true \
pambrose/prometheus-proxy:1.8.3
pambrose/prometheus-proxy:1.8.4
```

Start an agent container with:

```bash
docker run --rm -p 8083:8083 -p 8093:8093 \
--env AGENT_CONFIG='https://raw.githubusercontent.com/pambrose/prometheus-proxy/master/examples/simple.conf' \
pambrose/prometheus-agent:1.8.3
pambrose/prometheus-agent:1.8.4
```

Using the config file [simple.conf](https://raw.githubusercontent.com/pambrose/prometheus-proxy/master/examples/simple.conf),
Expand All @@ -131,7 +131,7 @@ is in your current directory, run an agent container with:
docker run --rm -p 8083:8083 -p 8093:8093 \
--mount type=bind,source="$(pwd)"/prom-agent.conf,target=/app/prom-agent.conf \
--env AGENT_CONFIG=prom-agent.conf \
pambrose/prometheus-agent:1.8.3
pambrose/prometheus-agent:1.8.4
```

**Note:** The `WORKDIR` of the proxy and agent images is `/app`, so make sure
Expand Down Expand Up @@ -252,15 +252,15 @@ docker run --rm -p 8082:8082 -p 8092:8092 -p 50440:50440 -p 8080:8080 \
--env PROXY_CONFIG=tls-no-mutual-auth.conf \
--env ADMIN_ENABLED=true \
--env METRICS_ENABLED=true \
pambrose/prometheus-proxy:1.8.3
pambrose/prometheus-proxy:1.8.4

docker run --rm -p 8083:8083 -p 8093:8093 \
--mount type=bind,source="$(pwd)"/testing/certs,target=/app/testing/certs \
--mount type=bind,source="$(pwd)"/examples/tls-no-mutual-auth.conf,target=/app/tls-no-mutual-auth.conf \
--env AGENT_CONFIG=tls-no-mutual-auth.conf \
--env PROXY_HOSTNAME=mymachine.lan:50440 \
--name docker-agent \
pambrose/prometheus-agent:1.8.3
pambrose/prometheus-agent:1.8.4
```

**Note:** The `WORKDIR` of the proxy and agent images is `/app`, so make sure
Expand Down
2 changes: 1 addition & 1 deletion bin/docker-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
docker run --rm -p 8083:8083 -p 8093:8093 \
--env AGENT_CONFIG='https://raw.githubusercontent.com/pambrose/prometheus-proxy/master/examples/simple.conf' \
--env PROXY_HOSTNAME=mymachine.lan \
pambrose/prometheus-agent:1.8.3
pambrose/prometheus-agent:1.8.4
2 changes: 1 addition & 1 deletion bin/docker-proxy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

docker run --rm -p 8082:8082 -p 8092:8092 -p 50051:50051 -p 8080:8080 \
--env PROXY_CONFIG='https://raw.githubusercontent.com/pambrose/prometheus-proxy/master/examples/simple.conf' \
pambrose/prometheus-proxy:1.8.3
pambrose/prometheus-proxy:1.8.4
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
}

group = 'io.prometheus'
version = '1.8.3'
version = '1.8.4'

sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand Down
2 changes: 1 addition & 1 deletion docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
10) Create release on github (https://github.com/pambrose/prometheus-proxy/releases) and
upload the *build/libs/prometheus-proxy.jar* and *build/libs/prometheus-agent.jar* files.

11) Build and push docker images with: `make docker-build docker-push`
11) Build and push docker images with: `make build-docker push-docker`

12) Update the *prometheus-proxy* and *prometheus-agent* repository descriptions
on [Docker hub](https://hub.docker.com) with the latest version of *README.md*.
2 changes: 1 addition & 1 deletion etc/compose/proxy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
prometheus-proxy:
autoredeploy: true
image: 'pambrose/prometheus-proxy:1.8.3'
image: 'pambrose/prometheus-proxy:1.8.4'
ports:
- '8080:8080'
- '8082:8082'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ prometheus_version=0.9.0
protoc_version=3.12.4
slf4j_version=1.7.30
typesafe_version=1.4.0
utils_version=35fcd6c
utils_version=8a9b883
zipkin_version=5.12.5
2 changes: 1 addition & 1 deletion src/main/kotlin/io/prometheus/Agent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import kotlin.time.TimeSource.Monotonic
import kotlin.time.milliseconds
import kotlin.time.seconds

@Version(version = "1.8.3", date = "9/1/20")
@Version(version = "1.8.4", date = "9/3/20")
class Agent(val options: AgentOptions,
inProcessServerName: String = "",
testMode: Boolean = false,
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/prometheus/Proxy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import kotlin.time.milliseconds

@Version(version = "1.8.3", date = "9/1/20")
@Version(version = "1.8.4", date = "9/3/20")
class Proxy(val options: ProxyOptions,
proxyHttpPort: Int = options.proxyHttpPort,
inProcessServerName: String = "",
Expand Down
34 changes: 17 additions & 17 deletions src/main/kotlin/io/prometheus/agent/AgentHttpService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
package io.prometheus.agent

import com.github.pambrose.common.dsl.KtorDsl.get
import com.github.pambrose.common.dsl.KtorDsl.newHttpClient
import com.github.pambrose.common.dsl.KtorDsl.withHttpClient
import com.github.pambrose.common.util.isNull
import com.github.pambrose.common.util.simpleClassName
import com.github.pambrose.common.util.zip
import com.google.common.net.HttpHeaders
import io.ktor.client.*
import io.ktor.client.engine.cio.*
import io.ktor.client.features.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
Expand Down Expand Up @@ -71,22 +71,22 @@ internal class AgentHttpService(val agent: Agent) {

// Content is fetched here
try {
newHttpClient {
requestTimeout = 90.seconds.toLongMilliseconds()
}.use { client ->
withHttpClient(client) {
get(url,
{
val accept: String? = request.accept
if (accept?.isNotEmpty() == true)
header(HttpHeaders.ACCEPT, accept)
val scrapeTimeout = agent.options.scrapeTimeoutSecs.seconds
logger.debug { "Setting scrapeTimeoutSecs = $scrapeTimeout" }
timeout { requestTimeoutMillis = scrapeTimeout.toLongMilliseconds() }
},
getBlock(url, scrapeResults, scrapeMsg, request.debugEnabled))
CIO.create { requestTimeout = 90.seconds.toLongMilliseconds() }
.use { engine ->
HttpClient(engine) { install(HttpTimeout) }
.use { client ->
client.get(url,
{
val accept: String? = request.accept
if (accept?.isNotEmpty() == true)
header(HttpHeaders.ACCEPT, accept)
val scrapeTimeout = agent.options.scrapeTimeoutSecs.seconds
logger.debug { "Setting scrapeTimeoutSecs = $scrapeTimeout" }
timeout { requestTimeoutMillis = scrapeTimeout.toLongMilliseconds() }
},
getBlock(url, scrapeResults, scrapeMsg, request.debugEnabled))
}
}
}
}
catch (e: TimeoutCancellationException) {
logger.warn(e) { "fetchScrapeUrl() $e - $url" }
Expand Down
3 changes: 2 additions & 1 deletion wercker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
box: java
box:
id: openjdk

dev:
steps:
Expand Down

0 comments on commit 4e6be6a

Please sign in to comment.