@Test public void test() { String name = "TestName"; String namepace = "TestNamespace"; MetricContext context = new MetricContext.Builder("name").build(); context.addNotificationTarget(new com.google.common.base.Function<Notification, Void>() { @Nullable @Override public Void apply(@Nullable Notification input) { if (input instanceof EventNotification) { GobblinTrackingEvent event = ((EventNotification) input).getEvent(); Map<String, String> metadata = event.getMetadata(); Assert.assertEquals(event.getNamespace(), namepace); Assert.assertEquals(metadata.containsKey(GobblinEventBuilder.EVENT_TYPE), true); Assert.assertEquals(metadata.containsKey(TimingEvent.METADATA_START_TIME), true); Assert.assertEquals(metadata.containsKey(TimingEvent.METADATA_END_TIME), true); Assert.assertEquals(metadata.containsKey(TimingEvent.METADATA_DURATION), true); Assert.assertEquals(metadata.get(GobblinEventBuilder.EVENT_TYPE), TimingEvent.METADATA_TIMING_EVENT); Assert.assertEquals(event.getName(), name); } return null; } }); TimingEvent timingEvent = new TimingEvent(new EventSubmitter.Builder(context, namepace).build(), name); timingEvent.close(); }
@Override public void close() { doStop(); submitter.submit(this); }
TimingEvent extends GobblinEventBuilder implements Closeable { @Override public void close() { doStop(); submitter.submit(this); } }
TimingEvent extends GobblinEventBuilder implements Closeable { @Override public void close() { doStop(); submitter.submit(this); } TimingEvent(EventSubmitter submitter, String name); }
TimingEvent extends GobblinEventBuilder implements Closeable { @Override public void close() { doStop(); submitter.submit(this); } TimingEvent(EventSubmitter submitter, String name); void stop(); @Deprecated void stop(Map<String, String> additionalMetadata); void doStop(); @Override void close(); static boolean isTimingEvent(GobblinTrackingEvent event); static TimingEvent fromEvent(GobblinTrackingEvent event); }
TimingEvent extends GobblinEventBuilder implements Closeable { @Override public void close() { doStop(); submitter.submit(this); } TimingEvent(EventSubmitter submitter, String name); void stop(); @Deprecated void stop(Map<String, String> additionalMetadata); void doStop(); @Override void close(); static boolean isTimingEvent(GobblinTrackingEvent event); static TimingEvent fromEvent(GobblinTrackingEvent event); static final String METADATA_START_TIME; static final String METADATA_END_TIME; static final String METADATA_DURATION; static final String METADATA_TIMING_EVENT; static final String METADATA_MESSAGE; static final String JOB_ORCHESTRATED_TIME; static final String JOB_START_TIME; static final String JOB_END_TIME; }