Skip to content

Commit

Permalink
refactor(telemetry): modify Telemetry capacity default value
Browse files Browse the repository at this point in the history
  • Loading branch information
christianbuon committed Oct 1, 2024
1 parent 5540c08 commit 9968f7c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,11 @@ public class ConfigBuilder {

protected boolean truncateLargePayloads;

private int maximumTelemetryData = DEFAULT_CAPACITY_FOR_TELEMETRY_EVENTS;
private int maximumTelemetryData =
RollbarTelemetryEventTracker.MAXIMUM_CAPACITY_FOR_TELEMETRY_EVENTS;

private TelemetryEventTracker telemetryEventTracker;

private static final int MINIMUM_CAPACITY_FOR_TELEMETRY_EVENTS = 1;

private static final int DEFAULT_CAPACITY_FOR_TELEMETRY_EVENTS = 10;

private static final int MAXIMUM_CAPACITY_FOR_TELEMETRY_EVENTS = 50;

/**
* Constructor with an access token.
*/
Expand Down Expand Up @@ -487,23 +482,13 @@ public ConfigBuilder truncateLargePayloads(boolean truncate) {

/**
* <p>
* Maximum Telemetry Events sent in a payload (This value can be between 1 and 50, exceed any of
* these thresholds and the closest will be taken). Default: 10.
* Maximum Telemetry Events sent in a payload. Default is
* {@value RollbarTelemetryEventTracker#MAXIMUM_CAPACITY_FOR_TELEMETRY_EVENTS}.
* </p>
* @param maximumTelemetryData max quantity of telemetry events sent.
* @return the builder instance.
*/
public ConfigBuilder maximumTelemetryData(int maximumTelemetryData) {
if (maximumTelemetryData < MINIMUM_CAPACITY_FOR_TELEMETRY_EVENTS) {
this.maximumTelemetryData = MINIMUM_CAPACITY_FOR_TELEMETRY_EVENTS;
return this;
}

if (maximumTelemetryData > MAXIMUM_CAPACITY_FOR_TELEMETRY_EVENTS) {
this.maximumTelemetryData = MAXIMUM_CAPACITY_FOR_TELEMETRY_EVENTS;
return this;
}

this.maximumTelemetryData = maximumTelemetryData;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* Default {@link TelemetryEventTracker}.
*/
public class RollbarTelemetryEventTracker implements TelemetryEventTracker {
public static final int MAXIMUM_CAPACITY_FOR_TELEMETRY_EVENTS = 100;
private final int maximumTelemetryData;
private final Queue<TelemetryEvent> telemetryEvents = new ConcurrentLinkedQueue<>();
private final Provider<Long> timestampProvider;
Expand All @@ -27,7 +28,6 @@ public class RollbarTelemetryEventTracker implements TelemetryEventTracker {
private static final String NETWORK_KEY_URL = "url";
private static final String NETWORK_KEY_STATUS_CODE = "status_code";
private static final int NO_CAPACITY = 0;
private static final int MAXIMUM_CAPACITY_FOR_TELEMETRY_EVENTS = 100;

/**
* Construct a {@link RollbarTelemetryEventTracker}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class ConfigBuilderTest {

static final String FRAMEWORK = "framework";

private static final int DEFAULT_CAPACITY_FOR_TELEMETRY_EVENTS = 10;
private static final int DEFAULT_CAPACITY_FOR_TELEMETRY_EVENTS = 100;

@Rule
public MockitoRule rule = MockitoJUnit.rule();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public final class ConfigBuilder {
private boolean enabled;
private DefaultLevels defaultLevels;
private boolean truncateLargePayloads;
private int maximumTelemetryData = DEFAULT_CAPACITY_FOR_TELEMETRY_EVENTS;
private int maximumTelemetryData =
RollbarTelemetryEventTracker.MAXIMUM_CAPACITY_FOR_TELEMETRY_EVENTS;
private TelemetryEventTracker telemetryEventTracker;
private static final int DEFAULT_CAPACITY_FOR_TELEMETRY_EVENTS = 10;


/**
Expand Down Expand Up @@ -471,9 +471,8 @@ public ConfigBuilder truncateLargePayloads(boolean truncate) {

/**
* <p>
* Maximum Telemetry Events sent in a payload (can be overwritten if the
* {@link TelemetryEventTracker} has thresholds like the {@link RollbarTelemetryEventTracker}).
* Default: 10.
* Maximum Telemetry Events sent in a payload. Default is
* {@value RollbarTelemetryEventTracker#MAXIMUM_CAPACITY_FOR_TELEMETRY_EVENTS}.
* </p>
* @param maximumTelemetryData max quantity of telemetry events sent.
* @return the builder instance.
Expand Down

0 comments on commit 9968f7c

Please sign in to comment.