1717
1818import static io .aklivity .zilla .runtime .binding .kafka .internal .types .event .KafkaEventType .API_VERSION_REJECTED ;
1919import static io .aklivity .zilla .runtime .binding .kafka .internal .types .event .KafkaEventType .AUTHORIZATION_FAILED ;
20+ import static io .aklivity .zilla .runtime .binding .kafka .internal .types .event .KafkaEventType .BROKER_CONNECTION_FAILED ;
2021import static io .aklivity .zilla .runtime .binding .kafka .internal .types .event .KafkaEventType .CLUSTER_AUTHORIZATION_FAILED ;
22+ import static io .aklivity .zilla .runtime .binding .kafka .internal .types .event .KafkaEventType .GROUP_AUTHORIZATION_FAILED ;
23+ import static io .aklivity .zilla .runtime .binding .kafka .internal .types .event .KafkaEventType .OFFSET_COMMIT_FAILED ;
24+ import static io .aklivity .zilla .runtime .binding .kafka .internal .types .event .KafkaEventType .PRODUCE_ERROR ;
2125import static io .aklivity .zilla .runtime .binding .kafka .internal .types .event .KafkaEventType .SASL_AUTHENTICATION_FAILED ;
2226import static io .aklivity .zilla .runtime .binding .kafka .internal .types .event .KafkaEventType .TOPIC_AUTHORIZATION_FAILED ;
27+ import static io .aklivity .zilla .runtime .binding .kafka .internal .types .event .KafkaEventType .TRANSACTIONAL_ID_AUTHORIZATION_FAILED ;
28+ import static io .aklivity .zilla .runtime .binding .kafka .internal .types .event .KafkaEventType .UNSUPPORTED_SASL_MECHANISM ;
2329
2430import java .nio .ByteBuffer ;
2531import java .time .Clock ;
@@ -47,6 +53,12 @@ public class KafkaEventContext
4753 private final int clusterAuthorizationFailedEventId ;
4854 private final int topicAuthorizationFailedEventId ;
4955 private final int saslAuthenticationFailedEventId ;
56+ private final int brokerConnectionFailedEventId ;
57+ private final int produceErrorEventId ;
58+ private final int groupAuthorizationFailedEventId ;
59+ private final int transactionalIdAuthorizationFailedEventId ;
60+ private final int unsupportedSaslMechanismEventId ;
61+ private final int offsetCommitFailedEventId ;
5062 private final MessageConsumer eventWriter ;
5163 private final Clock clock ;
5264
@@ -59,6 +71,13 @@ public KafkaEventContext(
5971 this .clusterAuthorizationFailedEventId = context .supplyEventId ("binding.kafka.cluster.authorization.failed" );
6072 this .topicAuthorizationFailedEventId = context .supplyEventId ("binding.kafka.topic.authorization.failed" );
6173 this .saslAuthenticationFailedEventId = context .supplyEventId ("binding.kafka.sasl.authentication.failed" );
74+ this .brokerConnectionFailedEventId = context .supplyEventId ("binding.kafka.broker.connection.failed" );
75+ this .produceErrorEventId = context .supplyEventId ("binding.kafka.produce.error" );
76+ this .groupAuthorizationFailedEventId = context .supplyEventId ("binding.kafka.group.authorization.failed" );
77+ this .transactionalIdAuthorizationFailedEventId =
78+ context .supplyEventId ("binding.kafka.transactional.id.authorization.failed" );
79+ this .unsupportedSaslMechanismEventId = context .supplyEventId ("binding.kafka.unsupported.sasl.mechanism" );
80+ this .offsetCommitFailedEventId = context .supplyEventId ("binding.kafka.offset.commit.failed" );
6281 this .eventWriter = context .supplyEventWriter ();
6382 this .clock = context .clock ();
6483 }
@@ -195,4 +214,158 @@ public void saslAuthenticationFailed(
195214 .build ();
196215 eventWriter .accept (kafkaTypeId , event .buffer (), event .offset (), event .limit ());
197216 }
217+
218+ public void brokerConnectionFailed (
219+ long traceId ,
220+ long bindingId ,
221+ String host ,
222+ int port )
223+ {
224+ KafkaEventExFW extension = kafkaEventExRW
225+ .wrap (extensionBuffer , 0 , extensionBuffer .capacity ())
226+ .brokerConnectionFailed (e -> e
227+ .typeId (BROKER_CONNECTION_FAILED .value ())
228+ .host (host )
229+ .port (port )
230+ )
231+ .build ();
232+ EventFW event = eventRW
233+ .wrap (eventBuffer , 0 , eventBuffer .capacity ())
234+ .id (brokerConnectionFailedEventId )
235+ .timestamp (clock .millis ())
236+ .traceId (traceId )
237+ .namespacedId (bindingId )
238+ .extension (extension .buffer (), extension .offset (), extension .limit ())
239+ .build ();
240+ eventWriter .accept (kafkaTypeId , event .buffer (), event .offset (), event .limit ());
241+ }
242+
243+ public void produceError (
244+ long traceId ,
245+ long bindingId ,
246+ int apiKey ,
247+ int apiVersion ,
248+ int errorCode ,
249+ String topic )
250+ {
251+ KafkaEventExFW extension = kafkaEventExRW
252+ .wrap (extensionBuffer , 0 , extensionBuffer .capacity ())
253+ .produceError (e -> e
254+ .typeId (PRODUCE_ERROR .value ())
255+ .apiKey (apiKey )
256+ .apiVersion (apiVersion )
257+ .errorCode (errorCode )
258+ .topic (topic )
259+ )
260+ .build ();
261+ EventFW event = eventRW
262+ .wrap (eventBuffer , 0 , eventBuffer .capacity ())
263+ .id (produceErrorEventId )
264+ .timestamp (clock .millis ())
265+ .traceId (traceId )
266+ .namespacedId (bindingId )
267+ .extension (extension .buffer (), extension .offset (), extension .limit ())
268+ .build ();
269+ eventWriter .accept (kafkaTypeId , event .buffer (), event .offset (), event .limit ());
270+ }
271+
272+ public void groupAuthorizationFailed (
273+ long traceId ,
274+ long bindingId ,
275+ int apiKey ,
276+ int apiVersion )
277+ {
278+ KafkaEventExFW extension = kafkaEventExRW
279+ .wrap (extensionBuffer , 0 , extensionBuffer .capacity ())
280+ .groupAuthorizationFailed (e -> e
281+ .typeId (GROUP_AUTHORIZATION_FAILED .value ())
282+ .apiKey (apiKey )
283+ .apiVersion (apiVersion )
284+ )
285+ .build ();
286+ EventFW event = eventRW
287+ .wrap (eventBuffer , 0 , eventBuffer .capacity ())
288+ .id (groupAuthorizationFailedEventId )
289+ .timestamp (clock .millis ())
290+ .traceId (traceId )
291+ .namespacedId (bindingId )
292+ .extension (extension .buffer (), extension .offset (), extension .limit ())
293+ .build ();
294+ eventWriter .accept (kafkaTypeId , event .buffer (), event .offset (), event .limit ());
295+ }
296+
297+ public void transactionalIdAuthorizationFailed (
298+ long traceId ,
299+ long bindingId ,
300+ int apiKey ,
301+ int apiVersion )
302+ {
303+ KafkaEventExFW extension = kafkaEventExRW
304+ .wrap (extensionBuffer , 0 , extensionBuffer .capacity ())
305+ .transactionalIdAuthorizationFailed (e -> e
306+ .typeId (TRANSACTIONAL_ID_AUTHORIZATION_FAILED .value ())
307+ .apiKey (apiKey )
308+ .apiVersion (apiVersion )
309+ )
310+ .build ();
311+ EventFW event = eventRW
312+ .wrap (eventBuffer , 0 , eventBuffer .capacity ())
313+ .id (transactionalIdAuthorizationFailedEventId )
314+ .timestamp (clock .millis ())
315+ .traceId (traceId )
316+ .namespacedId (bindingId )
317+ .extension (extension .buffer (), extension .offset (), extension .limit ())
318+ .build ();
319+ eventWriter .accept (kafkaTypeId , event .buffer (), event .offset (), event .limit ());
320+ }
321+
322+ public void unsupportedSaslMechanism (
323+ long traceId ,
324+ long bindingId ,
325+ String mechanism )
326+ {
327+ KafkaEventExFW extension = kafkaEventExRW
328+ .wrap (extensionBuffer , 0 , extensionBuffer .capacity ())
329+ .unsupportedSaslMechanism (e -> e
330+ .typeId (UNSUPPORTED_SASL_MECHANISM .value ())
331+ .mechanism (mechanism )
332+ )
333+ .build ();
334+ EventFW event = eventRW
335+ .wrap (eventBuffer , 0 , eventBuffer .capacity ())
336+ .id (unsupportedSaslMechanismEventId )
337+ .timestamp (clock .millis ())
338+ .traceId (traceId )
339+ .namespacedId (bindingId )
340+ .extension (extension .buffer (), extension .offset (), extension .limit ())
341+ .build ();
342+ eventWriter .accept (kafkaTypeId , event .buffer (), event .offset (), event .limit ());
343+ }
344+
345+ public void offsetCommitFailed (
346+ long traceId ,
347+ long bindingId ,
348+ int apiKey ,
349+ int apiVersion ,
350+ int errorCode )
351+ {
352+ KafkaEventExFW extension = kafkaEventExRW
353+ .wrap (extensionBuffer , 0 , extensionBuffer .capacity ())
354+ .offsetCommitFailed (e -> e
355+ .typeId (OFFSET_COMMIT_FAILED .value ())
356+ .apiKey (apiKey )
357+ .apiVersion (apiVersion )
358+ .errorCode (errorCode )
359+ )
360+ .build ();
361+ EventFW event = eventRW
362+ .wrap (eventBuffer , 0 , eventBuffer .capacity ())
363+ .id (offsetCommitFailedEventId )
364+ .timestamp (clock .millis ())
365+ .traceId (traceId )
366+ .namespacedId (bindingId )
367+ .extension (extension .buffer (), extension .offset (), extension .limit ())
368+ .build ();
369+ eventWriter .accept (kafkaTypeId , event .buffer (), event .offset (), event .limit ());
370+ }
198371}
0 commit comments