|
29 | 29 | import io.opentelemetry.instrumentation.testing.internal.AutoCleanupExtension;
|
30 | 30 | import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
|
31 | 31 | import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
|
32 |
| -import io.opentelemetry.sdk.testing.assertj.AttributeAssertion; |
33 | 32 | import io.opentelemetry.sdk.trace.data.StatusData;
|
34 | 33 | import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
|
35 | 34 | import java.net.InetSocketAddress;
|
36 | 35 | import java.time.Duration;
|
37 |
| -import java.util.ArrayList; |
38 | 36 | import java.util.Arrays;
|
39 | 37 | import java.util.Collection;
|
40 | 38 | import java.util.Collections;
|
41 | 39 | import java.util.HashMap;
|
42 |
| -import java.util.List; |
43 | 40 | import java.util.Map;
|
44 | 41 | import java.util.concurrent.ArrayBlockingQueue;
|
45 | 42 | import java.util.concurrent.BlockingQueue;
|
@@ -263,22 +260,15 @@ void getTimeout() throws InterruptedException {
|
263 | 260 | EXCEPTION_STACKTRACE,
|
264 | 261 | val -> val.isInstanceOf(String.class))))
|
265 | 262 | .hasAttributesSatisfyingExactly(
|
266 |
| - withErrorType( |
267 |
| - "net.spy.memcached.internal.CheckedOperationTimeoutException", |
268 |
| - equalTo( |
269 |
| - maybeStable(DB_SYSTEM), |
270 |
| - DbIncubatingAttributes.DbSystemIncubatingValues.MEMCACHED), |
271 |
| - equalTo(maybeStable(DB_OPERATION), "get"))))); |
272 |
| - } |
273 |
| - |
274 |
| - private static List<AttributeAssertion> withErrorType( |
275 |
| - String errorType, AttributeAssertion... assertions) { |
276 |
| - List<AttributeAssertion> list = new ArrayList<>(Arrays.asList(assertions)); |
277 |
| - |
278 |
| - if (SemconvStability.emitStableDatabaseSemconv()) { |
279 |
| - list.add(equalTo(ERROR_TYPE, errorType)); |
280 |
| - } |
281 |
| - return list; |
| 263 | + equalTo( |
| 264 | + ERROR_TYPE, |
| 265 | + SemconvStability.emitStableDatabaseSemconv() |
| 266 | + ? "net.spy.memcached.internal.CheckedOperationTimeoutException" |
| 267 | + : null), |
| 268 | + equalTo( |
| 269 | + maybeStable(DB_SYSTEM), |
| 270 | + DbIncubatingAttributes.DbSystemIncubatingValues.MEMCACHED), |
| 271 | + equalTo(maybeStable(DB_OPERATION), "get")))); |
282 | 272 | }
|
283 | 273 |
|
284 | 274 | @Test
|
@@ -896,12 +886,15 @@ void decrException() {
|
896 | 886 | .hasException(
|
897 | 887 | new IllegalArgumentException("Key is too long (maxlen = 250)"))
|
898 | 888 | .hasAttributesSatisfyingExactly(
|
899 |
| - withErrorType( |
900 |
| - "java.lang.IllegalArgumentException", |
901 |
| - equalTo( |
902 |
| - maybeStable(DB_SYSTEM), |
903 |
| - DbIncubatingAttributes.DbSystemIncubatingValues.MEMCACHED), |
904 |
| - equalTo(maybeStable(DB_OPERATION), "decr"))))); |
| 889 | + equalTo( |
| 890 | + ERROR_TYPE, |
| 891 | + SemconvStability.emitStableDatabaseSemconv() |
| 892 | + ? "java.lang.IllegalArgumentException" |
| 893 | + : null), |
| 894 | + equalTo( |
| 895 | + maybeStable(DB_SYSTEM), |
| 896 | + DbIncubatingAttributes.DbSystemIncubatingValues.MEMCACHED), |
| 897 | + equalTo(maybeStable(DB_OPERATION), "decr")))); |
905 | 898 | }
|
906 | 899 |
|
907 | 900 | @Test
|
@@ -984,12 +977,15 @@ void incrException() {
|
984 | 977 | .hasException(
|
985 | 978 | new IllegalArgumentException("Key is too long (maxlen = 250)"))
|
986 | 979 | .hasAttributesSatisfyingExactly(
|
987 |
| - withErrorType( |
988 |
| - "java.lang.IllegalArgumentException", |
989 |
| - equalTo( |
990 |
| - maybeStable(DB_SYSTEM), |
991 |
| - DbIncubatingAttributes.DbSystemIncubatingValues.MEMCACHED), |
992 |
| - equalTo(maybeStable(DB_OPERATION), "incr"))))); |
| 980 | + equalTo( |
| 981 | + ERROR_TYPE, |
| 982 | + SemconvStability.emitStableDatabaseSemconv() |
| 983 | + ? "java.lang.IllegalArgumentException" |
| 984 | + : null), |
| 985 | + equalTo( |
| 986 | + maybeStable(DB_SYSTEM), |
| 987 | + DbIncubatingAttributes.DbSystemIncubatingValues.MEMCACHED), |
| 988 | + equalTo(maybeStable(DB_OPERATION), "incr")))); |
993 | 989 | }
|
994 | 990 |
|
995 | 991 | private static String key(String k) {
|
|
0 commit comments