Record metrics on a Redisson cache.

@param registry - registry to bind metrics to
@param cache - cache to instrument
@param tags - tags to apply to all recorded metrics
@return cache
4475
public static RedissonCache monitor(MeterRegistry registry, RedissonCache cache, Iterable<Tag> tags) {
        new RedissonCacheMetrics(cache, tags).bindTo(registry);
        return cache;
    }
81377
@Deprecated
    public static DistributionSummary summaryWithDefaultQuantiles(MeterRegistry registry,
                                                                  String name, Iterable<Tag> tags) {
        requireNonNull(registry, "registry");
        requireNonNull(name, "name");
        requireNonNull(tags, "tags");
        return DistributionSummary.builder(name)
                                  .tags(tags)
                                  .publishPercentiles(PERCENTILES)
                                  .register(registry);
    }
36518
public CollectionRequest<Task> getTasksWithTag(String tag) {
    
        String path = String.format("/tags/%s/tasks", tag);
        return new CollectionRequest<Task>(this, Task.class, path, "GET");
    }
130125
@RequestMapping(method = RequestMethod.GET)
  public ApplicationRegistry getMetrics(@RequestParam Map<String, String> filters)
    throws IOException {
    boolean all = filters.get("all") != null;
    String filterMeterNameRegex = filters.getOrDefault("meterNameRegex", "");
    String filterTagNameRegex = filters.getOrDefault("tagNameRegex", "");
    String filterTagValueRegex = filters.getOrDefault("tagValueRegex", "");
    TagMeasurementFilter queryFilter = new TagMeasurementFilter(
        filterMeterNameRegex, filterTagNameRegex, filterTagValueRegex);
    Predicate<Measurement> filter;
    if (all) {
      filter = queryFilter;
    } else {
      filter = queryFilter.and(getDefaultMeasurementFilter());
    }

    ApplicationRegistry response = new ApplicationRegistry();
    response.setApplicationName(applicationName);
    response.setApplicationVersion(applicationVersion);
    response.setMetrics(encodeRegistry(registry, filter));
    return response;
  }
1330351
public function Tag($tag, $instance, array $options = null)
    {
        //========================
        // Determine Handler
        //========================
        if(isset($options['cacheHandler'])) {
            if (isset($this->cacheHandlers[$options['cacheHandler']]))
            {
                $handler = $this->cacheHandlers[$options['cacheHandler']];
            } else {
                trigger_error("KeyRing Tag requested but that cache handler was not provided during construction of keyring", E_USER_ERROR);
            }
        } else {
            $handler = $this->cacheHandlers[$this->defaultCacheHandler];
        }
        
        //==================================
        // Check if Tag Version Specified
        //===================================
        $version = isset($options['version']) ? $options['version'] : null;                
        
        //==================================
        // Check if Prefix Specified
        //===================================
        $prefix = isset($options['prefix']) ? $options['prefix'] : $this->defaultPrefix;                
        
        // Determine Type
        if(isset($options['type'])) {
            switch(strtolower($options['type']))
            {
                case 'standard':                   
                    $tag = new FragmentedKeys\Tag\Standard($tag, $instance, $version, $handler, $prefix);
                    break;                
                case 'constant':
                    $tag = new FragmentedKeys\Tag\Constant($tag, $instance, $version, $handler, $prefix);
                    break;
            }
        }        
        return $tag;         
    }
1179305
public GetGroupResult withTags(java.util.Map<String, String> tags) {
        setTags(tags);
        return this;
    }
1306259
public static void monitor(MeterRegistry registry, SessionFactory sessionFactory, String sessionFactoryName, String... tags) {
        monitor(registry, sessionFactory, sessionFactoryName, Tags.of(tags));
    }
244365
public void setMetricRegistry(Object metricRegistry)
   {
      if (metricRegistry != null && safeIsAssignableFrom(metricRegistry, "com.codahale.metrics.MetricRegistry")) {
         setMetricsTrackerFactory(new CodahaleMetricsTrackerFactory((MetricRegistry) metricRegistry));
      }
      else if (metricRegistry != null && safeIsAssignableFrom(metricRegistry, "io.micrometer.core.instrument.MeterRegistry")) {
         setMetricsTrackerFactory(new MicrometerMetricsTrackerFactory((MeterRegistry) metricRegistry));
      }
      else {
         setMetricsTrackerFactory(null);
      }
   }
1162156
@Override
    public java.util.concurrent.Future<TagQueueResult> tagQueueAsync(String queueUrl, java.util.Map<String, String> tags) {

        return tagQueueAsync(new TagQueueRequest().withQueueUrl(queueUrl).withTags(tags));
    }
