/** * Submit the event */ public void submit(MetricContext context) { context.submitEvent(build()); } }
/** * Submits the {@link org.apache.gobblin.metrics.GobblinTrackingEvent} to the {@link org.apache.gobblin.metrics.MetricContext}. * @param name Name of the event. * @param additionalMetadata Additional metadata to be added to the event. */ public void submit(String name, Map<String, String> additionalMetadata) { if(this.metricContext.isPresent()) { Map<String, String> finalMetadata = Maps.newHashMap(this.metadata); if(!additionalMetadata.isEmpty()) { finalMetadata.putAll(additionalMetadata); } // Timestamp is set by metric context. this.metricContext.get().submitEvent(new GobblinTrackingEvent(0l, this.namespace, name, finalMetadata)); } }
private void submitTrackingEvent(URI jobSpecURI, String jobSpecVersion, String operType) { GobblinTrackingEvent e = GobblinTrackingEvent.newBuilder() .setName(TRACKING_EVENT_NAME) .setNamespace(JobCatalog.class.getName()) .setMetadata(ImmutableMap.<String, String>builder() .put(GobblinMetricsKeys.OPERATION_TYPE_META, operType) .put(GobblinMetricsKeys.JOB_SPEC_URI_META, jobSpecURI.toString()) .put(GobblinMetricsKeys.JOB_SPEC_VERSION_META, jobSpecVersion) .build()) .build(); this.metricsContext.submitEvent(e); }
private void submitTrackingEvent(URI specSpecURI, String specSpecVersion, String operType) { GobblinTrackingEvent e = GobblinTrackingEvent.newBuilder() .setName(TRACKING_EVENT_NAME) .setNamespace(SpecCatalog.class.getName()) .setMetadata(ImmutableMap.<String, String>builder() .put(GobblinMetricsKeys.OPERATION_TYPE_META, operType) .put(GobblinMetricsKeys.SPEC_URI_META, specSpecURI.toString()) .put(GobblinMetricsKeys.SPEC_VERSION_META, specSpecVersion) .build()) .build(); this.metricsContext.submitEvent(e); }
private void submitUnfulfilledRequestEventsHelper(List<FileSet<CopyEntity>> fileSetList, String eventName) { for (FileSet<CopyEntity> fileSet : fileSetList) { GobblinTrackingEvent event = GobblinTrackingEvent.newBuilder().setName(eventName).setNamespace(CopySource.class.getName()).setMetadata( ImmutableMap.<String, String>builder() .put(ConfigurationKeys.DATASET_URN_KEY, fileSet.getDataset().getUrn()) .put(FILESET_TOTAL_ENTITIES, Integer.toString(fileSet.getTotalEntities())) .put(FILESET_TOTAL_SIZE_IN_BYTES, Long.toString(fileSet.getTotalSizeInBytes())) .put(FILESET_NAME, fileSet.getName()).build()).build(); this.metricContext.submitEvent(event); } }
@Override public R2ResponseStatus handleResponse(Request<RestRequest> request, RestResponse response) { R2ResponseStatus status = new R2ResponseStatus(StatusType.OK); int statusCode = response.getStatus(); status.setStatusCode(statusCode); HttpUtils.updateStatusType(status, statusCode, errorCodeWhitelist); if (status.getType() == StatusType.OK) { status.setContent(response.getEntity()); status.setContentType(response.getHeader(CONTENT_TYPE_HEADER)); } else { log.info("Receive an unsuccessful response with status code: " + statusCode); Map<String, String> metadata = Maps.newHashMap(); metadata.put(HttpConstants.STATUS_CODE, String.valueOf(statusCode)); metadata.put(HttpConstants.REQUEST, request.toString()); if (status.getType() != StatusType.CONTINUE) { FailureEventBuilder failureEvent = new FailureEventBuilder(R2_FAILED_REQUEST_EVENT); failureEvent.addAdditionalMetadata(metadata); failureEvent.submit(metricsContext); } else { GobblinTrackingEvent event = new GobblinTrackingEvent(0L, R2_RESPONSE_EVENT_NAMESPACE, R2_FAILED_REQUEST_EVENT, metadata); metricsContext.submitEvent(event); } } return status; } }
testContext.submitEvent(event); verify(fs, never()).append(failureLogPath); verify(outputStream, never()).write(anyByte());
context.submitEvent(event);
@Test public void testSimpleEvent() throws IOException { try ( MetricContext metricContext = MetricContext.builder(this.getClass().getCanonicalName() + ".testGraphiteReporter1").build(); GraphiteEventReporter graphiteEventReporter = getBuilder(metricContext).withEmitValueAsKey(false).build();) { Map<String, String> metadata = Maps.newHashMap(); metadata.put(JobEvent.METADATA_JOB_ID, "job1"); metadata.put(TaskEvent.METADATA_TASK_ID, "task1"); metricContext.submitEvent(GobblinTrackingEvent.newBuilder() .setName(JobEvent.TASKS_SUBMITTED) .setNamespace(NAMESPACE) .setMetadata(metadata).build()); try { Thread.sleep(100); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } graphiteEventReporter.report(); try { Thread.sleep(100); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } TimestampedValue retrievedEvent = graphiteSender.getMetric("gobblin.metrics.job1.task1.events.TasksSubmitted"); Assert.assertEquals(retrievedEvent.getValue(), "0"); Assert.assertTrue(retrievedEvent.getTimestamp() <= (System.currentTimeMillis() / 1000l)); } }
@Test public void testSimpleEvent() throws IOException { try ( MetricContext metricContext = MetricContext.builder(this.getClass().getCanonicalName() + ".testInfluxDBReporter1").build(); InfluxDBEventReporter influxEventReporter = getBuilder(metricContext).build();) { Map<String, String> metadata = Maps.newHashMap(); metadata.put(JobEvent.METADATA_JOB_ID, "job1"); metadata.put(TaskEvent.METADATA_TASK_ID, "task1"); metricContext.submitEvent(GobblinTrackingEvent.newBuilder() .setName(JobEvent.TASKS_SUBMITTED) .setNamespace(NAMESPACE) .setMetadata(metadata).build()); try { Thread.sleep(100); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } influxEventReporter.report(); try { Thread.sleep(100); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } TimestampedValue retrievedEvent = influxDB.getMetric( "gobblin.metrics.job1.task1.events.TasksSubmitted"); Assert.assertEquals(retrievedEvent.getValue(), "0.0"); Assert.assertTrue(retrievedEvent.getTimestamp() <= (System.currentTimeMillis())); } }
metadata.put("m2", null); event.setMetadata(metadata); context.submitEvent(event);
metadata.put(JobEvent.METADATA_JOB_STATE, "FAILED"); metricContext.submitEvent(GobblinTrackingEvent.newBuilder() .setName(MultiPartEvent.JOBSTATE_EVENT.getEventName()) .setNamespace(NAMESPACE)
metadata.put(JobEvent.METADATA_JOB_STATE, "FAILED"); metricContext.submitEvent(GobblinTrackingEvent.newBuilder() .setName(MultiPartEvent.JOBSTATE_EVENT.getEventName()) .setNamespace(NAMESPACE)
metadata.put("m2", null); event.setMetadata(metadata); context.submitEvent(event); metadata.put("k3", "v3"); event.setMetadata(metadata); context.submitEvent(event);
metadata.put(tag1, metadataValue1); event.setMetadata(metadata); context.submitEvent(event);
/** * Submit the event */ public void submit(MetricContext context) { context.submitEvent(build()); } }
/** * Submits the {@link org.apache.gobblin.metrics.GobblinTrackingEvent} to the {@link org.apache.gobblin.metrics.MetricContext}. * @param name Name of the event. * @param additionalMetadata Additional metadata to be added to the event. */ public void submit(String name, Map<String, String> additionalMetadata) { if(this.metricContext.isPresent()) { Map<String, String> finalMetadata = Maps.newHashMap(this.metadata); if(!additionalMetadata.isEmpty()) { finalMetadata.putAll(additionalMetadata); } // Timestamp is set by metric context. this.metricContext.get().submitEvent(new GobblinTrackingEvent(0l, this.namespace, name, finalMetadata)); } }
private void submitTrackingEvent(URI specSpecURI, String specSpecVersion, String operType) { GobblinTrackingEvent e = GobblinTrackingEvent.newBuilder() .setName(TRACKING_EVENT_NAME) .setNamespace(SpecCatalog.class.getName()) .setMetadata(ImmutableMap.<String, String>builder() .put(GobblinMetricsKeys.OPERATION_TYPE_META, operType) .put(GobblinMetricsKeys.SPEC_URI_META, specSpecURI.toString()) .put(GobblinMetricsKeys.SPEC_VERSION_META, specSpecVersion) .build()) .build(); this.metricsContext.submitEvent(e); }
private void submitTrackingEvent(URI jobSpecURI, String jobSpecVersion, String operType) { GobblinTrackingEvent e = GobblinTrackingEvent.newBuilder() .setName(TRACKING_EVENT_NAME) .setNamespace(JobCatalog.class.getName()) .setMetadata(ImmutableMap.<String, String>builder() .put(GobblinMetricsKeys.OPERATION_TYPE_META, operType) .put(GobblinMetricsKeys.JOB_SPEC_URI_META, jobSpecURI.toString()) .put(GobblinMetricsKeys.JOB_SPEC_VERSION_META, jobSpecVersion) .build()) .build(); this.metricsContext.submitEvent(e); }
private void submitUnfulfilledRequestEventsHelper(List<FileSet<CopyEntity>> fileSetList, String eventName) { for (FileSet<CopyEntity> fileSet : fileSetList) { GobblinTrackingEvent event = GobblinTrackingEvent.newBuilder().setName(eventName).setNamespace(CopySource.class.getName()).setMetadata( ImmutableMap.<String, String>builder() .put(ConfigurationKeys.DATASET_URN_KEY, fileSet.getDataset().getUrn()) .put(FILESET_TOTAL_ENTITIES, Integer.toString(fileSet.getTotalEntities())) .put(FILESET_TOTAL_SIZE_IN_BYTES, Long.toString(fileSet.getTotalSizeInBytes())) .put(FILESET_NAME, fileSet.getName()).build()).build(); this.metricContext.submitEvent(event); } }