Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
Move setting of number_of_events tag to controller (#1555)
Browse files Browse the repository at this point in the history
Turns out we don't always have the span in the binary publisher (due to it
being used for internal KPI events publishing).
  • Loading branch information
a1exsh authored Oct 6, 2023
1 parent 7e878e8 commit 26c5662
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ private ResponseEntity postBinaryEvents(final String eventTypeName,
"publishing record result can not be empty");
}
final EventPublishResult result = publishingResultConverter.mapPublishingResultToView(recordResults);
final int eventCount = result.getResponses().size();

final int eventCount = nakadiRecords.size();
TracingService.setTag("number_of_events", eventCount);

final long totalSizeBytes = countingInputStream.getCount();
TracingService.setTag("slo_bucket", TracingService.getSLOBucketName(totalSizeBytes));
Expand Down Expand Up @@ -264,11 +266,14 @@ private ResponseEntity postEventInternal(final String eventTypeName,
} else {
result = publisher.publish(eventsAsString, eventTypeName, consumerTags);
}
// FIXME: there should be a more direct way to get the input batch size
final int eventCount = result.getResponses().size();

reportMetrics(eventTypeMetrics, result, totalSizeBytes, eventCount);
reportSLOs(startingNanos, totalSizeBytes, eventCount, result, eventTypeName, client);

TracingService.setTag("number_of_events", eventCount);

if (result.getStatus() == EventPublishingStatus.FAILED) {
TracingService.setErrorFlag();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ private List<NakadiRecordResult> processInternal(final EventType eventType,
final List<NakadiRecord> records,
final List<Check> checks,
final Map<HeaderTag, String> consumerTags) {

TracingService.setTag("number_of_events", records.size());

for (final Check check : checks) {
final List<NakadiRecordResult> res = check.execute(eventType, records);
if (res != null && !res.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ EventPublishResult processInternal(final String events,

Closeable publishingCloser = null;
final List<BatchItem> batch = BatchFactory.from(events);

TracingService.setTag("number_of_events", batch.size());

try {
publishingCloser = timelineSync.workWithEventType(eventTypeName, nakadiSettings.getTimelineWaitTimeoutMs());

Expand Down

0 comments on commit 26c5662

Please sign in to comment.