Skip to content

Commit a9bc92f

Browse files
committed
fixup bug in WithSpanInterceptor
1 parent 777714e commit a9bc92f

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

src/main/java/no/ssb/dlp/pseudo/service/accessgroups/CloudIdentityService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package no.ssb.dlp.pseudo.service.accessgroups;
22

33
import io.micronaut.cache.annotation.Cacheable;
4-
import io.opentelemetry.api.trace.Span;
54
import io.reactivex.Flowable;
65
import jakarta.inject.Singleton;
76
import lombok.RequiredArgsConstructor;

src/main/java/no/ssb/dlp/pseudo/service/tracing/WithSpanContext.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
public final class WithSpanContext {
1414
private static final ContextKey<Span> WITH_SPAN_KEY = ContextKey.named("pseudo.withspan.span");
1515

16+
private WithSpanContext(){ }
17+
1618
public static Span currentSpan() {
1719
Span span = Context.current().get(WITH_SPAN_KEY);
1820
return span != null ? span : Span.current();

src/main/java/no/ssb/dlp/pseudo/service/tracing/WithSpanInterceptor.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,18 @@ private static void addSpanAttributes(Span span, MethodInvocationContext<Object,
110110
}
111111
}
112112

113-
private static void setAttribute(Span span, String name, Object value) {
113+
private static void setAttribute(Span span, String attributeName, Object value) {
114114
switch (value) {
115-
case String stringValue -> span.setAttribute(name, stringValue);
116-
case Boolean booleanValue -> span.setAttribute(name, booleanValue);
117-
case Long longValue -> span.setAttribute(name, longValue);
118-
case Integer intValue -> span.setAttribute(name, intValue.longValue());
119-
case Short shortValue -> span.setAttribute(name, shortValue.longValue());
120-
case Byte byteValue -> span.setAttribute(name, byteValue.longValue());
121-
case Double doubleValue -> span.setAttribute(name, doubleValue);
122-
case Float floatValue -> span.setAttribute(name, floatValue.doubleValue());
123-
case Character charValue -> span.setAttribute(name, String.valueOf(charValue));
124-
default -> span.setAttribute(name, String.valueOf(value));
115+
case String stringValue -> span.setAttribute(attributeName, stringValue);
116+
case Boolean booleanValue -> span.setAttribute(attributeName, booleanValue);
117+
case Long longValue -> span.setAttribute(attributeName, longValue);
118+
case Integer intValue -> span.setAttribute(attributeName, intValue.longValue());
119+
case Short shortValue -> span.setAttribute(attributeName, shortValue.longValue());
120+
case Byte byteValue -> span.setAttribute(attributeName, byteValue.longValue());
121+
case Double doubleValue -> span.setAttribute(attributeName, doubleValue);
122+
case Float floatValue -> span.setAttribute(attributeName, floatValue.doubleValue());
123+
case Character charValue -> span.setAttribute(attributeName, String.valueOf(charValue));
124+
case null, default -> span.setAttribute(attributeName, String.valueOf(value));
125125
}
126126
}
127127
}

0 commit comments

Comments
 (0)