use of org.zalando.nakadi.service.NakadiKpiPublisher in project nakadi by zalando.
the class StreamingState method publishKpi.
private void publishKpi(final String eventTypeName) {
final Client client = getContext().getParameters().getConsumingClient();
final NakadiKpiPublisher kpiPublisher = getContext().getKpiPublisher();
final long bytes = kpiDataPerEventType.get(eventTypeName).getAndResetBytesSent();
final long count = kpiDataPerEventType.get(eventTypeName).getAndResetNumberOfEventsSent();
final String appNameHashed = kpiPublisher.hash(client.getClientId());
getLog().info("[SLO] [streamed-data] api={} eventTypeName={} app={} appHashed={} " + "numberOfEvents={} bytesStreamed={} subscription={}", "hila", eventTypeName, client.getClientId(), appNameHashed, count, bytes, getContext().getSubscription().getId());
kpiPublisher.publish(getContext().getKpiDataStreamedEventType(), () -> new JSONObject().put("api", "hila").put("subscription", getContext().getSubscription().getId()).put("event_type", eventTypeName).put("app", client.getClientId()).put("app_hashed", appNameHashed).put("token_realm", client.getRealm()).put("number_of_events", count).put("bytes_streamed", bytes));
}
Aggregations