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.
25
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));
    }
  }
547572
public void registerNewMetrics(MetricName name, Metric metric) {
		final Set<MetricName> registeredNames = getNames();
		if (!registeredNames.contains(name)) {
			try {
				register(name, metric);
			} catch (IllegalArgumentException e){/* exception due to race condition*/}
		}
	}
1284335
@SuppressWarnings("unchecked")
	public <T extends Metric> T register(MetricName name, T metric) throws IllegalArgumentException {
		if (metric instanceof MetricSet) {
			throw new IllegalArgumentException("This metrics registry is not compatible with MetricSets. Use a Metric2Set instead.");
		} else {
			final Metric existing = metrics.putIfAbsent(name, metric);
			if (existing != null) {
				throw new IllegalArgumentException("A metric named " + name + " already exists");
			}
			else {
				// This is a new metric - we have to register the Metric with
				// the legacy Dropwizard Metric registry as
				// well to support existing reports and listeners
				metricRegistry.register(name.toGraphiteName(), metric);
			}
		}
		return metric;
	}
1131587
private void injectTagsToEvent(GobblinTrackingEvent event) {
    Map<String, String> originalMetadata = event.getMetadata();
    Map<String, Object> tags = getTagMap();
    Map<String, String> newMetadata = Maps.newHashMap();
    for(Map.Entry<String, Object> entry : tags.entrySet()) {
      newMetadata.put(entry.getKey(), entry.getValue().toString());
    }
    newMetadata.putAll(originalMetadata);
    event.setMetadata(newMetadata);
  }
813752
private void addMetric(
      List<Metric> metrics,
      String name,
      TagList tags,
      Object value) {
    long now = System.currentTimeMillis();
    if (onlyNumericMetrics) {
      value = asNumber(value);
    }
    if (value != null) {

      TagList newTags = counters.matches(MonitorConfig.builder(name).withTags(tags).build())
          ? getTagListWithAdditionalTag(tags, DataSourceType.COUNTER)
          : getTagListWithAdditionalTag(tags, DataSourceType.GAUGE);
      Metric m = new Metric(name, newTags, now, value);
      metrics.add(m);
    }
  }
750594
public void addParam(String name, String value) {
        if (name == null) {
            throw new NullPointerException("name");
        }
        if (value == null) {
            throw new NullPointerException("value");
        }
        params.add(new Param(name, value));
    }
1135849
@SuppressWarnings("unchecked")
    public <T extends Metric> T register(String name, T metric) throws IllegalArgumentException {
        if (metric instanceof MetricSet) {
            registerAll(name, (MetricSet) metric);
        } else {
            final Metric existing = metrics.putIfAbsent(name, metric);
            if (existing == null) {
                onMetricAdded(name, metric);
            } else {
                throw new IllegalArgumentException("A metric named " + name + " already exists");
            }
        }
        return metric;
    }
24472
public void addParameter( String name, String value )
    {
        if ( _additionalParameters == null )
        {
            _additionalParameters = new HashMap();
        }
        
        _additionalParameters.put( name, value );
    }
1274301
private void reportMeter(String name, Meter meter) {
        String prefixedName = prefix(name);
        if (!snapshots.hasDescriptor(prefixedName)) {

            MetricItem.Builder builder = MetricItem.Builder.create();

            builder.events("events");

            builder.events("m1_rate", 1, rateUnit);
            builder.events("m5_rate", 5, rateUnit);
            builder.events("m15_rate", 15, rateUnit);
            builder.events("mean_rate", rateUnit);
            snapshots.setDescriptor(prefixedName, builder.build());
        }

        Map<String, Number> values = new HashMap<>();

        addMetered(meter, values, "events");

        snapshots.addSnapshot(prefixedName, getTimestamp(), values);
    }
1020089
protected static void checkMetricLabelName(String name) {
    if (!METRIC_LABEL_NAME_RE.matcher(name).matches()) {
      throw new IllegalArgumentException("Invalid metric label name: " + name);
    }
    if (RESERVED_METRIC_LABEL_NAME_RE.matcher(name).matches()) {
      throw new IllegalArgumentException("Invalid metric label name, reserved for internal use: " + name);
    }
  }
782518
public AbstractFastFileBuilder<T> withMetaData(String name, String value) {
        this.metaDataSet.add(new MetaData(name, value));
        return this;
    }
94772
@Override
    public boolean remove(String name) {
        final Metric metric = metrics.remove(name);
        metadata.remove(name);
        if (metric != null) {
            return true;
        }
        return false;
    }
21567
public void addNamedQueryParameter(String name, Object value) {
        parameters.put(checkNotNull(name), checkNotNull(value));
    }
671352
public Metric add(String name, String description, MeasurableStat stat) {
        return add(name, description, stat, null);
    }
446680
@Override
    public Histogram histogram(String name) {
        return this.histogram(new Metadata(name, MetricType.HISTOGRAM));
    }
1374182
private void pushEvent(GobblinTrackingEvent event) throws IOException {

    Map<String, String> metadata = event.getMetadata();
    String name = getMetricName(metadata, event.getName());
    long timestamp = event.getTimestamp();
    MultiPartEvent multiPartEvent = MultiPartEvent.getEvent(metadata.get(EventSubmitter.EVENT_TYPE));
    if (multiPartEvent == null) {
      influxDBPusher.push(buildEventAsPoint(name, EMTPY_VALUE, timestamp));
    }
    else {
      List<Point> points = Lists.newArrayList();
      for (String field : multiPartEvent.getMetadataFields()) {
        Point point = buildEventAsPoint(JOINER.join(name, field), convertValue(field,  metadata.get(field)), timestamp);
        points.add(point);
      }
      influxDBPusher.push(points);
    }
  }
611905
public void addEntityMetadata(String persistenceUnit, Class<?> clazz, EntityMetadata entityMetadata)
    {
        Metamodel metamodel = getMetamodelMap().get(persistenceUnit);
        Map<String, EntityMetadata> entityClassToMetadataMap = ((MetamodelImpl) metamodel).getEntityMetadataMap();
        if (entityClassToMetadataMap == null || entityClassToMetadataMap.isEmpty())
        {
            entityClassToMetadataMap.put(clazz.getName(), entityMetadata);
        }
        else
        {
            if (logger.isDebugEnabled())
                logger.debug("Entity meta model already exists for persistence unit " + persistenceUnit + " and class "
                        + clazz + ". Noting needs to be done");
        }
    }