710749
def _collect_metrics_async(self, instance, query_specs):
        
        # ## <TEST-INSTRUMENTATION>
        t = Timer()
        # ## </TEST-INSTRUMENTATION>
        i_key = self._instance_key(instance)
        server_instance = self._get_server_instance(instance)
        perfManager = server_instance.content.perfManager
        custom_tags = instance.get('tags', [])
        results = perfManager.QueryPerf(query_specs)
        if results:
            for mor_perfs in results:
                mor_name = str(mor_perfs.entity)
                try:
                    mor = self.mor_cache.get_mor(i_key, mor_name)
                except MorNotFoundError:
                    self.log.error(
                        "Trying to get metrics from object %s deleted from the cache, skipping. "
                        "Consider increasing the parameter `clean_morlist_interval` to avoid that",
                        mor_name,
                    )
                    continue

                for result in mor_perfs.value:
                    counter_id = result.id.counterId
                    if not self.metadata_cache.contains(i_key, counter_id):
                        self.log.debug(
                            "Skipping value for counter {}, because there is no metadata about it".format(
                                ensure_unicode(counter_id)
                            )
                        )
                        continue

                    # Metric types are absolute, delta, and rate
                    metric_name = self.metadata_cache.get_metadata(i_key, result.id.counterId).get('name')

                    if self.in_compatibility_mode(instance):
                        if metric_name not in ALL_METRICS:
                            self.log.debug("Skipping unknown `{}` metric.".format(ensure_unicode(metric_name)))
                            continue

                    if not result.value:
                        self.log.debug(
                            "Skipping `{}` metric because the value is empty".format(ensure_unicode(metric_name))
                        )
                        continue

                    instance_name = result.id.instance or "none"
                    value = self._transform_value(instance, result.id.counterId, result.value[0])

                    tags = ['instance:{}'.format(ensure_unicode(instance_name))]
                    if not mor['hostname']:  # no host tags available
                        tags.extend(mor['tags'])

                    # vsphere "rates" should be submitted as gauges (rate is
                    # precomputed).
                    self.gauge(
                        "vsphere.{}".format(ensure_unicode(metric_name)),
                        value,
                        hostname=mor['hostname'],
                        tags=tags + custom_tags,
                    )

        # ## <TEST-INSTRUMENTATION>
        self.histogram('datadog.agent.vsphere.metric_colection.time', t.total(), tags=custom_tags)
1244137
@Benchmark
  @BenchmarkMode(Mode.AverageTime)
  @OutputTimeUnit(TimeUnit.NANOSECONDS)
  public TagContext getCurrentTagContext(Data data) {
    return data.tagger.getCurrentTagContext();
  }
1207994
public CreateLoggerDefinitionRequest withTags(java.util.Map<String, String> tags) {
        setTags(tags);
        return this;
    }
1026743
protected Set<CacheEntryTag> getTags(Element element) {
        final Object key = element.getObjectKey();
        if (key instanceof TaggedCacheEntry) {
            return ((TaggedCacheEntry) key).getTags();
        }

        final Object value = element.getObjectValue();
        if (value instanceof TaggedCacheEntry) {
            return ((TaggedCacheEntry) value).getTags();
        }

        return null;
    }
544225
@Override
    public <T extends Metric> T register(String name, T metric) throws IllegalArgumentException {
        // For MP Metrics 1.0, MetricType.from(Class in) does not support lambdas or proxy classes
        return register(name, metric, new Metadata(name, from(metric)));
    }
666742
public function gauge($metric, $level, array $tags = array(), $sampleRate = AbstractMetric::DEFAULT_SAMPLE_RATE)
    {
        try {
            $this->sendMetric($this->metricFactory->gauge($metric, $level, $tags, $sampleRate));
        } catch (\Exception $exception) {
            $this->logException($exception);
        }

        return $this;
    }
75816
protected void processOneMetric(List<String> resultStrings, Server server, Result result, Object value, String addTagName,
									String addTagValue) {
		String metricName = this.metricNameStrategy.formatName(result);

		//
		// Skip any non-numeric values since OpenTSDB only supports numeric metrics.
		//
		if (isNumeric(value)) {
			StringBuilder resultString = new StringBuilder();

			formatResultString(resultString, metricName, result.getEpoch() / 1000L, value);
			addTags(resultString, server);

			if (addTagName != null) {
				addTag(resultString, addTagName, addTagValue);
			}

			if (!typeNames.isEmpty()) {
				this.addTypeNamesTags(resultString, result);
			}

			resultStrings.add(resultString.toString());
		} else {
			log.debug("Skipping non-numeric value for metric {}; value={}", metricName, value);
		}
	}
575503
protected void putElement(Ehcache cache, Element element) {
        final Set<CacheEntryTag> tags = this.getTags(element);

        // Check if the key is tagged
        if (tags != null && !tags.isEmpty()) {
            final String cacheName = cache.getName();
            final Object key = element.getObjectKey();
            final LoadingCache<CacheEntryTag, Set<Object>> cacheKeys =
                    taggedCacheKeys.getUnchecked(cacheName);

            logger.debug("Tracking {} tags in cache {} for key {}", tags.size(), cacheName, key);

            // Add all the tags to the tracking map
            for (final CacheEntryTag tag : tags) {
                // Record that this tag type is stored in this cache
                final String tagType = tag.getTagType();
                final Set<Ehcache> caches = taggedCaches.getUnchecked(tagType);
                caches.add(cache);

                // Record the tag->key association
                final Set<Object> taggedKeys = cacheKeys.getUnchecked(tag);
                taggedKeys.add(key);
            }
        }
    }