Skip to content

Commit 8559aba

Browse files
PR comments
1 parent ca11660 commit 8559aba

File tree

9 files changed

+25
-31
lines changed

9 files changed

+25
-31
lines changed

client/src/main/java/io/split/client/EventClientImpl.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static EventClientImpl create(CloseableHttpClient httpclient, URI eventsR
8989
_eventQueue = eventQueue;
9090
_waitBeforeShutdown = waitBeforeShutdown;
9191

92-
_maxQueueSize = 1;
92+
_maxQueueSize = maxQueueSize;
9393
_flushIntervalMillis = flushIntervalMillis;
9494
_telemetryRuntimeProducer = checkNotNull(telemetryRuntimeProducer);
9595

@@ -131,8 +131,7 @@ public boolean track(Event event, int eventSize) {
131131
if (event == null) {
132132
return false;
133133
}
134-
WrappedEvent we = new WrappedEvent(event, eventSize);
135-
_eventQueue.put(we);
134+
_eventQueue.put(new WrappedEvent(event, eventSize));
136135
_telemetryRuntimeProducer.recordEventStats(EventsDataRecordsEnum.EVENTS_QUEUED, 1);
137136

138137
} catch (ClassCastException | NullPointerException | InterruptedException e) {
@@ -195,9 +194,8 @@ public void run() {
195194
// Clear the queue of events for the next batch.
196195
events = new ArrayList<>();
197196
accumulated = 0;
198-
long endTime = System.currentTimeMillis();
199-
_telemetryRuntimeProducer.recordSyncLatency(HTTPLatenciesEnum.EVENTS, endTime-initTime);
200-
_telemetryRuntimeProducer.recordSuccessfulSync(LastSynchronizationRecordsEnum.EVENTS, endTime);
197+
_telemetryRuntimeProducer.recordSyncLatency(HTTPLatenciesEnum.EVENTS, System.currentTimeMillis()-initTime);
198+
_telemetryRuntimeProducer.recordSuccessfulSync(LastSynchronizationRecordsEnum.EVENTS, System.currentTimeMillis());
201199
}
202200
}
203201
} catch (InterruptedException e) {

client/src/main/java/io/split/client/HttpSegmentChangeFetcher.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.apache.hc.client5.http.classic.methods.HttpGet;
1414
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
1515
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
16+
import org.apache.hc.core5.http.HttpStatus;
1617
import org.apache.hc.core5.http.io.entity.EntityUtils;
1718
import org.apache.hc.core5.net.URIBuilder;
1819
import org.slf4j.Logger;
@@ -67,19 +68,18 @@ public SegmentChange fetch(String segmentName, long since, boolean addCacheHeade
6768

6869
int statusCode = response.getCode();
6970

70-
if (statusCode < 200 || statusCode >= 300) {
71+
if (statusCode < HttpStatus.SC_OK || statusCode >= HttpStatus.SC_MULTIPLE_CHOICES) {
7172
_telemetryRuntimeProducer.recordSyncError(ResourceEnum.SEGMENT_SYNC, statusCode);
7273
_log.error("Response status was: " + statusCode);
73-
if (statusCode == 403) {
74+
if (statusCode == HttpStatus.SC_FORBIDDEN) {
7475
_log.error("factory instantiation: you passed a browser type api_key, " +
7576
"please grab an api key from the Split console that is of type sdk");
7677
}
7778
throw new IllegalStateException("Could not retrieve segment changes for " + segmentName + "; http return code " + statusCode);
7879
}
7980

80-
long endTime = System.currentTimeMillis();
81-
_telemetryRuntimeProducer.recordSyncLatency(HTTPLatenciesEnum.SEGMENTS, endTime-start);
82-
_telemetryRuntimeProducer.recordSuccessfulSync(LastSynchronizationRecordsEnum.SEGMENTS, endTime);
81+
_telemetryRuntimeProducer.recordSyncLatency(HTTPLatenciesEnum.SEGMENTS, System.currentTimeMillis()-start);
82+
_telemetryRuntimeProducer.recordSuccessfulSync(LastSynchronizationRecordsEnum.SEGMENTS, System.currentTimeMillis());
8383

8484
String json = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
8585
if (_log.isDebugEnabled()) {

client/src/main/java/io/split/client/HttpSplitChangeFetcher.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.apache.hc.client5.http.classic.methods.HttpGet;
1414
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
1515
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
16+
import org.apache.hc.core5.http.HttpStatus;
1617
import org.apache.hc.core5.http.io.entity.EntityUtils;
1718
import org.apache.hc.core5.net.URIBuilder;
1819
import org.slf4j.Logger;
@@ -67,12 +68,11 @@ public SplitChange fetch(long since, boolean addCacheHeader) {
6768

6869
int statusCode = response.getCode();
6970

70-
if (statusCode < 200 || statusCode >= 300) {
71+
if (statusCode < HttpStatus.SC_OK || statusCode >= HttpStatus.SC_MULTIPLE_CHOICES) {
7172
_telemetryRuntimeProducer.recordSyncError(ResourceEnum.SPLIT_SYNC, statusCode);
7273
throw new IllegalStateException("Could not retrieve splitChanges; http return code " + statusCode);
7374
}
74-
long endtime = System.currentTimeMillis();
75-
_telemetryRuntimeProducer.recordSyncLatency(HTTPLatenciesEnum.SPLITS, endtime-start);
75+
_telemetryRuntimeProducer.recordSyncLatency(HTTPLatenciesEnum.SPLITS, System.currentTimeMillis()-start);
7676

7777

7878
String json = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);

client/src/main/java/io/split/client/SplitClientConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class SplitClientConfig {
2121
public static final String EVENTS_ENDPOINT = "https://events.split.io";
2222
public static final String AUTH_ENDPOINT = "https://auth.split.io/api/auth";
2323
public static final String STREAMING_ENDPOINT = "https://streaming.split.io/sse";
24-
public static final String TELEMETRY_ENDPOINT = "https://telemetry.split-stage.io/api/v1/";
24+
public static final String TELEMETRY_ENDPOINT = "https://telemetry.split.io/api/v1";
2525

2626
private final String _endpoint;
2727
private final String _eventsEndpoint;

client/src/main/java/io/split/client/SplitClientImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,7 @@ private SplitResult getTreatmentWithConfigInternal(String method, String matchin
232232
result.changeNumber,
233233
attributes
234234
);
235-
long endTime = System.currentTimeMillis();
236-
_telemetryEvaluationProducer.recordLatency(methodEnum, endTime-initTime);
235+
_telemetryEvaluationProducer.recordLatency(methodEnum, System.currentTimeMillis()-initTime);
237236
return new SplitResult(result.treatment, result.configurations);
238237
} catch (Exception e) {
239238
try {

client/src/main/java/io/split/client/SplitFactoryImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ public synchronized void destroy() {
191191
_log.info("Successful shutdown of eventClient");
192192
_syncManager.shutdown();
193193
_log.info("Successful shutdown of syncManager");
194-
long endSession = System.currentTimeMillis();
195-
_telemetryStorage.recordSessionLength(endSession - _startTime);
194+
_telemetryStorage.recordSessionLength(System.currentTimeMillis() - _startTime);
196195
_telemetrySyncTask.stopScheduledTask();
197196
} catch (IOException e) {
198197
_log.error("We could not shutdown split", e);

client/src/main/java/io/split/client/impressions/HttpImpressionsSender.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
1414
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
1515
import org.apache.hc.core5.http.HttpEntity;
16+
import org.apache.hc.core5.http.HttpStatus;
1617
import org.slf4j.Logger;
1718
import org.slf4j.LoggerFactory;
1819

@@ -73,13 +74,12 @@ public void postImpressionsBulk(List<TestImpressions> impressions) {
7374

7475
int status = response.getCode();
7576

76-
if (status < 200 || status >= 300) {
77+
if (status < HttpStatus.SC_OK || status >= HttpStatus.SC_MULTIPLE_CHOICES) {
7778
_telemetryRuntimeProducer.recordSyncError(ResourceEnum.IMPRESSION_SYNC, status);
7879
_logger.warn("Response status was: " + status);
7980
}
80-
long endTime = System.currentTimeMillis();
81-
_telemetryRuntimeProducer.recordSyncLatency(HTTPLatenciesEnum.IMPRESSIONS, endTime - initTime);
82-
_telemetryRuntimeProducer.recordSuccessfulSync(LastSynchronizationRecordsEnum.IMPRESSIONS, endTime);
81+
_telemetryRuntimeProducer.recordSyncLatency(HTTPLatenciesEnum.IMPRESSIONS, System.currentTimeMillis() - initTime);
82+
_telemetryRuntimeProducer.recordSuccessfulSync(LastSynchronizationRecordsEnum.IMPRESSIONS, System.currentTimeMillis());
8383

8484
} catch (Throwable t) {
8585
_logger.warn("Exception when posting impressions" + impressions, t);
@@ -101,13 +101,12 @@ public void postCounters(HashMap<ImpressionCounter.Key, Integer> raw) {
101101
request.setEntity(Utils.toJsonEntity(ImpressionCount.fromImpressionCounterData(raw)));
102102
try (CloseableHttpResponse response = _client.execute(request)) {
103103
int status = response.getCode();
104-
if (status < 200 || status >= 300) {
104+
if (status < HttpStatus.SC_OK || status >= HttpStatus.SC_MULTIPLE_CHOICES) {
105105
_telemetryRuntimeProducer.recordSyncError(ResourceEnum.IMPRESSION_COUNT_SYNC, status);
106106
_logger.warn("Response status was: " + status);
107107
}
108-
long endTime = System.currentTimeMillis();
109-
_telemetryRuntimeProducer.recordSyncLatency(HTTPLatenciesEnum.IMPRESSIONS_COUNT, endTime - initTime);
110-
_telemetryRuntimeProducer.recordSuccessfulSync(LastSynchronizationRecordsEnum.IMPRESSIONS_COUNT, endTime);
108+
_telemetryRuntimeProducer.recordSyncLatency(HTTPLatenciesEnum.IMPRESSIONS_COUNT, System.currentTimeMillis() - initTime);
109+
_telemetryRuntimeProducer.recordSuccessfulSync(LastSynchronizationRecordsEnum.IMPRESSIONS_COUNT, System.currentTimeMillis());
111110
} catch (IOException exc) {
112111
_logger.warn("Exception when posting impression counters: ", exc);
113112
}

client/src/main/java/io/split/client/impressions/ImpressionsManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void track(Impression impression) {
105105
}
106106

107107
if (Mode.DEBUG.equals(_mode) || shouldQueueImpression(impression)) {
108-
if (shouldQueueImpression(impression)) {
108+
if (!shouldQueueImpression(impression)) {
109109
_telemetryRuntimeProducer.recordImpressionStats(ImpressionsDataTypeEnum.IMPRESSIONS_DEDUPED, 1);
110110
}
111111
if (_storage.put(KeyImpression.fromImpression(impression))) {

client/src/main/java/io/split/engine/sse/AuthApiClientImp.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ public AuthenticationResponse Authenticate() {
4848
_log.debug(String.format("Success connection to: %s", _target));
4949

5050
String jsonContent = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
51-
long endTime = System.currentTimeMillis();
5251
_telemetryRuntimeProducer.recordTokenRefreshes();
53-
_telemetryRuntimeProducer.recordSuccessfulSync(LastSynchronizationRecordsEnum.TOKEN, endTime);
54-
_telemetryRuntimeProducer.recordSyncLatency(HTTPLatenciesEnum.TOKEN, endTime-initTime);
52+
_telemetryRuntimeProducer.recordSuccessfulSync(LastSynchronizationRecordsEnum.TOKEN, System.currentTimeMillis());
53+
_telemetryRuntimeProducer.recordSyncLatency(HTTPLatenciesEnum.TOKEN, System.currentTimeMillis()-initTime);
5554
return getSuccessResponse(jsonContent);
5655
}
5756

0 commit comments

Comments
 (0)