Skip to content

Commit 7c08ea7

Browse files
committed
Rebase with OTel Metrics
1 parent bd67163 commit 7c08ea7

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/common/InMemoryMetricExporter.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import io.opentelemetry.api.common.AttributeKey;
2323
import io.opentelemetry.api.common.Attributes;
24-
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
2524
import io.opentelemetry.sdk.common.CompletableResultCode;
2625
import io.opentelemetry.sdk.metrics.InstrumentType;
2726
import io.opentelemetry.sdk.metrics.data.AggregationTemporality;
@@ -35,9 +34,6 @@
3534
@ApplicationScoped
3635
public class InMemoryMetricExporter implements MetricExporter {
3736

38-
private static final List<String> LEGACY_KEY_COMPONENTS = List.of(SemanticAttributes.HTTP_METHOD.getKey(),
39-
SemanticAttributes.HTTP_ROUTE.getKey(),
40-
SemanticAttributes.HTTP_STATUS_CODE.getKey());
4137
private static final List<String> KEY_COMPONENTS = List.of(SemanticAttributes.HTTP_REQUEST_METHOD.getKey(),
4238
SemanticAttributes.HTTP_ROUTE.getKey(),
4339
SemanticAttributes.HTTP_RESPONSE_STATUS_CODE.getKey());
@@ -77,13 +73,7 @@ public static Map<String, PointData> getMostRecentPointsMap(List<MetricData> fin
7773
.collect(toMap(
7874
pointData -> pointData.getAttributes().asMap().entrySet().stream()
7975
//valid attributes for the resulting map key
80-
.filter(entry -> {
81-
if (SemconvStability.emitOldHttpSemconv()) {
82-
return LEGACY_KEY_COMPONENTS.contains(entry.getKey().getKey());
83-
} else {
84-
return KEY_COMPONENTS.contains(entry.getKey().getKey());
85-
}
86-
})
76+
.filter(entry -> KEY_COMPONENTS.contains(entry.getKey().getKey()))
8777
// ensure order
8878
.sorted(Comparator.comparing(o -> o.getKey().getKey()))
8979
// build key

extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/sender/VertxHttpSender.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.zip.GZIPOutputStream;
1919

2020
import io.opentelemetry.exporter.internal.http.HttpSender;
21+
import io.opentelemetry.exporter.internal.marshal.Marshaler;
2122
import io.opentelemetry.sdk.common.CompletableResultCode;
2223
import io.opentelemetry.sdk.internal.ThrottlingLogger;
2324
import io.quarkus.vertx.core.runtime.BufferOutputStream;
@@ -91,7 +92,7 @@ private static String determineBasePath(URI baseUri) {
9192
}
9293

9394
@Override
94-
public void send(Consumer<OutputStream> marshaler,
95+
public void send(Marshaler marshaler,
9596
int contentLength,
9697
Consumer<Response> onHttpResponseRead,
9798
Consumer<Throwable> onError) {
@@ -178,7 +179,7 @@ private static class ClientRequestSuccessHandler implements Handler<HttpClientRe
178179
private final int contentLength;
179180
private final Consumer<Response> onHttpResponseRead;
180181
private final Consumer<Throwable> onError;
181-
private final Consumer<OutputStream> marshaler;
182+
private final Marshaler marshaler;
182183

183184
private final int attemptNumber;
184185
private final Supplier<Boolean> isShutdown;
@@ -190,7 +191,7 @@ public ClientRequestSuccessHandler(HttpClient client,
190191
int contentLength,
191192
Consumer<Response> onHttpResponseRead,
192193
Consumer<Throwable> onError,
193-
Consumer<OutputStream> marshaler,
194+
Marshaler marshaler,
194195
int attemptNumber,
195196
Supplier<Boolean> isShutdown) {
196197
this.client = client;
@@ -281,12 +282,16 @@ public byte[] responseBody() {
281282
if (compressionEnabled) {
282283
clientRequest.putHeader("Content-Encoding", "gzip");
283284
try (var gzos = new GZIPOutputStream(os)) {
284-
marshaler.accept(gzos);
285+
marshaler.writeBinaryTo(gzos);
285286
} catch (IOException e) {
286287
throw new IllegalStateException(e);
287288
}
288289
} else {
289-
marshaler.accept(os);
290+
try {
291+
marshaler.writeBinaryTo(os);
292+
} catch (IOException e) {
293+
throw new IllegalStateException(e);
294+
}
290295
}
291296

292297
if (!headers.isEmpty()) {

0 commit comments

Comments
 (0)