Skip to content

Commit b8b6bbe

Browse files
committed
Test deprecated API
1 parent 28b4c18 commit b8b6bbe

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.instrumentation.armeria.v1_3;
7+
8+
import com.linecorp.armeria.client.WebClientBuilder;
9+
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
10+
import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpClientTest;
11+
import io.opentelemetry.instrumentation.testing.junit.http.HttpClientInstrumentationExtension;
12+
import io.opentelemetry.instrumentation.testing.junit.http.HttpClientTestOptions;
13+
import java.util.Collections;
14+
import org.junit.jupiter.api.extension.RegisterExtension;
15+
16+
@SuppressWarnings("deprecation")
17+
class ArmeriaHttpClientOldTest extends AbstractArmeriaHttpClientTest {
18+
19+
@RegisterExtension
20+
static final InstrumentationExtension testing = HttpClientInstrumentationExtension.forLibrary();
21+
22+
@Override
23+
protected WebClientBuilder configureClient(WebClientBuilder clientBuilder) {
24+
return clientBuilder.decorator(
25+
ArmeriaTelemetry.builder(testing.getOpenTelemetry())
26+
.setCapturedClientRequestHeaders(
27+
Collections.singletonList(AbstractHttpClientTest.TEST_REQUEST_HEADER))
28+
.setCapturedClientResponseHeaders(
29+
Collections.singletonList(AbstractHttpClientTest.TEST_RESPONSE_HEADER))
30+
.build()
31+
.newClientDecorator());
32+
}
33+
34+
@Override
35+
protected void configure(HttpClientTestOptions.Builder optionsBuilder) {
36+
super.configure(optionsBuilder);
37+
38+
// library instrumentation doesn't have a good way of suppressing nested CLIENT spans yet
39+
optionsBuilder.disableTestWithClientParent();
40+
41+
// Agent users have automatic propagation through executor instrumentation, but library users
42+
// should do manually using Armeria patterns.
43+
optionsBuilder.disableTestCallbackWithParent();
44+
optionsBuilder.disableTestErrorWithCallback();
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.instrumentation.armeria.v1_3;
7+
8+
import com.linecorp.armeria.server.ServerBuilder;
9+
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
10+
import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerTest;
11+
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerInstrumentationExtension;
12+
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerTestOptions;
13+
import java.util.Collections;
14+
import org.junit.jupiter.api.extension.RegisterExtension;
15+
16+
@SuppressWarnings("deprecation")
17+
class ArmeriaHttpServerOldTest extends AbstractArmeriaHttpServerTest {
18+
19+
@RegisterExtension
20+
static final InstrumentationExtension testing = HttpServerInstrumentationExtension.forLibrary();
21+
22+
@Override
23+
protected ServerBuilder configureServer(ServerBuilder sb) {
24+
return sb.decorator(
25+
ArmeriaTelemetry.builder(testing.getOpenTelemetry())
26+
.setCapturedServerRequestHeaders(
27+
Collections.singletonList(AbstractHttpServerTest.TEST_REQUEST_HEADER))
28+
.setCapturedServerResponseHeaders(
29+
Collections.singletonList(AbstractHttpServerTest.TEST_RESPONSE_HEADER))
30+
.build()
31+
.newServiceDecorator());
32+
}
33+
34+
@Override
35+
protected void configure(HttpServerTestOptions options) {
36+
super.configure(options);
37+
// library instrumentation does not create a span at all
38+
options.disableTestNonStandardHttpMethod();
39+
}
40+
}

0 commit comments

Comments
 (0)