Skip to content

Commit

Permalink
Add ability to set custom tags for statsd metrics (close #340)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeemster committed Aug 25, 2023
1 parent 03909f2 commit 58ee443
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ trait Collector {
)

lazy val metricRegistry: Option[HttpMetricsRegistry] = collectorConf.monitoring.metrics.statsd match {
case StatsdConfig(true, hostname, port, period, prefix) =>
case StatsdConfig(true, hostname, port, period, prefix, tags) =>
val constantTags = tags.map { case (k: String, v: String) => s"${k}:${v}" }

Some(
DatadogRegistry(
client = new NonBlockingStatsDClientBuilder()
Expand All @@ -145,6 +147,7 @@ trait Collector {
.enableAggregation(true)
.aggregationFlushInterval(period.toMillis.toInt)
.enableTelemetry(false)
.constantTags(constantTags.toArray: _*)
.build(),
DatadogSettings
.default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ package model {
enabled: Boolean,
hostname: String,
port: Int,
period: FiniteDuration = 1.minute,
prefix: String = "snowplow.collector"
period: FiniteDuration = 1.minute,
prefix: String = "snowplow.collector",
tags: Map[String, String] = Map("app" -> "collector")
)
final case class MetricsConfig(statsd: StatsdConfig)
final case class MonitoringConfig(metrics: MetricsConfig)
Expand Down
5 changes: 5 additions & 0 deletions examples/config.kafka.extended.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ collector {
period = "10 seconds"
# Optional, override the default metric prefix
# "prefix": "snowplow.collector"

# Any key-value pairs to be tagged on every StatsD metric
"tags": {
"app": collector
}
}

# Configures how long the colletor should pause after receiving a sigterm before starting the graceful shutdown.
Expand Down
5 changes: 5 additions & 0 deletions examples/config.kinesis.extended.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ collector {
period = "10 seconds"
# Optional, override the default metric prefix
# "prefix": "snowplow.collector"

# Any key-value pairs to be tagged on every StatsD metric
"tags": {
"app": collector
}
}

# Configures how long the colletor should pause after receiving a sigterm before starting the graceful shutdown.
Expand Down
5 changes: 5 additions & 0 deletions examples/config.nsq.extended.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ collector {
period = "10 seconds"
# Optional, override the default metric prefix
# "prefix": "snowplow.collector"

# Any key-value pairs to be tagged on every StatsD metric
"tags": {
"app": collector
}
}

# Configures how long the colletor should pause after receiving a sigterm before starting the graceful shutdown.
Expand Down
5 changes: 5 additions & 0 deletions examples/config.pubsub.extended.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ collector {
period = "10 seconds"
# Optional, override the default metric prefix
# "prefix": "snowplow.collector"

# Any key-value pairs to be tagged on every StatsD metric
"tags": {
"app": collector
}
}

# Configures how long the colletor should pause after receiving a sigterm before starting the graceful shutdown.
Expand Down
5 changes: 5 additions & 0 deletions examples/config.rabbitmq.extended.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ collector {
period = "10 seconds"
# Optional, override the default metric prefix
# "prefix": "snowplow.collector"

# Any key-value pairs to be tagged on every StatsD metric
"tags": {
"app": collector
}
}

# Configures how long the colletor should pause after receiving a sigterm before starting the graceful shutdown.
Expand Down
5 changes: 5 additions & 0 deletions examples/config.sqs.extended.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ collector {
period = "10 seconds"
# Optional, override the default metric prefix
# "prefix": "snowplow.collector"

# Any key-value pairs to be tagged on every StatsD metric
"tags": {
"app": collector
}
}

# Configures how long the colletor should pause after receiving a sigterm before starting the graceful shutdown.
Expand Down
5 changes: 5 additions & 0 deletions examples/config.stdout.extended.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ collector {
period = "10 seconds"
# Optional, override the default metric prefix
# "prefix": "snowplow.collector"

# Any key-value pairs to be tagged on every StatsD metric
"tags": {
"app": collector
}
}

# Configures how long the colletor should pause after receiving a sigterm before starting the graceful shutdown.
Expand Down

0 comments on commit 58ee443

Please sign in to comment.