Skip to content

Commit

Permalink
Merge branch '1.13.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatan-ivanov committed Oct 8, 2024
2 parents c799962 + 44fdcbe commit 82615d3
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 2 deletions.
1 change: 1 addition & 0 deletions micrometer-java11/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ description 'Micrometer core classes that require Java 11'
dependencies {
api project(":micrometer-core")

testImplementation project(":micrometer-test")
testImplementation 'ru.lanwen.wiremock:wiremock-junit5'
testImplementation 'com.github.tomakehurst:wiremock-jre8-standalone'
testImplementation project(":micrometer-observation-test")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public String asString() {

/**
* Key name for outcome.
* @since 1.11.0
*/
OUTCOME {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright 2024 VMware, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micrometer.java11.instrument.binder.jdk;

import io.micrometer.common.lang.Nullable;
import io.micrometer.core.instrument.HttpClientTimingInstrumentationVerificationTests;
import io.micrometer.observation.docs.ObservationDocumentation;

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;

class JdkHttpClientTimingInstrumentationVerificationTests
extends HttpClientTimingInstrumentationVerificationTests<HttpClient> {

@Override
protected HttpClient clientInstrumentedWithMetrics() {
return getInstrumentationBuilder().build();
}

@Nullable
@Override
protected HttpClient clientInstrumentedWithObservations() {
return getInstrumentationBuilder().observationRegistry(getObservationRegistry()).build();
}

private MicrometerHttpClient.InstrumentationBuilder getInstrumentationBuilder() {
return MicrometerHttpClient.instrumentationBuilder(
HttpClient.newBuilder().connectTimeout(Duration.ofMillis(100)).build(), getRegistry());
}

@Override
protected void sendHttpRequest(HttpClient instrumentedClient, HttpMethod method, @Nullable byte[] body, URI baseUri,
String templatedPath, String... pathVariables) {
try {
instrumentedClient.send(makeRequest(method, body, baseUri, templatedPath, pathVariables),
HttpResponse.BodyHandlers.ofString());
}
catch (Exception e) {
throw new RuntimeException(e);
}
}

@Override
protected ObservationDocumentation observationDocumentation() {
return HttpClientObservationDocumentation.HTTP_CALL;
}

private HttpRequest makeRequest(HttpMethod method, @Nullable byte[] body, URI baseUri, String templatedPath,
String... pathVariables) {
return HttpRequest.newBuilder()
.method(method.name(),
body != null ? HttpRequest.BodyPublishers.ofByteArray(body) : HttpRequest.BodyPublishers.noBody())
.uri(URI.create(baseUri + substitutePathVariables(templatedPath, pathVariables)))
.setHeader(MicrometerHttpClient.URI_PATTERN_HEADER, templatedPath)
.build();
}

}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ buildCache {

include 'micrometer-commons', 'micrometer-core', 'micrometer-observation'

['core', 'boot2', 'boot2-reactive', 'spring-integration', 'hazelcast', 'hazelcast3', 'javalin', 'jersey3', 'jetty12', 'jooq', 'kotlin'].each { sample ->
['core', 'boot2', 'boot2-reactive', 'spring-integration', 'hazelcast', 'hazelcast3', 'javalin', 'jersey3', 'jooq', 'kotlin'].each { sample ->
include "micrometer-samples-$sample"
project(":micrometer-samples-$sample").projectDir = new File(rootProject.projectDir, "samples/micrometer-samples-$sample")
}
Expand Down

0 comments on commit 82615d3

Please sign in to comment.