Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.CLOUD_PROVIDER;
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.CLOUD_REGION;
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.CloudPlatformIncubatingValues.AWS_EC2;
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.CloudProviderIncubatingValues.AWS;
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.HOST_ID;
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.HOST_IMAGE_ID;
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.HOST_NAME;
Expand Down Expand Up @@ -89,7 +90,7 @@ static Resource buildResource(String endpoint) {
String hostname = fetchHostname(hostnameUrl, token);

AttributesBuilder attrBuilders = Attributes.builder();
attrBuilders.put(CLOUD_PROVIDER, IncubatingAttributes.CloudProviderIncubatingValues.AWS);
attrBuilders.put(CLOUD_PROVIDER, AWS);
attrBuilders.put(CLOUD_PLATFORM, AWS_EC2);

try (JsonParser parser = JSON_FACTORY.createParser(identity)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ static void fetchMetadata(
.getLogGroupArn()
.ifPresent(
logGroupArn -> {
attrBuilders.put(AWS_LOG_GROUP_ARNS, Collections.singletonList(logGroupArn));
attrBuilders.put(AWS_LOG_GROUP_ARNS, singletonList(logGroupArn));
});

logArnBuilder
.getLogStreamArn()
.ifPresent(
logStreamArn -> {
attrBuilders.put(AWS_LOG_STREAM_ARNS, Collections.singletonList(logStreamArn));
attrBuilders.put(AWS_LOG_STREAM_ARNS, singletonList(logStreamArn));
});
} catch (IOException e) {
logger.log(Level.WARNING, "Can't get ECS metadata", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
public class EksResourceTest {
class EksResourceTest {

@Mock private DockerHelper mockDockerHelper;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import io.opentelemetry.context.propagation.TextMapGetter;
import io.opentelemetry.context.propagation.TextMapPropagator;
import io.opentelemetry.context.propagation.TextMapSetter;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.logging.Logger;
Expand Down Expand Up @@ -80,7 +79,7 @@ public final class AwsXrayPropagator implements TextMapPropagator {
private static final String INVALID_LINEAGE = "-1:11111111:0";
private static final int NUM_OF_LINEAGE_DELIMITERS = 2;

private static final List<String> FIELDS = Collections.singletonList(TRACE_HEADER_KEY);
private static final List<String> FIELDS = singletonList(TRACE_HEADER_KEY);

private static final AwsXrayPropagator INSTANCE = new AwsXrayPropagator();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.LinkedHashMap;
import org.junit.jupiter.api.Test;

public class AwsXrayCompositePropagatorTest extends AwsXrayPropagatorTest {
class AwsXrayCompositePropagatorTest extends AwsXrayPropagatorTest {

@Override
TextMapPropagator propagator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void addLink_SystemProperty() {

assertThat(span.toSpanData().getLinks())
.isEqualTo(
Collections.singletonList(
singletonList(
LinkData.create(
SpanContext.createFromRemoteParent(
"00000001240000000000000000000001",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import io.opentelemetry.sdk.trace.samplers.Sampler;
import io.opentelemetry.sdk.trace.samplers.SamplingResult;
import java.time.Duration;
import java.util.Collections;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -84,6 +83,6 @@ private static SamplingResult doSample(Sampler sampler) {
"cat-service",
SpanKind.SERVER,
Attributes.empty(),
Collections.emptyList());
emptyList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.opentelemetry.api.common.AttributeKey;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

Expand All @@ -23,7 +22,7 @@ public class AttributePropagatingSpanProcessorBuilder {

private AttributeKey<String> spanNamePropagationKey = AwsAttributeKeys.AWS_LOCAL_OPERATION;
private List<AttributeKey<String>> attributesKeysToPropagate =
Arrays.asList(AwsAttributeKeys.AWS_REMOTE_SERVICE, AwsAttributeKeys.AWS_REMOTE_OPERATION);
asList(AwsAttributeKeys.AWS_REMOTE_SERVICE, AwsAttributeKeys.AWS_REMOTE_OPERATION);

public static AttributePropagatingSpanProcessorBuilder create() {
return new AttributePropagatingSpanProcessorBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import io.opentelemetry.sdk.trace.samplers.Sampler;
import io.opentelemetry.sdk.trace.samplers.SamplingDecision;
import io.opentelemetry.sdk.trace.samplers.SamplingResult;
import java.util.Collections;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -71,7 +70,7 @@ private void validateShouldSample(
"name",
SpanKind.CLIENT,
Attributes.empty(),
Collections.emptyList());
emptyList());

if (rootDecision.equals(expectedDecision)) {
assertThat(actualResult).isEqualTo(rootResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import io.opentelemetry.context.Context;
import io.opentelemetry.sdk.trace.ReadableSpan;
import io.opentelemetry.sdk.trace.SdkTracerProvider;
import java.util.Arrays;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -34,8 +33,7 @@ public void setup() {
tracer =
SdkTracerProvider.builder()
.addSpanProcessor(
AttributePropagatingSpanProcessor.create(
spanNameKey, Arrays.asList(testKey1, testKey2)))
AttributePropagatingSpanProcessor.create(spanNameKey, asList(testKey1, testKey2)))
.build()
.get("awsxray");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package io.opentelemetry.contrib.awsxray;

import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
Expand All @@ -23,9 +25,7 @@
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.data.StatusData;
import io.opentelemetry.sdk.trace.export.SpanExporter;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -78,7 +78,7 @@ public void testExportDelegationWithoutAttributeOrModification() {
Attributes metricAttributes = buildMetricAttributes(CONTAINS_NO_ATTRIBUTES);
configureMocksForExport(spanDataMock, metricAttributes);

awsMetricAttributesSpanExporter.export(Collections.singletonList(spanDataMock));
awsMetricAttributesSpanExporter.export(singletonList(spanDataMock));
verify(delegateMock, times(1)).export(delegateExportCaptor.capture());
Collection<SpanData> exportedSpans = delegateExportCaptor.getValue();
assertThat(exportedSpans.size()).isEqualTo(1);
Expand All @@ -94,7 +94,7 @@ public void testExportDelegationWithAttributeButWithoutModification() {
Attributes metricAttributes = buildMetricAttributes(CONTAINS_NO_ATTRIBUTES);
configureMocksForExport(spanDataMock, metricAttributes);

awsMetricAttributesSpanExporter.export(Collections.singletonList(spanDataMock));
awsMetricAttributesSpanExporter.export(singletonList(spanDataMock));
verify(delegateMock, times(1)).export(delegateExportCaptor.capture());
Collection<SpanData> exportedSpans = delegateExportCaptor.getValue();
assertThat(exportedSpans.size()).isEqualTo(1);
Expand All @@ -110,7 +110,7 @@ public void testExportDelegationWithoutAttributeButWithModification() {
Attributes metricAttributes = buildMetricAttributes(CONTAINS_ATTRIBUTES);
configureMocksForExport(spanDataMock, metricAttributes);

awsMetricAttributesSpanExporter.export(Collections.singletonList(spanDataMock));
awsMetricAttributesSpanExporter.export(singletonList(spanDataMock));
verify(delegateMock, times(1)).export(delegateExportCaptor.capture());
List<SpanData> exportedSpans = (List<SpanData>) delegateExportCaptor.getValue();
assertThat(exportedSpans.size()).isEqualTo(1);
Expand All @@ -130,7 +130,7 @@ public void testExportDelegationWithAttributeAndModification() {
Attributes metricAttributes = buildMetricAttributes(CONTAINS_ATTRIBUTES);
configureMocksForExport(spanDataMock, metricAttributes);

awsMetricAttributesSpanExporter.export(Collections.singletonList(spanDataMock));
awsMetricAttributesSpanExporter.export(singletonList(spanDataMock));
verify(delegateMock, times(1)).export(delegateExportCaptor.capture());
List<SpanData> exportedSpans = (List<SpanData>) delegateExportCaptor.getValue();
assertThat(exportedSpans.size()).isEqualTo(1);
Expand Down Expand Up @@ -162,8 +162,7 @@ public void testExportDelegationWithMultipleSpans() {
Attributes metricAttributes3 = buildMetricAttributes(CONTAINS_NO_ATTRIBUTES);
configureMocksForExport(spanDataMock3, metricAttributes3);

awsMetricAttributesSpanExporter.export(
Arrays.asList(spanDataMock1, spanDataMock2, spanDataMock3));
awsMetricAttributesSpanExporter.export(asList(spanDataMock1, spanDataMock2, spanDataMock3));
verify(delegateMock, times(1)).export(delegateExportCaptor.capture());
List<SpanData> exportedSpans = (List<SpanData>) delegateExportCaptor.getValue();
assertThat(exportedSpans.size()).isEqualTo(3);
Expand Down Expand Up @@ -201,7 +200,7 @@ public void testOverridenAttributes() {
"new value3");
configureMocksForExport(spanDataMock, metricAttributes);

awsMetricAttributesSpanExporter.export(Collections.singletonList(spanDataMock));
awsMetricAttributesSpanExporter.export(singletonList(spanDataMock));
verify(delegateMock, times(1)).export(delegateExportCaptor.capture());
List<SpanData> exportedSpans = (List<SpanData>) delegateExportCaptor.getValue();
assertThat(exportedSpans.size()).isEqualTo(1);
Expand All @@ -223,7 +222,7 @@ public void testExportDelegatingSpanDataBehaviour() {
Attributes metricAttributes = buildMetricAttributes(CONTAINS_ATTRIBUTES);
configureMocksForExport(spanDataMock, metricAttributes);

awsMetricAttributesSpanExporter.export(Collections.singletonList(spanDataMock));
awsMetricAttributesSpanExporter.export(singletonList(spanDataMock));
verify(delegateMock, times(1)).export(delegateExportCaptor.capture());
List<SpanData> exportedSpans = (List<SpanData>) delegateExportCaptor.getValue();
assertThat(exportedSpans.size()).isEqualTo(1);
Expand Down Expand Up @@ -260,11 +259,11 @@ public void testExportDelegatingSpanDataBehaviour() {
when(spanDataMock.getStartEpochNanos()).thenReturn(testStartEpochNanos);
assertThat(exportedSpan.getStartEpochNanos()).isEqualTo(testStartEpochNanos);

List<EventData> eventsMock = Collections.singletonList(mock(EventData.class));
List<EventData> eventsMock = singletonList(mock(EventData.class));
when(spanDataMock.getEvents()).thenReturn(eventsMock);
assertThat(exportedSpan.getEvents()).isEqualTo(eventsMock);

List<LinkData> linksMock = Collections.singletonList(mock(LinkData.class));
List<LinkData> linksMock = singletonList(mock(LinkData.class));
when(spanDataMock.getLinks()).thenReturn(linksMock);
assertThat(exportedSpan.getLinks()).isEqualTo(linksMock);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import io.opentelemetry.sdk.trace.data.ExceptionEventData;
import io.opentelemetry.sdk.trace.data.SpanData;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -252,7 +251,7 @@ private static ReadableSpan buildReadableSpanWithThrowableMock(Throwable throwab
InstrumentationScopeInfo awsSdkScopeInfo =
InstrumentationScopeInfo.builder("aws-sdk").setVersion("version").build();
ExceptionEventData mockEventData = mock(ExceptionEventData.class);
List<EventData> events = new ArrayList<>(Arrays.asList(mockEventData));
List<EventData> events = new ArrayList<>(asList(mockEventData));

// Configure latency
when(readableSpanMock.getLatencyNanos()).thenReturn(TEST_LATENCY_NANOS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.io.IOException;
import java.io.UncheckedIOException;
import java.time.Duration;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -213,7 +212,7 @@ private static SamplingDecision doSample(Sampler sampler, String name) {
"span",
SpanKind.SERVER,
Attributes.of(AttributeKey.stringKey("test"), name),
Collections.emptyList())
emptyList())
.getDecision();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import io.opentelemetry.sdk.trace.samplers.Sampler;
import io.opentelemetry.sdk.trace.samplers.SamplingDecision;
import io.opentelemetry.sdk.trace.samplers.SamplingResult;
import java.util.Collections;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
Expand Down Expand Up @@ -43,6 +42,6 @@ private static SamplingResult doSample(Sampler sampler) {
"span",
SpanKind.CLIENT,
Attributes.empty(),
Collections.emptyList());
emptyList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import io.opentelemetry.sdk.trace.samplers.Sampler;
import io.opentelemetry.sdk.trace.samplers.SamplingDecision;
import java.time.Duration;
import java.util.Collections;
import org.junit.jupiter.api.Test;

class RateLimitingSamplerTest {
Expand All @@ -35,7 +34,7 @@ void limitsRate() {
"span",
SpanKind.CLIENT,
Attributes.empty(),
Collections.emptyList())
emptyList())
.getDecision())
.isEqualTo(SamplingDecision.RECORD_AND_SAMPLE);
// Balanced used up
Expand All @@ -47,7 +46,7 @@ void limitsRate() {
"span",
SpanKind.CLIENT,
Attributes.empty(),
Collections.emptyList())
emptyList())
.getDecision())
.isEqualTo(SamplingDecision.DROP);

Expand All @@ -61,7 +60,7 @@ void limitsRate() {
"span",
SpanKind.CLIENT,
Attributes.empty(),
Collections.emptyList())
emptyList())
.getDecision())
.isEqualTo(SamplingDecision.DROP);
clock.advance(Duration.ofMillis(900));
Expand All @@ -74,7 +73,7 @@ void limitsRate() {
"span",
SpanKind.CLIENT,
Attributes.empty(),
Collections.emptyList())
emptyList())
.getDecision())
.isEqualTo(SamplingDecision.RECORD_AND_SAMPLE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Unit tests for {@link ResourceHolder}. Note that there isn't a great way to test the "default"
* fallback logic, as when the test suite is run, the customize logic appears to be invoked.
*/
public class ResourceHolderTest {
class ResourceHolderTest {

@Test
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import java.io.UncheckedIOException;
import java.time.Duration;
import java.time.Instant;
import java.util.Collections;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -846,7 +845,7 @@ private static SamplingResult doSample(SamplingRuleApplier applier) {
"span",
SpanKind.CLIENT,
Attributes.empty(),
Collections.emptyList());
emptyList());
}

private static GetSamplingRulesResponse.SamplingRule readSamplingRule(String resourcePath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.opentelemetry.sdk.trace.samplers.SamplingResult;
import java.time.Duration;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
Expand Down Expand Up @@ -103,7 +102,7 @@ void updateTargets() {
Resource.getDefault(),
clock,
Sampler.alwaysOn(),
Arrays.asList(rule1, rule4, rule3, rule2));
asList(rule1, rule4, rule3, rule2));

assertThat(doSample(sampler, "cat-service"))
.isEqualTo(SamplingResult.create(SamplingDecision.RECORD_AND_SAMPLE));
Expand Down Expand Up @@ -176,6 +175,6 @@ private static SamplingResult doSample(Sampler sampler, String name) {
name,
SpanKind.CLIENT,
Attributes.of(AttributeKey.stringKey("test"), name),
Collections.emptyList());
emptyList());
}
}
Loading