Skip to content

Commit 6292ec3

Browse files
committed
Apply spotless code formatting.
1 parent ef218e9 commit 6292ec3

16 files changed

+225
-43
lines changed

profiler/src/main/java/com/splunk/opentelemetry/profiler/snapshot/ActiveSpanTracker.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright Splunk Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.splunk.opentelemetry.profiler.snapshot;
218

319
import io.opentelemetry.api.trace.Span;
@@ -30,7 +46,7 @@ public Scope attach(Context toAttach) {
3046
}
3147

3248
String traceId = spanContext.getTraceId();
33-
SpanContext current = activeSpans.get(traceId);
49+
SpanContext current = activeSpans.get(traceId);
3450
if (current == spanContext) {
3551
return scope;
3652
}

profiler/src/main/java/com/splunk/opentelemetry/profiler/snapshot/InterceptingContextStorageSpanTrackingActivator.java

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright Splunk Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.splunk.opentelemetry.profiler.snapshot;
218

319
import com.google.common.annotations.VisibleForTesting;
@@ -13,16 +29,18 @@ class InterceptingContextStorageSpanTrackingActivator implements SpanTrackingAct
1329
}
1430

1531
@VisibleForTesting
16-
InterceptingContextStorageSpanTrackingActivator(Consumer<UnaryOperator<ContextStorage>> contextStorageWrappingFunction) {
32+
InterceptingContextStorageSpanTrackingActivator(
33+
Consumer<UnaryOperator<ContextStorage>> contextStorageWrappingFunction) {
1734
this.contextStorageWrappingFunction = contextStorageWrappingFunction;
1835
}
1936

2037
@Override
2138
public void activate(TraceRegistry registry) {
22-
contextStorageWrappingFunction.accept(contextStorage -> {
23-
ActiveSpanTracker tracker = new ActiveSpanTracker(contextStorage, registry);
24-
SpanTrackerProvider.INSTANCE.configure(tracker);
25-
return tracker;
26-
});
39+
contextStorageWrappingFunction.accept(
40+
contextStorage -> {
41+
ActiveSpanTracker tracker = new ActiveSpanTracker(contextStorage, registry);
42+
SpanTrackerProvider.INSTANCE.configure(tracker);
43+
return tracker;
44+
});
2745
}
2846
}

