Skip to content

Commit e319fdd

Browse files
committed
Cleanup
1 parent 980514a commit e319fdd

File tree

4 files changed

+31
-18
lines changed

4 files changed

+31
-18
lines changed

dd-java-agent/agent-otel/otel-bootstrap/src/main/java/datadog/trace/bootstrap/otel/metrics/OtelInstrumentBuilder.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package datadog.trace.bootstrap.otel.metrics;
22

3+
import static datadog.trace.bootstrap.otel.metrics.OtelInstrumentType.OBSERVABLE_COUNTER;
4+
import static datadog.trace.bootstrap.otel.metrics.OtelInstrumentType.OBSERVABLE_GAUGE;
5+
import static datadog.trace.bootstrap.otel.metrics.OtelInstrumentType.OBSERVABLE_UP_DOWN_COUNTER;
6+
37
import javax.annotation.Nullable;
48

59
public final class OtelInstrumentBuilder {
@@ -91,11 +95,11 @@ public OtelInstrumentDescriptor observableDescriptor() {
9195
private OtelInstrumentType observableType(OtelInstrumentType instrumentType) {
9296
switch (instrumentType) {
9397
case COUNTER:
94-
return OtelInstrumentType.OBSERVABLE_COUNTER;
98+
return OBSERVABLE_COUNTER;
9599
case UP_DOWN_COUNTER:
96-
return OtelInstrumentType.OBSERVABLE_UP_DOWN_COUNTER;
100+
return OBSERVABLE_UP_DOWN_COUNTER;
97101
case GAUGE:
98-
return OtelInstrumentType.OBSERVABLE_GAUGE;
102+
return OBSERVABLE_GAUGE;
99103
default:
100104
throw new IllegalArgumentException(instrumentType + " has no observable equivalent");
101105
}

dd-java-agent/agent-otel/otel-bootstrap/src/main/java/datadog/trace/bootstrap/otel/metrics/data/OtelMetricStorage.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package datadog.trace.bootstrap.otel.metrics.data;
22

3+
import static datadog.trace.bootstrap.otel.metrics.OtelInstrumentType.COUNTER;
4+
import static datadog.trace.bootstrap.otel.metrics.OtelInstrumentType.HISTOGRAM;
5+
import static datadog.trace.bootstrap.otel.metrics.OtelInstrumentType.OBSERVABLE_COUNTER;
6+
37
import datadog.logging.RatelimitedLogger;
48
import datadog.trace.api.Config;
59
import datadog.trace.api.config.OtlpConfig;
@@ -63,12 +67,10 @@ private static boolean shouldResetOnCollect(OtelInstrumentType type) {
6367
switch (TEMPORALITY_PREFERENCE) {
6468
case DELTA:
6569
// gauges and up/down counters stay as cumulative
66-
return type == OtelInstrumentType.HISTOGRAM
67-
|| type == OtelInstrumentType.COUNTER
68-
|| type == OtelInstrumentType.OBSERVABLE_COUNTER;
70+
return type == HISTOGRAM || type == COUNTER || type == OBSERVABLE_COUNTER;
6971
case LOWMEMORY:
7072
// observable counters, gauges, and up/down counters stay as cumulative
71-
return type == OtelInstrumentType.HISTOGRAM || type == OtelInstrumentType.COUNTER;
73+
return type == HISTOGRAM || type == COUNTER;
7274
case CUMULATIVE:
7375
default:
7476
return false;

dd-trace-core/src/main/java/datadog/trace/core/otlp/common/OtlpCommonProto.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
package datadog.trace.core.otlp.common;
22

3+
import static datadog.trace.bootstrap.otlp.common.OtlpAttributeVisitor.BOOLEAN;
4+
import static datadog.trace.bootstrap.otlp.common.OtlpAttributeVisitor.BOOLEAN_ARRAY;
5+
import static datadog.trace.bootstrap.otlp.common.OtlpAttributeVisitor.DOUBLE;
6+
import static datadog.trace.bootstrap.otlp.common.OtlpAttributeVisitor.DOUBLE_ARRAY;
7+
import static datadog.trace.bootstrap.otlp.common.OtlpAttributeVisitor.LONG;
8+
import static datadog.trace.bootstrap.otlp.common.OtlpAttributeVisitor.LONG_ARRAY;
9+
import static datadog.trace.bootstrap.otlp.common.OtlpAttributeVisitor.STRING;
10+
import static datadog.trace.bootstrap.otlp.common.OtlpAttributeVisitor.STRING_ARRAY;
311
import static java.nio.charset.StandardCharsets.UTF_8;
412

513
import datadog.communication.serialization.GenerationalUtf8Cache;
@@ -8,7 +16,6 @@
816
import datadog.communication.serialization.StreamingBuffer;
917
import datadog.trace.api.Config;
1018
import datadog.trace.bootstrap.otel.common.OtelInstrumentationScope;
11-
import datadog.trace.bootstrap.otlp.common.OtlpAttributeVisitor;
1219
import java.nio.ByteBuffer;
1320
import java.util.List;
1421

@@ -149,28 +156,28 @@ public static void writeInstrumentationScope(
149156
public static void writeAttribute(StreamingBuffer buf, int type, String key, Object value) {
150157
byte[] keyUtf8 = keyUtf8(key);
151158
switch (type) {
152-
case OtlpAttributeVisitor.STRING:
159+
case STRING:
153160
writeStringAttribute(buf, keyUtf8, valueUtf8((String) value));
154161
break;
155-
case OtlpAttributeVisitor.BOOLEAN:
162+
case BOOLEAN:
156163
writeBooleanAttribute(buf, keyUtf8, (boolean) value);
157164
break;
158-
case OtlpAttributeVisitor.LONG:
165+
case LONG:
159166
writeLongAttribute(buf, keyUtf8, (long) value);
160167
break;
161-
case OtlpAttributeVisitor.DOUBLE:
168+
case DOUBLE:
162169
writeDoubleAttribute(buf, keyUtf8, (double) value);
163170
break;
164-
case OtlpAttributeVisitor.STRING_ARRAY:
171+
case STRING_ARRAY:
165172
writeStringArrayAttribute(buf, keyUtf8, (List<String>) value);
166173
break;
167-
case OtlpAttributeVisitor.BOOLEAN_ARRAY:
174+
case BOOLEAN_ARRAY:
168175
writeBooleanArrayAttribute(buf, keyUtf8, (List<Boolean>) value);
169176
break;
170-
case OtlpAttributeVisitor.LONG_ARRAY:
177+
case LONG_ARRAY:
171178
writeLongArrayAttribute(buf, keyUtf8, (List<Long>) value);
172179
break;
173-
case OtlpAttributeVisitor.DOUBLE_ARRAY:
180+
case DOUBLE_ARRAY:
174181
writeDoubleArrayAttribute(buf, keyUtf8, (List<Double>) value);
175182
break;
176183
default:

dd-trace-core/src/main/java/datadog/trace/core/otlp/common/OtlpResourceProto.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
public final class OtlpResourceProto {
1919
private OtlpResourceProto() {}
2020

21-
public static final byte[] RESOURCE_MESSAGE = buildResourceMessage(Config.get());
22-
2321
private static final Set<String> IGNORED_GLOBAL_TAGS =
2422
new HashSet<>(
2523
Arrays.asList(
@@ -30,6 +28,8 @@ private OtlpResourceProto() {}
3028
"deployment.environment.name",
3129
"service.version"));
3230

31+
public static final byte[] RESOURCE_MESSAGE = buildResourceMessage(Config.get());
32+
3333
static byte[] buildResourceMessage(Config config) {
3434
GrowableBuffer buf = new GrowableBuffer(512);
3535

0 commit comments

Comments
 (0)