Skip to content

Commit d0dc9bd

Browse files
Updates based on PR review comments.
1 parent 102e185 commit d0dc9bd

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

dd-java-agent/src/main/java/datadog/trace/bootstrap/BootstrapInitializationTelemetry.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
/** Thread safe telemetry class used to relay information about tracer activation. */
1515
public abstract class BootstrapInitializationTelemetry {
16+
private static final int DEFAULT_MAX_TAGS = 5;
17+
1618
/** Returns a singleton no op instance of initialization telemetry */
1719
public static BootstrapInitializationTelemetry noOpInstance() {
1820
return NoOp.INSTANCE;
@@ -129,7 +131,7 @@ public void onError(Throwable t) {
129131
causes.add("error_type:" + t.getClass().getName());
130132

131133
// Limit the number of tags to avoid overpopulating the JSON payload.
132-
int maxTags = maxTags(5);
134+
int maxTags = maxTags();
133135
int numCauses = causes.size();
134136
if (numCauses > maxTags) {
135137
causes = causes.subList(numCauses - maxTags, numCauses);
@@ -138,16 +140,18 @@ public void onError(Throwable t) {
138140
onPoint("library_entrypoint.error", causes);
139141
}
140142

141-
private int maxTags(int defaultValue) {
142-
try {
143-
String s =
144-
EnvironmentVariables.getOrDefault(
145-
"DD_TELEMETRY_FORWARDER_MAX_TAGS", String.valueOf(defaultValue));
143+
private int maxTags() {
144+
String maxTags = EnvironmentVariables.get("DD_TELEMETRY_FORWARDER_MAX_TAGS");
146145

147-
return Integer.parseInt(s);
148-
} catch (Exception e) {
149-
return defaultValue;
146+
if (maxTags != null) {
147+
try {
148+
return Integer.parseInt(maxTags);
149+
} catch (Throwable ignore) {
150+
// Ignore and return default value.
151+
}
150152
}
153+
154+
return DEFAULT_MAX_TAGS;
151155
}
152156

153157
@Override

0 commit comments

Comments
 (0)