Skip to content

Commit 1b46829

Browse files
authored
Merge branch 'master' into apply-scalafmtsbt
2 parents 77ad210 + b8dea69 commit 1b46829

File tree

32 files changed

+620
-1209
lines changed

32 files changed

+620
-1209
lines changed

.github/workflows/ci.yml

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
name: Test all the things
2-
32
on: [ push, pull_request ]
3+
env:
4+
JAVA_OPTS: -Xms5120M -Xmx5120M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
5+
JVM_OPTS: -Xms5120M -Xmx5120M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
46

57
jobs:
68
ci:
7-
runs-on: ubuntu-latest
8-
env:
9-
JAVA_OPTS: -Xms5120M -Xmx5120M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
10-
JVM_OPTS: -Xms5120M -Xmx5120M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
9+
runs-on: self-hosted
1110
steps:
12-
- uses: actions/checkout@v1
11+
- uses: actions/checkout@v4
1312
- run: git fetch -f --depth=1 origin '+refs/tags/*:refs/tags/*'
1413
- uses: coursier/cache-action@v6
1514
- uses: coursier/setup-action@v1
@@ -19,9 +18,13 @@ jobs:
1918
- name: Test
2019
run: sbt -v ";+core/test;+instrumentation/test;+reporters/test"
2120
lint:
22-
runs-on: ubuntu-latest
21+
runs-on: self-hosted
2322
steps:
24-
- uses: actions/checkout@v1
23+
- uses: actions/checkout@v4
2524
- uses: coursier/cache-action@v6
25+
- uses: coursier/setup-action@v1
26+
with:
27+
jvm: adopt:8
28+
apps: sbt
2629
- name: Test
2730
run: sbt -v "+scalafmtCheckAll;scalafmtSbtCheck"

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ on:
66

77
jobs:
88
release:
9-
runs-on: ubuntu-latest
9+
runs-on: self-hosted
1010
env:
1111
JAVA_OPTS: -Xms5120M -Xmx5120M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
1212
JVM_OPTS: -Xms5120M -Xmx5120M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
1313
steps:
14-
- uses: actions/checkout@v1
14+
- uses: actions/checkout@v4
1515
- run: git fetch -f --depth=1 origin '+refs/tags/*:refs/tags/*'
1616
- uses: coursier/cache-action@v6
1717
- uses: coursier/setup-action@v1

build.sbt

+18
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ lazy val `kamon-spring` = (project in file("instrumentation/kamon-spring"))
414414
"org.springframework.boot" % "spring-boot-starter-webflux" % "2.4.2" % "provided",
415415
okHttp % "test",
416416
"com.h2database" % "h2" % "1.4.200" % "test",
417+
"javax.xml.bind" % "jaxb-api" % "2.3.1" % "test",
417418
"org.springframework.boot" % "spring-boot-starter-data-jpa" % "2.4.2" % "test",
418419
scalatest % "test",
419420
logbackClassic % "test"
@@ -575,6 +576,21 @@ lazy val `kamon-pekko-grpc` = (project in file("instrumentation/kamon-pekko-grpc
575576
)
576577
)).dependsOn(`kamon-pekko-http`, `kamon-testkit` % "test")
577578

