Skip to content

Commit 5efb8b5

Browse files
committed
Merge branch 'master' of github.com:kamon-io/Kamon into kamon-armeria-instrumentation
2 parents 82f9305 + 14bef34 commit 5efb8b5

File tree

6 files changed

+26
-21
lines changed

6 files changed

+26
-21
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Test all the things
22

3-
on:
4-
push:
3+
on: [push, pull_request]
4+
55

66
jobs:
77
ci:

build.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,11 @@ lazy val `kamon-annotation` = (project in file("instrumentation/kamon-annotation
340340
assemblyShadeRules in assembly := Seq(
341341
ShadeRule.rename("javax.el.**" -> "kamon.lib.@0").inAll,
342342
ShadeRule.rename("com.sun.el.**" -> "kamon.lib.@0").inAll,
343+
ShadeRule.rename("com.github.ben-manes.**" -> "kamon.lib.@0").inAll,
343344
),
344345
libraryDependencies ++= Seq(
345346
kanelaAgent % "provided",
347+
"com.github.ben-manes.caffeine" % "caffeine" % "2.8.5" % "provided,shaded", // provided? no?
346348
"org.glassfish" % "javax.el" % "3.0.1-b11" % "provided,shaded",
347349
scalatest % "test",
348350
logbackClassic % "test",

instrumentation/kamon-annotation/src/main/java/kamon/annotation/instrumentation/cache/AnnotationCache.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package kamon.annotation.instrumentation.cache;
1818

19+
import com.github.benmanes.caffeine.cache.Caffeine;
20+
import com.github.benmanes.caffeine.cache.RemovalListener;
1921
import kamon.Kamon;
2022
import kamon.annotation.api.Time;
2123
import kamon.annotation.api.TrackConcurrency;
@@ -24,29 +26,26 @@
2426
import kamon.metric.*;
2527
import kamon.tag.TagSet;
2628
import kamon.trace.SpanBuilder;
27-
import kanela.agent.libs.net.jodah.expiringmap.ExpirationListener;
28-
import kanela.agent.libs.net.jodah.expiringmap.ExpirationPolicy;
29-
import kanela.agent.libs.net.jodah.expiringmap.ExpiringMap;
3029
import kanela.agent.util.log.Logger;
3130

3231
import java.lang.reflect.Method;
3332
import java.util.Collections;
3433
import java.util.HashMap;
3534
import java.util.Map;
3635
import java.util.Objects;
36+
import java.util.concurrent.ConcurrentMap;
3737
import java.util.concurrent.TimeUnit;
3838

3939
public final class AnnotationCache {
4040

4141
private static Map<MetricKey, Object> metrics = buildCache();
4242

4343
private static Map<MetricKey, Object> buildCache() {
44-
return ExpiringMap
45-
.builder()
46-
.expiration(1, TimeUnit.MINUTES)
47-
.expirationPolicy(ExpirationPolicy.ACCESSED)
48-
.asyncExpirationListener(ExpirationListener())
49-
.build();
44+
return Caffeine.newBuilder()
45+
.expireAfterAccess(1, TimeUnit.MINUTES)
46+
.removalListener(LogExpirationListener())
47+
.build()
48+
.asMap();
5049
}
5150

5251
public static Gauge getGauge(Method method, Object obj, Class<?> clazz, String className, String methodName) {
@@ -193,8 +192,8 @@ private static String getOperationName(String name, Object obj, Class<?> clazz,
193192
return (evaluatedString.isEmpty() || evaluatedString.equals("unknown")) ? className + "." + methodName: evaluatedString;
194193
}
195194

196-
private static ExpirationListener<MetricKey, Object> ExpirationListener() {
197-
return (key, value) -> {
195+
private static RemovalListener<MetricKey, Object> LogExpirationListener() {
196+
return (key, value, cause) -> {
198197
if(value instanceof Instrument) ((Instrument) value).remove();
199198
Logger.debug(() -> "Expiring key: " + key + "with value" + value);
200199
};

instrumentation/kamon-play/build.sbt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ libraryDependencies ++= { if(scalaBinaryVersion.value == "2.11") Seq.empty else
5656
"com.typesafe.play" %% "play-logback" % `Play-2.8-version` % "test-play-2.8",
5757
)}
5858

59-
// We are explicitly removing the gRPC-related dependencies because they are not published for Scala 2.11.
60-
PB.additionalDependencies := { if(scalaBinaryVersion.value == "2.11") Seq.empty else PB.additionalDependencies.value }
59+
// We are explicitly removing the gRPC-related dependencies because the are manually added
60+
// on the Test configuration for Play 2.8.
61+
PB.additionalDependencies := Seq.empty
6162

6263

6364
/**

reporters/kamon-datadog/src/test/scala/kamon/datadog/DatadogMetricSenderSpec.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class DatadogMetricSenderSpec extends WordSpec with Matchers with Reconfigure {
6767
buffer.lst should contain("test.counter" -> "0|c|#service:kamon-application,env:staging,tag1:value1")
6868
}
6969

70-
"filter out blacklisted tags" in AgentReporter(new TestBuffer(), ConfigFactory.parseString(
70+
"filter out environment tags" in AgentReporter(new TestBuffer(), ConfigFactory.parseString(
7171
"""
7272
|kamon.datadog.environment-tags.exclude = [env]
7373
|kamon.environment.tags.env = staging
@@ -97,7 +97,8 @@ class DatadogMetricSenderSpec extends WordSpec with Matchers with Reconfigure {
9797

9898
"filter other tags" in AgentReporter(new TestBuffer(), ConfigFactory.parseString(
9999
"""
100-
|kamon.datadog.environment-tags.exclude = [ "tag*" ]
100+
|kamon.datadog.environment-tags.exclude = []
101+
|kamon.datadog.environment-tags.filter.excludes = [ "tag*" ]
101102
|kamon.environment.tags.env = staging
102103
|""".stripMargin).withFallback(Kamon.config())) {
103104
case (buffer, reporter) =>
@@ -120,7 +121,7 @@ class DatadogMetricSenderSpec extends WordSpec with Matchers with Reconfigure {
120121
)
121122

122123
buffer.lst should have size 1
123-
buffer.lst should contain("test.counter" -> "0|c|#service:kamon-application,env:staging,tag1:value1,tag2:value2,otherTag:otherValue")
124+
buffer.lst should contain("test.counter" -> "0|c|#service:kamon-application,env:staging,otherTag:otherValue")
124125
}
125126

126127
"append no tags" in AgentReporter(new TestBuffer(), ConfigFactory.parseString(

reporters/kamon-prometheus/src/main/scala/kamon/prometheus/embeddedhttp/SunEmbeddedHttpServer.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ class SunEmbeddedHttpServer(hostname: String, port: Int, scrapeSource: ScrapeSou
1414
val handler = new HttpHandler {
1515
override def handle(httpExchange: HttpExchange): Unit = {
1616
val data = scrapeSource.scrapeData()
17-
httpExchange.sendResponseHeaders(200, data.length)
17+
val bytes = data.getBytes(StandardCharsets.UTF_8)
18+
httpExchange.sendResponseHeaders(200, bytes.length)
1819
val os = httpExchange.getResponseBody
19-
try
20-
os.write(data.getBytes(StandardCharsets.UTF_8))
20+
try {
21+
os.write(bytes)
22+
}
2123
finally
2224
os.close()
2325
}

0 commit comments

Comments
 (0)