metrics-common-tags-core

Micro-util for adding common tags to Spring Boot metrics (micrometer)

License

License

Categories

Categories

Metrics Application Testing & Monitoring Monitoring
GroupId

GroupId

io.github.ing8ar.metrics-common-tags
ArtifactId

ArtifactId

metrics-common-tags-core
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

metrics-common-tags-core
Micro-util for adding common tags to Spring Boot metrics (micrometer)
Project URL

Project URL

https://github.com/ing8ar/metrics-common-tags
Source Code Management

Source Code Management

https://github.com/ing8ar/metrics-common-tags

Download metrics-common-tags-core

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.ing8ar.metrics-common-tags/metrics-common-tags-core/ -->
<dependency>
    <groupId>io.github.ing8ar.metrics-common-tags</groupId>
    <artifactId>metrics-common-tags-core</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.ing8ar.metrics-common-tags/metrics-common-tags-core/
implementation 'io.github.ing8ar.metrics-common-tags:metrics-common-tags-core:0.1.0'
// https://jarcasting.com/artifacts/io.github.ing8ar.metrics-common-tags/metrics-common-tags-core/
implementation ("io.github.ing8ar.metrics-common-tags:metrics-common-tags-core:0.1.0")
'io.github.ing8ar.metrics-common-tags:metrics-common-tags-core:jar:0.1.0'
<dependency org="io.github.ing8ar.metrics-common-tags" name="metrics-common-tags-core" rev="0.1.0">
  <artifact name="metrics-common-tags-core" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.ing8ar.metrics-common-tags', module='metrics-common-tags-core', version='0.1.0')
)
libraryDependencies += "io.github.ing8ar.metrics-common-tags" % "metrics-common-tags-core" % "0.1.0"
[io.github.ing8ar.metrics-common-tags/metrics-common-tags-core "0.1.0"]

Dependencies

runtime (1)

Group / Artifact Type Version
io.github.microutils : kotlin-logging jar 1.6.20

Project Modules

There are no modules declared in this project.

Metrics Common Tags

Micro-util for adding common tags to spring boot metrics (spring boot actuator).

Similarly, but not the same feature (since Spring Boot 2.1.0) - management.metrics.tags.*, because it helps to extract some non constant data.

Getting Started

1. Add dependency to build file (build.gradle.kts)

implementation("io.github.ing8ar.metrics-common-tags:metrics-common-tags-autoconfigure:0.1.1")

2. Add properties to your spring boot application.yml

metrics:
  common:
    tags:
      - app
      - host

3. Run app

Your app will add that tags with values for each metric:

Key Value
app ${spring.application.name}
host InetAddress.getLocalHost().hostName

Pre-initialize tags

Tag Extractor class
app DefaultAppNameTagExtractor
host DefaultHostNameTagExtractor

Customization

You can add your own tags, or override exist.

Add your own tag

Create bean which implements TagExtractor:

    @Bean
    open fun customTagExtractor() = object : TagExtractor {
        override val tagName: String
            get() = "custom-tag"

        override fun extract() = "custom tag data"

    }

, then add tag name to configuration file (ex.: application.yml):

metrics:
  common:
    tags:
      - custom-tag

Override exist

See example project

Versions

Version
0.1.0