Support for Dropwizard metric names with encoded tags

The Metrics library (v4.x) does not natively support tags, however tags can be encoded as part of the metric name. This library offers a modified MetricName class for converting tagged metrics to the legay format.

License

License

Categories

Categories

DropWizard Container Microservices Metrics Application Testing & Monitoring Monitoring
GroupId

GroupId

de.peetzen.dropwizard.metrics
ArtifactId

ArtifactId

metrics-tagging
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

Support for Dropwizard metric names with encoded tags
The Metrics library (v4.x) does not natively support tags, however tags can be encoded as part of the metric name. This library offers a modified MetricName class for converting tagged metrics to the legay format.
Project URL

Project URL

https://github.com/peetzen/dropwizard-metrics-tagging
Source Code Management

Source Code Management

https://github.com/peetzen/dropwizard-metrics-tagging

Download metrics-tagging

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Tagging support for Dropwizard Metrics

CircleCI Maven Central License

The Metrics project from Dropwizard does not natively support tags in version v4.x. However, tags can be encoded as part of the metric name. This library offers a MetricName class for creating metric names and converting tagged metric names to the legacy format.

Documentation

This library adds support for creating metric names with tags.

The MetricName class is based on the code for Dropwizard metrics (v5.x) and adds methods for converting to the legacy metric name format. In addition, it contains support for dealing with tags from the MetricTaggingContext ThreadLocal context.

Getting started

The artifacts including source and binaries are available on the central Maven repositories.

For maven:

<dependency>
  <groupId>de.peetzen.dropwizard.metrics</groupId>
  <artifactId>metrics-tagging</artifactId>
  <version>1.0.1</version>
</dependency>

For gradle:

implementation group: 'de.peetzen.dropwizard.metrics', name: 'metrics-tagging', version: '1.0.1'

Fully compatible with Dropwizard Metrics version v4.x.

Usage

Create a metric name with a single explicit tag.

    String name = MetricName.build("my","metric").tagged("tenant", "tenant-id").toLegacyFormat();
    assert name.equals("my.metric[tenant:tenant-id]");

Create a metric name with a single tag fetched from the MetricTaggingContext context.

    MetricName metricName = MetricName.build("my","metric");
    MetricTaggingContext.put("tenant", "tenant-id")

    String name = metricName.taggedUsingContext().toLegacyFormat();
    assert name.equals("my.metric[tenant:tenant-id]");

Versions

Version
1.0.1
1.0.0