profiler/src/main/java/com/splunk/opentelemetry/profiler/snapshot/ScheduledExecutorStackTraceSampler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ class ScheduledExecutorStackTraceSampler implements StackTraceSampler {
4343
private final Supplier<SpanTracker> spanTracker;
4444
private final Duration samplingPeriod;
4545

46-
ScheduledExecutorStackTraceSampler(StagingArea stagingArea, Supplier<SpanTracker> spanTracker, Duration samplingPeriod) {
46+
ScheduledExecutorStackTraceSampler(
47+
StagingArea stagingArea, Supplier<SpanTracker> spanTracker, Duration samplingPeriod) {
4748
this.stagingArea = stagingArea;
4849
this.spanTracker = spanTracker;
4950
this.samplingPeriod = samplingPeriod;
@@ -91,7 +92,8 @@ public void run() {
9192
Instant now = Instant.now();
9293
ThreadInfo threadInfo = threadMXBean.getThreadInfo(threadId, Integer.MAX_VALUE);
9394
SpanContext spanContext = retrieveActiveSpan(traceId);
94-
StackTrace stackTrace = StackTrace.from(now, samplingPeriod, threadInfo, traceId, spanContext.getSpanId());
95+
StackTrace stackTrace =
96+
StackTrace.from(now, samplingPeriod, threadInfo, traceId, spanContext.getSpanId());
9597
stagingArea.stage(traceId, stackTrace);
9698
} catch (Exception e) {
9799
logger.log(Level.SEVERE, e, samplerErrorMessage(traceId, threadId));

profiler/src/main/java/com/splunk/opentelemetry/profiler/snapshot/SnapshotProfilingSdkCustomizer.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ public class SnapshotProfilingSdkCustomizer implements AutoConfigurationCustomiz
3838
private final SpanTrackingActivator spanTrackingActivator;
3939

4040
public SnapshotProfilingSdkCustomizer() {
41-
this(new TraceRegistry(), stackTraceSamplerProvider(), new InterceptingContextStorageSpanTrackingActivator());
41+
this(
42+
new TraceRegistry(),
43+
stackTraceSamplerProvider(),
44+
new InterceptingContextStorageSpanTrackingActivator());
4245
}
4346

4447
private static Function<ConfigProperties, StackTraceSampler> stackTraceSamplerProvider() {
@@ -119,7 +122,8 @@ private boolean includeTraceContextPropagator(Set<String> configuredPropagators)
119122
return configuredPropagators.isEmpty();
120123
}
121124

122-
private Function<ConfigProperties, Map<String, String>> startTrackingActiveSpans(TraceRegistry registry) {
125+
private Function<ConfigProperties, Map<String, String>> startTrackingActiveSpans(
126+
TraceRegistry registry) {
123127
return properties -> {
124128
if (snapshotProfilingEnabled(properties)) {
125129
spanTrackingActivator.activate(registry);

profiler/src/main/java/com/splunk/opentelemetry/profiler/snapshot/SpanTracker.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright Splunk Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.splunk.opentelemetry.profiler.snapshot;
218

319
import io.opentelemetry.api.trace.SpanContext;

profiler/src/main/java/com/splunk/opentelemetry/profiler/snapshot/SpanTrackerProvider.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
1+
/*
2+
* Copyright Splunk Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.splunk.opentelemetry.profiler.snapshot;
218

319
import java.util.Objects;
420
import java.util.function.Supplier;
521

622
class SpanTrackerProvider implements Supplier<SpanTracker> {
7-
public static final SpanTrackerProvider INSTANCE = new SpanTrackerProvider();
23+
public static final SpanTrackerProvider INSTANCE = new SpanTrackerProvider();
824

925
private SpanTracker tracker = SpanTracker.NOOP;
1026

profiler/src/main/java/com/splunk/opentelemetry/profiler/snapshot/SpanTrackingActivator.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright Splunk Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.splunk.opentelemetry.profiler.snapshot;
218

319
interface SpanTrackingActivator {

profiler/src/main/java/com/splunk/opentelemetry/profiler/snapshot/StackTrace.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
import java.time.Instant;
2323

2424
class StackTrace {
25-
static StackTrace from(Instant timestamp, Duration duration, ThreadInfo thread, String traceId, String spanId) {
25+
static StackTrace from(
26+
Instant timestamp, Duration duration, ThreadInfo thread, String traceId, String spanId) {
2627
return new StackTrace(
2728
timestamp,
2829
duration,
@@ -31,8 +32,7 @@ static StackTrace from(Instant timestamp, Duration duration, ThreadInfo thread,
3132
thread.getThreadState(),
3233
thread.getStackTrace(),
3334
traceId,
34-
spanId
35-
);
35+
spanId);
3636
}
3737

3838
private final Instant timestamp;

profiler/src/test/java/com/splunk/opentelemetry/profiler/snapshot/ActiveSpanTrackerTest.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright Splunk Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.splunk.opentelemetry.profiler.snapshot;
218

319
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -95,7 +111,8 @@ void restoreActiveSpanToPreviousSpanAfterScopeClosing() {
95111
scope.close();
96112

97113
var rootSpanContext = root.getSpanContext();
98-
assertEquals(Optional.of(rootSpanContext), spanTracker.getActiveSpan(rootSpanContext.getTraceId()));
114+
assertEquals(
115+
Optional.of(rootSpanContext), spanTracker.getActiveSpan(rootSpanContext.getTraceId()));
99116
}
100117
}
101118

@@ -108,7 +125,7 @@ void trackActiveSpanForMultipleTraces() throws Exception {
108125
registry.register(root2.getSpanContext());
109126

110127
try (var ignoredScope1 = executor.submit(attach(root1)).get();
111-
var ignoredScope2 = executor.submit(attach(root2)).get()) {
128+
var ignoredScope2 = executor.submit(attach(root2)).get()) {
112129
var traceId1 = root1.getSpanContext().getTraceId();
113130
assertEquals(Optional.of(root1.getSpanContext()), spanTracker.getActiveSpan(traceId1));
114131
var traceId2 = root2.getSpanContext().getTraceId();
@@ -167,7 +184,9 @@ void doNotTrackContinuallyTrackSameSpan() {
167184
try (var ignored = spanTracker.attach(context)) {
168185
var newContext = context.with(ContextKey.named("test-key"), "value");
169186
try (var scope = spanTracker.attach(newContext)) {
170-
assertEquals("io.opentelemetry.context.ThreadLocalContextStorage$ScopeImpl", scope.getClass().getName());
187+
assertEquals(
188+
"io.opentelemetry.context.ThreadLocalContextStorage$ScopeImpl",
189+
scope.getClass().getName());
171190
}
172191
}
173192
}

profiler/src/test/java/com/splunk/opentelemetry/profiler/snapshot/InMemorySpanTracker.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1+
/*
2+
* Copyright Splunk Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.splunk.opentelemetry.profiler.snapshot;
218

319
import io.opentelemetry.api.trace.SpanContext;
4-
520
import java.util.HashMap;
621
import java.util.Map;
722
import java.util.Optional;

0 commit comments

Comments
 (0)