579+
lazy val `kamon-pekko-connectors-kafka` = (project in file("instrumentation/kamon-pekko-connectors-kafka"))
580+
.disablePlugins(AssemblyPlugin)
581+
.enablePlugins(JavaAgent)
582+
.settings(instrumentationSettings)
583+
.settings(
584+
crossScalaVersions := Seq(`scala_2.12_version`, `scala_2.13_version`, scala_3_version),
585+
libraryDependencies ++= Seq(
586+
kanelaAgent % "provided",
587+
"org.apache.pekko" %% "pekko-connectors-kafka" % "1.0.0" % "provided",
588+
"org.apache.pekko" %% "pekko-stream" % "1.0.1" % "provided",
589+
scalatest % "test",
590+
logbackClassic % "test"
591+
)
592+
).dependsOn(`kamon-core`, `kamon-pekko`, `kamon-testkit` % "test")
593+
578594
lazy val `kamon-akka-grpc` = (project in file("instrumentation/kamon-akka-grpc"))
579595
.enablePlugins(JavaAgent, AkkaGrpcPlugin)
580596
.disablePlugins(AssemblyPlugin)
@@ -821,6 +837,7 @@ lazy val `kamon-apache-cxf` = (project in file("instrumentation/kamon-apache-cxf
821837
"org.mock-server" % "mockserver-client-java" % "5.13.2" % "test",
822838
"com.dimafeng" %% "testcontainers-scala" % "0.41.0" % "test",
823839
"com.dimafeng" %% "testcontainers-scala-mockserver" % "0.41.0" % "test",
840+
"javax.xml.bind" % "jaxb-api" % "2.3.1" % "test",
824841
"org.apache.cxf" % "cxf-rt-frontend-jaxws" % "3.3.6" % "test",
825842
"org.apache.cxf" % "cxf-rt-transports-http" % "3.3.6" % "test"
826843
)
@@ -1106,6 +1123,7 @@ lazy val `kamon-bundle-dependencies-2-12-and-up` = (project in file("bundle/kamo
11061123
`kamon-pekko`,
11071124
`kamon-pekko-http`,
11081125
`kamon-pekko-grpc`,
1126+
`kamon-pekko-connectors-kafka`,
11091127
`kamon-tapir`,
11101128
`kamon-alpakka-kafka`
11111129
)

core/kamon-core/src/main/java/kamon/context/generated/binary/context/BooleanTag.java

+26-51
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
1-
/*
2-
* Copyright 2013-2021 The Kamon Project <https://kamon.io>
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
171
package kamon.context.generated.binary.context;
182

193

204
// Code generated by colf(1); DO NOT EDIT.
5+
// The compiler used schema file Context.colf.
216

227

238
import static java.lang.String.format;
@@ -40,20 +25,16 @@
4025
* @author generated by colf(1)
4126
* @see <a href="https://github.com/pascaldekloe/colfer">Colfer's home</a>
4227
*/
43-
@javax.annotation.Generated(value="colf(1)", comments="Colfer from schema file Context.colf")
4428
public class BooleanTag implements Serializable {
4529

4630
/** The upper limit for serial byte sizes. */
4731
public static int colferSizeMax = 16 * 1024 * 1024;
4832

4933

50-
51-
5234
public String key;
5335

5436
public boolean value;
5537

56-
5738
/** Default constructor */
5839
public BooleanTag() {
5940
init();
@@ -88,7 +69,6 @@ public static class Unmarshaller {
8869
* @param buf the initial buffer or {@code null}.
8970
*/
9071
public Unmarshaller(InputStream in, byte[] buf) {
91-
// TODO: better size estimation
9272
if (buf == null || buf.length == 0)
9373
buf = new byte[Math.min(BooleanTag.colferSizeMax, 2048)];
9474
this.buf = buf;
@@ -133,7 +113,6 @@ public BooleanTag next() throws IOException {
133113
this.i = 0;
134114
} else if (i == buf.length) {
135115
byte[] src = this.buf;
136-
// TODO: better size estimation
137116
if (offset == 0) this.buf = new byte[Math.min(BooleanTag.colferSizeMax, this.buf.length * 4)];
138117
System.arraycopy(src, this.offset, this.buf, 0, this.i - this.offset);
139118
this.i -= this.offset;
@@ -154,6 +133,16 @@ public BooleanTag next() throws IOException {
154133

155134
}
156135

136+
/**
137+
* Gets the serial size estimate as an upper boundary, whereby
138+
* {@link #marshal(byte[],int)} ≤ {@link #marshalFit()} ≤ {@link #colferSizeMax}.
139+
* @return the number of bytes.
140+
*/
141+
public int marshalFit() {
142+
long n = 1L + 6 + (long)this.key.length() * 3 + 1;
143+
if (n < 0 || n > (long)BooleanTag.colferSizeMax) return BooleanTag.colferSizeMax;
144+
return (int) n;
145+
}
157146

158147
/**
159148
* Serializes the object.
@@ -165,22 +154,16 @@ public BooleanTag next() throws IOException {
165154
* @throws IllegalStateException on an upper limit breach defined by {@link #colferSizeMax}.
166155
*/
167156
public byte[] marshal(OutputStream out, byte[] buf) throws IOException {
168-
// TODO: better size estimation
169-
if (buf == null || buf.length == 0)
170-
buf = new byte[Math.min(BooleanTag.colferSizeMax, 2048)];
171-
172-
while (true) {
173-
int i;
174-
try {
175-
i = marshal(buf, 0);
176-
} catch (BufferOverflowException e) {
177-
buf = new byte[Math.min(BooleanTag.colferSizeMax, buf.length * 4)];
178-
continue;
179-
}
180-
181-
out.write(buf, 0, i);
182-
return buf;
157+
int n = 0;
158+
if (buf != null && buf.length != 0) try {
159+
n = marshal(buf, 0);
160+
} catch (BufferOverflowException e) {}
161+
if (n == 0) {
162+
buf = new byte[marshalFit()];
163+
n = marshal(buf, 0);
183164
}
165+
out.write(buf, 0, n);
166+
return buf;
184167
}
185168

186169
/**
@@ -323,16 +306,8 @@ public int unmarshal(byte[] buf, int offset, int end) {
323306

324307
// {@link Serializable} Colfer extension.
325308
private void writeObject(ObjectOutputStream out) throws IOException {
326-
// TODO: better size estimation
327-
byte[] buf = new byte[1024];
328-
int n;
329-
while (true) try {
330-
n = marshal(buf, 0);
331-
break;
332-
} catch (BufferUnderflowException e) {
333-
buf = new byte[4 * buf.length];
334-
}
335-
309+
byte[] buf = new byte[marshalFit()];
310+
int n = marshal(buf, 0);
336311
out.writeInt(n);
337312
out.write(buf, 0, n);
338313
}
@@ -371,7 +346,7 @@ public void setKey(String value) {
371346
/**
372347
* Sets kamon/context/generated/binary/context.BooleanTag.key.
373348
* @param value the replacement.
374-
* @return {link this}.
349+
* @return {@code this}.
375350
*/
376351
public BooleanTag withKey(String value) {
377352
this.key = value;
@@ -397,7 +372,7 @@ public void setValue(boolean value) {
397372
/**
398373
* Sets kamon/context/generated/binary/context.BooleanTag.value.
399374
* @param value the replacement.
400-
* @return {link this}.
375+
* @return {@code this}.
401376
*/
402377
public BooleanTag withValue(boolean value) {
403378
this.value = value;
@@ -420,8 +395,8 @@ public final boolean equals(Object o) {
420395
public final boolean equals(BooleanTag o) {
421396
if (o == null) return false;
422397
if (o == this) return true;
423-
return o.getClass() == BooleanTag.class
424-
&& (this.key == null ? o.key == null : this.key.equals(o.key))
398+
399+
return (this.key == null ? o.key == null : this.key.equals(o.key))
425400
&& this.value == o.value;
426401
}
427402

0 commit comments

Comments
 (0)