50
50
51
51
import java .io .Closeable ;
52
52
import java .io .IOException ;
53
+ import java .util .EnumMap ;
53
54
import java .util .List ;
54
55
import java .util .Map ;
55
56
import java .util .Optional ;
63
64
public class EventPublisher {
64
65
65
66
private static final Logger LOG = LoggerFactory .getLogger (EventPublisher .class );
66
- private static final String TAG_EVENT_TYPE = "event_type" ;
67
67
68
68
private final NakadiSettings nakadiSettings ;
69
69
@@ -286,7 +286,7 @@ private void validate(final List<BatchItem> batch, final EventType eventType, fi
286
286
throws EventValidationException , InternalNakadiException , NoSuchEventTypeException {
287
287
288
288
final Tracer .SpanBuilder validationSpan = TracingService .buildNewSpan ("validation" )
289
- .withTag (TAG_EVENT_TYPE , eventType .getName ());
289
+ .withTag (TracingService . TAG_EVENT_TYPE , eventType .getName ());
290
290
291
291
try (Closeable ignored = TracingService .withActiveSpan (validationSpan )) {
292
292
@@ -320,6 +320,7 @@ private void submit(
320
320
final List <BatchItem > batch , final EventType eventType ,
321
321
final Map <HeaderTag , String > consumerTags , final boolean delete )
322
322
throws EventPublishingException , InternalNakadiException {
323
+
323
324
final Timeline activeTimeline = timelineService .getActiveTimeline (eventType );
324
325
final String topic = activeTimeline .getTopic ();
325
326
@@ -334,10 +335,17 @@ private void submit(
334
335
335
336
final Span publishingSpan = TracingService .buildNewSpan ("publishing_to_kafka" )
336
337
.withTag (Tags .MESSAGE_BUS_DESTINATION .getKey (), topic )
337
- .withTag (TAG_EVENT_TYPE , eventType .getName ())
338
+ .withTag (TracingService . TAG_EVENT_TYPE , eventType .getName ())
338
339
.start ();
339
340
try (Closeable ignored = TracingService .activateSpan (publishingSpan )) {
340
- topicRepository .syncPostBatch (topic , batch , eventType .getName (), consumerTags , delete );
341
+ // DEBUG
342
+ final Map <HeaderTag , String > debugConsumerTags = new EnumMap <>(HeaderTag .class );
343
+ if (null != consumerTags ) {
344
+ debugConsumerTags .putAll (consumerTags );
345
+ }
346
+ debugConsumerTags .put (HeaderTag .DEBUG_PUBLISHER_TOPIC_ID , topic );
347
+ // DEBUG
348
+ topicRepository .syncPostBatch (topic , batch , eventType .getName (), debugConsumerTags , delete );
341
349
} catch (final EventPublishingException epe ) {
342
350
publishingSpan .log (epe .getMessage ());
343
351
throw epe ;
0 commit comments