From 0f7ad199cdf5baeea0c77b6196b3ed00f8884722 Mon Sep 17 00:00:00 2001 From: William Lo Date: Fri, 11 Aug 2023 01:05:37 -0400 Subject: [PATCH] Add namespace and use event submitter to send events --- .../gobblin/writer/InstrumentedGobblinOrcWriter.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gobblin-modules/gobblin-orc/src/main/java/org/apache/gobblin/writer/InstrumentedGobblinOrcWriter.java b/gobblin-modules/gobblin-orc/src/main/java/org/apache/gobblin/writer/InstrumentedGobblinOrcWriter.java index 4afe77d103b..c32f1e4e38a 100644 --- a/gobblin-modules/gobblin-orc/src/main/java/org/apache/gobblin/writer/InstrumentedGobblinOrcWriter.java +++ b/gobblin-modules/gobblin-orc/src/main/java/org/apache/gobblin/writer/InstrumentedGobblinOrcWriter.java @@ -29,8 +29,8 @@ import org.apache.gobblin.configuration.State; import org.apache.gobblin.instrumented.Instrumented; -import org.apache.gobblin.metrics.GobblinTrackingEvent; import org.apache.gobblin.metrics.MetricContext; +import org.apache.gobblin.metrics.event.EventSubmitter; import org.apache.gobblin.metrics.event.GobblinEventBuilder; @@ -46,6 +46,7 @@ public class InstrumentedGobblinOrcWriter extends GobblinOrcWriter { public static final String METRICS_BUFFER_RESIZES = "bufferResizes"; public static final String METRICS_BUFFER_SIZE = "bufferSize"; public static final String ORC_WRITER_METRICS_NAME = "OrcWriterMetrics"; + private static final String ORC_WRITER_NAMESPACE = "gobblin.orc.writer"; public InstrumentedGobblinOrcWriter(FsDataWriterBuilder builder, State properties) throws IOException { super(builder, properties); @@ -60,7 +61,7 @@ protected synchronized void closeInternal() throws IOException { this.orcFileWriter.close(); this.closed = true; log.info("Emitting ORC event metrics"); - this.metricContext.submitEvent(this.createOrcWriterMetadataEvent()); + this.sendOrcWriterMetadataEvent(); this.recycleRowBatchPool(); } else { // Throw fatal exception if there's outstanding buffered data since there's risk losing data if proceeds. @@ -70,8 +71,8 @@ protected synchronized void closeInternal() throws IOException { } } - GobblinTrackingEvent createOrcWriterMetadataEvent() throws IOException { - GobblinEventBuilder builder = new GobblinEventBuilder(ORC_WRITER_METRICS_NAME); + private void sendOrcWriterMetadataEvent() { + GobblinEventBuilder builder = new GobblinEventBuilder(ORC_WRITER_METRICS_NAME, ORC_WRITER_NAMESPACE); Map eventMetadataMap = Maps.newHashMap(); eventMetadataMap.put(METRICS_SCHEMA_NAME, this.inputSchema.getName()); eventMetadataMap.put(METRICS_BYTES_WRITTEN, String.valueOf(this.bytesWritten())); @@ -80,6 +81,6 @@ GobblinTrackingEvent createOrcWriterMetadataEvent() throws IOException { eventMetadataMap.put(METRICS_BUFFER_SIZE, String.valueOf(this.batchSize)); builder.addAdditionalMetadata(eventMetadataMap); - return builder.build(); + EventSubmitter.submit(metricContext, builder); } }