Search in sources :

Example 1 with NakadiKpiPublisher

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));
}
Also used : JSONObject(org.json.JSONObject) NakadiKpiPublisher(org.zalando.nakadi.service.NakadiKpiPublisher) ZkSubscriptionClient(org.zalando.nakadi.service.subscription.zk.ZkSubscriptionClient) Client(org.zalando.nakadi.security.Client)

Aggregations

JSONObject (org.json.JSONObject)1 Client (org.zalando.nakadi.security.Client)1 NakadiKpiPublisher (org.zalando.nakadi.service.NakadiKpiPublisher)1 ZkSubscriptionClient (org.zalando.nakadi.service.subscription.zk.ZkSubscriptionClient)1