metrics-common-tags-autoconfigure

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

License

License

Categories

Categories

Auto Application Layer Libs Code Generators config Configuration Metrics Application Testing & Monitoring Monitoring
GroupId

GroupId

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

ArtifactId

metrics-common-tags-autoconfigure
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

metrics-common-tags-autoconfigure
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-autoconfigure

How to add to project

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

Dependencies

runtime (4)

Group / Artifact Type Version
io.github.ing8ar.metrics-common-tags : metrics-common-tags-core jar 0.1.0
org.springframework.boot : spring-boot-autoconfigure jar
org.springframework.boot : spring-boot-actuator-autoconfigure jar
io.micrometer : micrometer-core jar

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.1
0.1.0