Skip to content

Commit fb98ed2

Browse files
fix(deps): update dependency io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha to v2.13.0-alpha (#1736)
1 parent 3af0b8e commit fb98ed2

File tree

8 files changed

+73
-65
lines changed

8 files changed

+73
-65
lines changed

aws-resources/src/main/java/io/opentelemetry/contrib/aws/resource/EcsResource.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,8 @@ static void parseResponse(
192192
DockerImage parsedImage = DockerImage.parse(value);
193193
if (parsedImage != null) {
194194
attrBuilders.put(CONTAINER_IMAGE_NAME, parsedImage.getRepository());
195-
// TODO: CONTAINER_IMAGE_TAG has been replaced with CONTAINER_IMAGE_TAGS
196195
attrBuilders.put(
197-
io.opentelemetry.semconv.ResourceAttributes.CONTAINER_IMAGE_TAG,
196+
io.opentelemetry.contrib.aws.resource.IncubatingAttributes.CONTAINER_IMAGE_TAGS,
198197
parsedImage.getTag());
199198
}
200199
break;

aws-resources/src/main/java/io/opentelemetry/contrib/aws/resource/IncubatingAttributes.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ private IncubatingAttributes() {}
2626
public static final AttributeKey<String> CLOUD_REGION = AttributeKey.stringKey("cloud.region");
2727
public static final AttributeKey<String> CLOUD_RESOURCE_ID =
2828
AttributeKey.stringKey("cloud.resource_id");
29+
public static final AttributeKey<List<String>> CONTAINER_IMAGE_TAGS =
30+
AttributeKey.stringArrayKey("container.image.tags");
2931

3032
public static final class CloudPlatformIncubatingValues {
3133
public static final String AWS_EC2 = "aws_ec2";

aws-resources/src/test/java/io/opentelemetry/contrib/aws/resource/EcsResourceTest.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
import static io.opentelemetry.semconv.incubating.CloudIncubatingAttributes.CLOUD_RESOURCE_ID;
2525
import static io.opentelemetry.semconv.incubating.ContainerIncubatingAttributes.CONTAINER_ID;
2626
import static io.opentelemetry.semconv.incubating.ContainerIncubatingAttributes.CONTAINER_IMAGE_NAME;
27+
import static io.opentelemetry.semconv.incubating.ContainerIncubatingAttributes.CONTAINER_IMAGE_TAGS;
2728
import static io.opentelemetry.semconv.incubating.ContainerIncubatingAttributes.CONTAINER_NAME;
29+
import static java.util.Collections.singletonList;
2830
import static org.assertj.core.api.Assertions.entry;
2931
import static org.mockito.Mockito.when;
3032

@@ -52,8 +54,6 @@ class EcsResourceTest {
5254

5355
@Mock private SimpleHttpClient mockHttpClient;
5456

55-
// Suppression is required for CONTAINER_IMAGE_TAG until we are ready to upgrade.
56-
@SuppressWarnings("deprecation")
5757
@Test
5858
void testCreateAttributesV3() throws IOException {
5959
Map<String, String> mockSysEnv = new HashMap<>();
@@ -78,7 +78,7 @@ void testCreateAttributesV3() throws IOException {
7878
entry(CONTAINER_NAME, "ecs-nginx-5-nginx-curl-ccccb9f49db0dfe0d901"),
7979
entry(CONTAINER_ID, "43481a6ce4842eec8fe72fc28500c6b52edcc0917f105b83379f88cac1ff3946"),
8080
entry(CONTAINER_IMAGE_NAME, "nrdlngr/nginx-curl"),
81-
entry(io.opentelemetry.semconv.ResourceAttributes.CONTAINER_IMAGE_TAG, "latest"),
81+
entry(CONTAINER_IMAGE_TAGS, singletonList("latest")),
8282
entry(AWS_ECS_CLUSTER_ARN, "arn:aws:ecs:us-east-2:012345678910:cluster/default"),
8383
entry(
8484
AttributeKey.stringKey("aws.ecs.container.image.id"),
@@ -90,8 +90,6 @@ void testCreateAttributesV3() throws IOException {
9090
entry(AWS_ECS_TASK_REVISION, "5"));
9191
}
9292

93-
// Suppression is required for CONTAINER_IMAGE_TAG until we are ready to upgrade.
94-
@SuppressWarnings("deprecation")
9593
@Test
9694
void testCreateAttributesV4() throws IOException {
9795
Map<String, String> mockSysEnv = new HashMap<>();
@@ -119,25 +117,22 @@ void testCreateAttributesV4() throws IOException {
119117
entry(CONTAINER_NAME, "ecs-curltest-26-curl-cca48e8dcadd97805600"),
120118
entry(CONTAINER_ID, "ea32192c8553fbff06c9340478a2ff089b2bb5646fb718b4ee206641c9086d66"),
121119
entry(CONTAINER_IMAGE_NAME, "111122223333.dkr.ecr.us-west-2.amazonaws.com/curltest"),
122-
entry(io.opentelemetry.semconv.ResourceAttributes.CONTAINER_IMAGE_TAG, "latest"),
120+
entry(CONTAINER_IMAGE_TAGS, singletonList("latest")),
123121
entry(
124122
AttributeKey.stringKey("aws.ecs.container.image.id"),
125123
"sha256:d691691e9652791a60114e67b365688d20d19940dde7c4736ea30e660d8d3553"),
126124
entry(AWS_ECS_CLUSTER_ARN, "arn:aws:ecs:us-west-2:111122223333:cluster/default"),
127125
entry(
128126
AWS_ECS_CONTAINER_ARN,
129127
"arn:aws:ecs:us-west-2:111122223333:container/0206b271-b33f-47ab-86c6-a0ba208a70a9"),
130-
entry(AWS_LOG_GROUP_NAMES, Collections.singletonList("/ecs/metadata")),
128+
entry(AWS_LOG_GROUP_NAMES, singletonList("/ecs/metadata")),
131129
entry(
132130
AWS_LOG_GROUP_ARNS,
133-
Collections.singletonList(
134-
"arn:aws:logs:us-west-2:111122223333:log-group:/ecs/metadata")),
135-
entry(
136-
AWS_LOG_STREAM_NAMES,
137-
Collections.singletonList("ecs/curl/8f03e41243824aea923aca126495f665")),
131+
singletonList("arn:aws:logs:us-west-2:111122223333:log-group:/ecs/metadata")),
132+
entry(AWS_LOG_STREAM_NAMES, singletonList("ecs/curl/8f03e41243824aea923aca126495f665")),
138133
entry(
139134
AWS_LOG_STREAM_ARNS,
140-
Collections.singletonList(
135+
singletonList(
141136
"arn:aws:logs:us-west-2:111122223333:log-group:/ecs/metadata:log-stream:ecs/curl/8f03e41243824aea923aca126495f665")),
142137
entry(
143138
AWS_ECS_TASK_ARN,

dependencyManagement/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
`java-platform`
33
}
44

5-
val otelInstrumentationVersion = "2.12.0-alpha"
5+
val otelInstrumentationVersion = "2.13.0-alpha"
66
val semconvVersion = "1.30.0"
77

88
javaPlatform {

inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/internal/util/OtelReflectionUtils.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import io.opentelemetry.api.GlobalOpenTelemetry;
99
import io.opentelemetry.api.OpenTelemetry;
10-
import io.opentelemetry.api.incubator.events.GlobalEventLoggerProvider;
1110
import io.opentelemetry.api.trace.TracerProvider;
1211
import io.opentelemetry.sdk.OpenTelemetrySdk;
1312
import io.opentelemetry.sdk.trace.SdkTracerProvider;
@@ -42,7 +41,6 @@ public static void shutdownAndResetGlobalOtel() {
4241
OpenTelemetrySdk sdk = (OpenTelemetrySdk) readField(otel, "delegate");
4342
sdk.close();
4443
GlobalOpenTelemetry.resetForTest();
45-
GlobalEventLoggerProvider.resetForTest();
4644
}
4745
}
4846

jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/JmxConnectionTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import java.nio.file.Path;
1111
import java.security.cert.X509Certificate;
12+
import java.util.concurrent.TimeUnit;
1213
import java.util.function.Function;
1314
import org.junit.jupiter.api.AfterAll;
1415
import org.junit.jupiter.api.BeforeAll;
@@ -191,18 +192,17 @@ private static void checkConnectionLogs(JmxScraperContainer scraper, boolean exp
191192
}
192193

193194
private static void waitTerminated(GenericContainer<?> container) {
194-
int retries = 10;
195-
while (retries > 0 && container.isRunning()) {
196-
retries--;
195+
long retryUntil = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(10);
196+
while (container.isRunning() && System.currentTimeMillis() < retryUntil) {
197197
try {
198-
Thread.sleep(100);
198+
TimeUnit.MILLISECONDS.sleep(100);
199199
} catch (InterruptedException e) {
200200
throw new RuntimeException(e);
201201
}
202202
}
203-
assertThat(retries)
203+
assertThat(container.isRunning())
204204
.describedAs("container should stop when testing connection")
205-
.isNotEqualTo(0);
205+
.isFalse();
206206
}
207207

208208
private static JmxScraperContainer scraperContainer() {

processors/src/main/java/io/opentelemetry/contrib/eventbridge/EventToSpanEventBridge.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import io.opentelemetry.sdk.logs.LogRecordProcessor;
1818
import io.opentelemetry.sdk.logs.ReadWriteLogRecord;
1919
import io.opentelemetry.sdk.logs.data.LogRecordData;
20+
import io.opentelemetry.sdk.logs.data.internal.ExtendedLogRecordData;
2021
import java.io.ByteArrayOutputStream;
2122
import java.io.IOException;
2223
import java.nio.charset.StandardCharsets;
@@ -56,7 +57,6 @@ public final class EventToSpanEventBridge implements LogRecordProcessor {
5657

5758
private static final Logger logger = Logger.getLogger(EventToSpanEventBridge.class.getName());
5859

59-
private static final AttributeKey<String> EVENT_NAME = AttributeKey.stringKey("event.name");
6060
private static final AttributeKey<Long> LOG_RECORD_OBSERVED_TIME_UNIX_NANO =
6161
AttributeKey.longKey("log.record.observed_time_unix_nano");
6262
private static final AttributeKey<Long> LOG_RECORD_SEVERITY_NUMBER =
@@ -76,7 +76,10 @@ public static EventToSpanEventBridge create() {
7676
@Override
7777
public void onEmit(Context context, ReadWriteLogRecord logRecord) {
7878
LogRecordData logRecordData = logRecord.toLogRecordData();
79-
String eventName = logRecordData.getAttributes().get(EVENT_NAME);
79+
if (!(logRecordData instanceof ExtendedLogRecordData)) {
80+
return;
81+
}
82+
String eventName = ((ExtendedLogRecordData) logRecordData).getEventName();
8083
if (eventName == null) {
8184
return;
8285
}
@@ -99,8 +102,7 @@ public void onEmit(Context context, ReadWriteLogRecord logRecord) {
99102
}
100103

101104
private static Attributes toSpanEventAttributes(LogRecordData logRecord) {
102-
AttributesBuilder builder =
103-
logRecord.getAttributes().toBuilder().removeIf(key -> key.equals(EVENT_NAME));
105+
AttributesBuilder builder = logRecord.getAttributes().toBuilder();
104106

105107
builder.put(LOG_RECORD_OBSERVED_TIME_UNIX_NANO, logRecord.getObservedTimestampEpochNanos());
106108

processors/src/test/java/io/opentelemetry/contrib/eventbridge/EventToSpanEventBridgeTest.java

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
import static io.opentelemetry.api.common.AttributeKey.stringKey;
1010
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
1111

12+
import io.opentelemetry.api.common.AttributeKey;
1213
import io.opentelemetry.api.common.Attributes;
14+
import io.opentelemetry.api.common.KeyValue;
1315
import io.opentelemetry.api.common.Value;
14-
import io.opentelemetry.api.incubator.events.EventLogger;
16+
import io.opentelemetry.api.incubator.logs.ExtendedLogger;
1517
import io.opentelemetry.api.logs.Severity;
1618
import io.opentelemetry.api.trace.Span;
1719
import io.opentelemetry.api.trace.SpanContext;
@@ -22,7 +24,6 @@
2224
import io.opentelemetry.context.Context;
2325
import io.opentelemetry.context.Scope;
2426
import io.opentelemetry.sdk.logs.SdkLoggerProvider;
25-
import io.opentelemetry.sdk.logs.internal.SdkEventLoggerProvider;
2627
import io.opentelemetry.sdk.testing.exporter.InMemorySpanExporter;
2728
import io.opentelemetry.sdk.testing.time.TestClock;
2829
import io.opentelemetry.sdk.trace.IdGenerator;
@@ -46,14 +47,13 @@ class EventToSpanEventBridgeTest {
4647
.addSpanProcessor(SimpleSpanProcessor.create(spanExporter))
4748
.build();
4849
private final TestClock testClock = TestClock.create();
49-
private final SdkEventLoggerProvider eventLoggerProvider =
50-
SdkEventLoggerProvider.create(
51-
SdkLoggerProvider.builder()
52-
.setClock(testClock)
53-
.addLogRecordProcessor(EventToSpanEventBridge.create())
54-
.build());
50+
private final SdkLoggerProvider loggerProvider =
51+
SdkLoggerProvider.builder()
52+
.setClock(testClock)
53+
.addLogRecordProcessor(EventToSpanEventBridge.create())
54+
.build();
5555
private final Tracer tracer = tracerProvider.get("tracer");
56-
private final EventLogger eventLogger = eventLoggerProvider.get("event-logger");
56+
private final ExtendedLogger logger = (ExtendedLogger) loggerProvider.get("event-logger");
5757

5858
private static Sampler onlyServerSpans() {
5959
return new Sampler() {
@@ -85,15 +85,18 @@ void withRecordingSpan_BridgesEvent() {
8585
// others. We create a recording span by setting kind to SERVER.
8686
Span span = tracer.spanBuilder("span").setSpanKind(SpanKind.SERVER).startSpan();
8787
try (Scope unused = span.makeCurrent()) {
88-
eventLogger
89-
.builder("my.event-name")
88+
logger
89+
.logRecordBuilder()
90+
.setEventName("my.event-name")
9091
.setTimestamp(100, TimeUnit.NANOSECONDS)
9192
.setSeverity(Severity.DEBUG)
92-
.put("foo", "bar")
93-
.put("number", 1)
94-
.put("map", Value.of(Collections.singletonMap("key", Value.of("value"))))
95-
.setAttributes(Attributes.builder().put("color", "red").build())
96-
.setAttributes(Attributes.builder().put("shape", "square").build())
93+
.setBody(
94+
Value.of(
95+
KeyValue.of("number", Value.of(1)),
96+
KeyValue.of("foo", Value.of("bar")),
97+
KeyValue.of("map", Value.of(Collections.singletonMap("key", Value.of("value"))))))
98+
.setAttribute(AttributeKey.stringKey("color"), "red")
99+
.setAttribute(AttributeKey.stringKey("shape"), "square")
97100
.emit();
98101
} finally {
99102
span.end();
@@ -134,15 +137,18 @@ void nonRecordingSpan_doesNotBridgeEvent() {
134137
// others. We create a non-recording span by setting kind to INTERNAL.
135138
Span span = tracer.spanBuilder("span").setSpanKind(SpanKind.INTERNAL).startSpan();
136139
try (Scope unused = span.makeCurrent()) {
137-
eventLogger
138-
.builder("my.event-name")
140+
logger
141+
.logRecordBuilder()
142+
.setEventName("my.event-name")
139143
.setTimestamp(100, TimeUnit.NANOSECONDS)
140144
.setSeverity(Severity.DEBUG)
141-
.put("foo", "bar")
142-
.put("number", 1)
143-
.put("map", Value.of(Collections.singletonMap("key", Value.of("value"))))
144-
.setAttributes(Attributes.builder().put("color", "red").build())
145-
.setAttributes(Attributes.builder().put("shape", "square").build())
145+
.setBody(
146+
Value.of(
147+
KeyValue.of("number", Value.of(1)),
148+
KeyValue.of("foo", Value.of("bar")),
149+
KeyValue.of("map", Value.of(Collections.singletonMap("key", Value.of("value"))))))
150+
.setAttribute(AttributeKey.stringKey("color"), "red")
151+
.setAttribute(AttributeKey.stringKey("shape"), "square")
146152
.emit();
147153
} finally {
148154
span.end();
@@ -158,8 +164,9 @@ void differentSpanContext_doesNotBridgeEvent() {
158164
// others. We create a recording span by setting kind to SERVER.
159165
Span span = tracer.spanBuilder("span").setSpanKind(SpanKind.SERVER).startSpan();
160166
try (Scope unused = span.makeCurrent()) {
161-
eventLogger
162-
.builder("my.event-name")
167+
logger
168+
.logRecordBuilder()
169+
.setEventName("my.event-name")
163170
// Manually override the context
164171
.setContext(
165172
Span.wrap(
@@ -171,11 +178,13 @@ void differentSpanContext_doesNotBridgeEvent() {
171178
.storeInContext(Context.current()))
172179
.setTimestamp(100, TimeUnit.NANOSECONDS)
173180
.setSeverity(Severity.DEBUG)
174-
.put("foo", "bar")
175-
.put("number", 1)
176-
.put("map", Value.of(Collections.singletonMap("key", Value.of("value"))))
177-
.setAttributes(Attributes.builder().put("color", "red").build())
178-
.setAttributes(Attributes.builder().put("shape", "square").build())
181+
.setBody(
182+
Value.of(
183+
KeyValue.of("number", Value.of(1)),
184+
KeyValue.of("foo", Value.of("bar")),
185+
KeyValue.of("map", Value.of(Collections.singletonMap("key", Value.of("value"))))))
186+
.setAttribute(AttributeKey.stringKey("color"), "red")
187+
.setAttribute(AttributeKey.stringKey("shape"), "square")
179188
.emit();
180189
} finally {
181190
span.end();
@@ -187,15 +196,18 @@ void differentSpanContext_doesNotBridgeEvent() {
187196

188197
@Test
189198
void noSpan_doesNotBridgeEvent() {
190-
eventLogger
191-
.builder("my.event-name")
199+
logger
200+
.logRecordBuilder()
201+
.setEventName("my.event-name")
192202
.setTimestamp(100, TimeUnit.NANOSECONDS)
193203
.setSeverity(Severity.DEBUG)
194-
.put("foo", "bar")
195-
.put("number", 1)
196-
.put("map", Value.of(Collections.singletonMap("key", Value.of("value"))))
197-
.setAttributes(Attributes.builder().put("color", "red").build())
198-
.setAttributes(Attributes.builder().put("shape", "square").build())
204+
.setBody(
205+
Value.of(
206+
KeyValue.of("number", Value.of(1)),
207+
KeyValue.of("foo", Value.of("bar")),
208+
KeyValue.of("map", Value.of(Collections.singletonMap("key", Value.of("value"))))))
209+
.setAttribute(AttributeKey.stringKey("color"), "red")
210+
.setAttribute(AttributeKey.stringKey("shape"), "square")
199211
.emit();
200212

201213
assertThat(spanExporter.getFinishedSpanItems()).isEmpty();

0 commit comments

Comments
 (0)