1313
1414/** Thread safe telemetry class used to relay information about tracer activation. */
1515public 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