Immediately send metrics to the backend.

@param rawMetrics Metrics to be sent. Names and tags will be sanitized.
15180
public void push(List<Metric> rawMetrics) {
    List<Metric> validMetrics = ValidCharacters.toValidValues(filter(rawMetrics));
    List<Metric> metrics = transformMetrics(validMetrics);

    LOGGER.debug("Scheduling push of {} metrics", metrics.size());
    final UpdateTasks tasks = getUpdateTasks(BasicTagList.EMPTY,
        identifyCountersForPush(metrics));
    final int maxAttempts = 5;
    int attempts = 1;
    while (!pushQueue.offer(tasks) && attempts <= maxAttempts) {
      ++attempts;
      final UpdateTasks droppedTasks = pushQueue.remove();
      LOGGER.warn("Removing old push task due to queue full. Dropping {} metrics.",
          droppedTasks.numMetrics);
      numMetricsDroppedQueueFull.increment(droppedTasks.numMetrics);
    }
    if (attempts >= maxAttempts) {
      LOGGER.error("Unable to push update of {}", tasks);
      numMetricsDroppedQueueFull.increment(tasks.numMetrics);
    } else {
      LOGGER.debug("Queued push of {}", tasks);
    }
  }
297164
public void updateMetricsRecord() {
    for (Map.Entry<MetricName, Long> entry: counters.entrySet()) {
      String name = (entry.getKey() + "_" + type).toLowerCase();
      record.setMetric(name, entry.getValue());
    }
    record.update();
  }
106233
def send_metrics_now
      ms = registry_measurements

      if ms.empty?
        Spectator.logger.debug 'No measurements to send'
      else
        uri = @registry.config[:uri]
        ms.each_slice(@registry.batch_size) do |batch|
          payload = payload_for_measurements(batch)
          Spectator.logger.info "Sending #{batch.length} measurements to #{uri}"
          @http.post_json(uri, payload)
        end
      end
    end
1092951
public void setMetricsTrackerFactory(MetricsTrackerFactory metricsTrackerFactory)
   {
      if (metricsTrackerFactory != null) {
         this.metricsTracker = new MetricsTrackerDelegate(metricsTrackerFactory.create(config.getPoolName(), getPoolStats()));
      }
      else {
         this.metricsTracker = new NopMetricsTrackerDelegate();
      }
   }
1344797
def do_metric_create_raw(mc, args):
    ''''''
    try:
        mc.metrics.create(**args.jsonbody)
    except (osc_exc.ClientException, k_exc.HttpError) as he:
        raise osc_exc.CommandError('%s\n%s' % (he.message, he.details))
    else:
        print('Successfully created metric')
747011
private void sendRegisterRequest() {
    Metrics.MetricPublisher publisher = Metrics.MetricPublisher.newBuilder().
        setHostname(hostname).
        setPort(instance.getInfo().getTaskId()).
        setComponentName(instance.getInfo().getComponentName()).
        setInstanceId(instance.getInstanceId()).
        setInstanceIndex(instance.getInfo().getComponentIndex()).
        build();
    Metrics.MetricPublisherRegisterRequest request =
        Metrics.MetricPublisherRegisterRequest.newBuilder().
            setPublisher(publisher).
            build();

    // The timeout would be the reconnect-interval-seconds
    sendRequest(request, null,
        Metrics.MetricPublisherRegisterResponse.newBuilder(),
        systemConfig.getInstanceReconnectMetricsmgrInterval());
  }
705433
public void setMetricDataResults(java.util.Collection<MetricDataResult> metricDataResults) {
        if (metricDataResults == null) {
            this.metricDataResults = null;
            return;
        }

        this.metricDataResults = new com.amazonaws.internal.SdkInternalList<MetricDataResult>(metricDataResults);
    }
701822
public void registerMetrics(MetricRegistry metricRegistry, String pipelineId) {
        meterName = name(Pipeline.class, pipelineId, "stage", String.valueOf(stage()), "executed");
        executed = metricRegistry.meter(meterName);
    }
1006317
public boolean updateMetric(Metric metric) {
        String metricName = metric.getName();
        checkMetricIsEmpty(metricName);
        QueryPart<Metric> queryPart = new Query<Metric>("metrics")
                .path(metricName, true);
        return httpClientManager.updateMetaData(queryPart, patch(metric));
    }
274420
def _submit_metrics(self, metrics, metric_name_and_type_by_property):
        
        for metric in metrics:
            if (
                metric.name not in metric_name_and_type_by_property
                and metric.name.lower() not in metric_name_and_type_by_property
            ):
                # Only report the metrics that were specified in the configration
                # Ignore added properties like 'Timestamp_Sys100NS', `Frequency_Sys100NS`, etc ...
                continue

            if metric_name_and_type_by_property.get(metric.name):
                metric_name, metric_type = metric_name_and_type_by_property[metric.name]
            elif metric_name_and_type_by_property.get(metric.name.lower()):
                metric_name, metric_type = metric_name_and_type_by_property[metric.name.lower()]
            else:
                continue

            try:
                func = getattr(self, metric_type.lower())
            except AttributeError:
                raise Exception(u"Invalid metric type: {0}".format(metric_type))

            func(metric_name, metric.value, metric.tags)
782665
public synchronized void pushMetric(final MetricsRecord mr) {
    if (changed) 
      mr.setMetric(getName(), value);
    changed = false;
  }
949426
public function send(AbstractMetric $metric)
    {
        $message = $this->getMetricMessage($metric);
        $this->flush($message);
    }
391173
public void send(List<StDatapoint> datapoints) {
    for (StDatapoint metric : datapoints) {
      StDatapointValidator.validate(metric);
    }
    sender.send(datapoints);
  }
469366
public void startMetricReporting(Properties properties) {
    if (this.metricsReportingStarted) {
      LOGGER.warn("Metric reporting has already started");
      return;
    }

    TimeUnit reportTimeUnit = TimeUnit.MILLISECONDS;
    long reportInterval = Long.parseLong(properties
        .getProperty(ConfigurationKeys.METRICS_REPORT_INTERVAL_KEY, ConfigurationKeys.DEFAULT_METRICS_REPORT_INTERVAL));
    ScheduledReporter.setReportingInterval(properties, reportInterval, reportTimeUnit);

    long startTime = System.currentTimeMillis();

    try {
      // Build and start the JMX reporter
      buildJmxMetricReporter(properties);
      if (this.jmxReporter.isPresent()) {
        LOGGER.info("Will start reporting metrics to JMX");
        this.jmxReporter.get().start();
      }

      // Build all other reporters
      buildFileMetricReporter(properties);
      buildKafkaMetricReporter(properties);
      buildGraphiteMetricReporter(properties);
      buildInfluxDBMetricReporter(properties);
      buildCustomMetricReporters(properties);
      buildFileFailureEventReporter(properties);

      // Start reporters that implement org.apache.gobblin.metrics.report.ScheduledReporter
      RootMetricContext.get().startReporting();

      // Start reporters that implement com.codahale.metrics.ScheduledReporter
      for (com.codahale.metrics.ScheduledReporter scheduledReporter : this.codahaleScheduledReporters) {
        scheduledReporter.start(reportInterval, reportTimeUnit);
      }
    } catch (Exception e) {
      LOGGER.error("Metrics reporting cannot be started due to {}", ExceptionUtils.getFullStackTrace(e));
      throw e;
    }

    this.metricsReportingStarted = true;
    LOGGER.info("Metrics reporting has been started in {} ms: GobblinMetrics {}",
        System.currentTimeMillis() - startTime, this.toString());
  }
1021277
function processExtraMetrics(ctx, payload) {
	// extra metrics (params and meta)
	if (_.isObject(ctx.action.metrics)) {
		// custom metrics def
		assignExtraMetrics(ctx, "params", payload);
		assignExtraMetrics(ctx, "meta", payload);
	}
}
1041598
private static <L> void populateMetricTypesForResourceType(
            ResourceType.Builder<?, L> resourceTypeBuilder,
            TypeSets.Builder<L> typeSetsBuilder) {

        Map<Name, TypeSet<MetricType<L>>> metricTypeSets = typeSetsBuilder.getMetricTypeSets();
        List<Name> metricSetNames = resourceTypeBuilder.getMetricSetNames();
        for (Name metricSetName : metricSetNames) {
            TypeSet<MetricType<L>> metricSet = metricTypeSets.get(metricSetName);
            if (metricSet != null && metricSet.isEnabled()) {
                resourceTypeBuilder.metricTypes(metricSet.getTypeMap().values());
            }
        }

    }
986468
public void forceGatherAllMetrics() {
    LOG.info("Forcing to gather all metrics and flush out.");
    Metrics.MetricPublisherPublishMessage.Builder builder =
        Metrics.MetricPublisherPublishMessage.newBuilder();

    for (List<String> metricNames : timeBucketToMetricNames.values()) {
      for (String metricName : metricNames) {
        gatherOneMetric(metricName, builder);
      }
    }

    metricCollectionCount.incr();
    addDataToMetricPublisher(builder, COLLECTION_COUNT_NAME, metricCollectionCount);

    Metrics.MetricPublisherPublishMessage msg = builder.build();

    queue.offer(msg);
  }