Skip to content

Commit

Permalink
Prepend to list instead of concatenating
Browse files Browse the repository at this point in the history
  • Loading branch information
dj707chen committed May 25, 2024
1 parent a9178e8 commit 57066e7
Showing 1 changed file with 31 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,10 @@ final class Prometheus[F[_]: Sync] private (
Sync[F].delay {
metrics.responseDuration
.labels(
List(
label(classifier),
reportMethod(method),
Phase.report(Phase.Headers),
) ++ customLabels: _*
label(classifier) +:
reportMethod(method) +:
Phase.report(Phase.Headers) +:
customLabels: _*
)
.observeWithExemplar(
SimpleTimer.elapsedSecondsFromNanos(0, elapsed),
Expand All @@ -169,23 +168,21 @@ final class Prometheus[F[_]: Sync] private (
Sync[F].delay {
metrics.responseDuration
.labels(
List(
label(classifier),
reportMethod(method),
Phase.report(Phase.Body),
) ++ customLabels: _*
label(classifier) +:
reportMethod(method) +:
Phase.report(Phase.Body) +:
customLabels: _*
)
.observeWithExemplar(
SimpleTimer.elapsedSecondsFromNanos(0, elapsed),
exemplarOpt.orNull: _*
)
metrics.requests
.labels(
List(
label(classifier),
reportMethod(method),
reportStatus(status),
) ++ customLabels: _*
label(classifier) +:
reportMethod(method) +:
reportStatus(status) +:
customLabels: _*
)
.incWithExemplar(exemplarOpt.orNull: _*)
}
Expand All @@ -208,11 +205,10 @@ final class Prometheus[F[_]: Sync] private (
Sync[F].delay {
metrics.abnormalTerminations
.labels(
List(
label(classifier),
AbnormalTermination.report(AbnormalTermination.Canceled),
label(Option.empty),
) ++ customLabels: _*
label(classifier) +:
AbnormalTermination.report(AbnormalTermination.Canceled) +:
label(Option.empty) +:
customLabels: _*
)
.observeWithExemplar(
SimpleTimer.elapsedSecondsFromNanos(0, elapsed),
Expand All @@ -230,11 +226,10 @@ final class Prometheus[F[_]: Sync] private (
Sync[F].delay {
metrics.abnormalTerminations
.labels(
List(
label(classifier),
AbnormalTermination.report(AbnormalTermination.Abnormal),
label(Option(cause.getClass.getName)),
) ++ customLabels: _*
label(classifier) +:
AbnormalTermination.report(AbnormalTermination.Abnormal) +:
label(Option(cause.getClass.getName)) +:
customLabels: _*
)
.observeWithExemplar(
SimpleTimer.elapsedSecondsFromNanos(0, elapsed),
Expand All @@ -252,11 +247,10 @@ final class Prometheus[F[_]: Sync] private (
Sync[F].delay {
metrics.abnormalTerminations
.labels(
List(
label(classifier),
AbnormalTermination.report(AbnormalTermination.Error),
label(Option(cause.getClass.getName)),
) ++ customLabels: _*
label(classifier) +:
AbnormalTermination.report(AbnormalTermination.Error) +:
label(Option(cause.getClass.getName)) +:
customLabels: _*
)
.observeWithExemplar(
SimpleTimer.elapsedSecondsFromNanos(0, elapsed),
Expand All @@ -270,11 +264,10 @@ final class Prometheus[F[_]: Sync] private (
Sync[F].delay {
metrics.abnormalTerminations
.labels(
List(
label(classifier),
AbnormalTermination.report(AbnormalTermination.Timeout),
label(Option.empty),
) ++ customLabels: _*
label(classifier) +:
AbnormalTermination.report(AbnormalTermination.Timeout) +:
label(Option.empty) +:
customLabels: _*
)
.observeWithExemplar(
SimpleTimer.elapsedSecondsFromNanos(0, elapsed),
Expand Down Expand Up @@ -320,7 +313,7 @@ final class Prometheus[F[_]: Sync] private (
.buckets(responseDurationSecondsHistogramBuckets.toList: _*)
.name(prefix + "_" + "response_duration_seconds")
.help("Response Duration in seconds.")
.labelNames(List("classifier", "method", "phase") ++ customLabels: _*)
.labelNames("classifier" +: "method" +: "phase" +: customLabels: _*)
.create(),
registry,
)
Expand All @@ -340,7 +333,7 @@ final class Prometheus[F[_]: Sync] private (
.build()
.name(prefix + "_" + "request_count")
.help("Total Requests.")
.labelNames(List("classifier", "method", "status") ++ customLabels: _*)
.labelNames("classifier" +: "method" +: "status" +: customLabels: _*)
.create(),
registry,
)
Expand All @@ -350,7 +343,7 @@ final class Prometheus[F[_]: Sync] private (
.build()
.name(prefix + "_" + "abnormal_terminations")
.help("Total Abnormal Terminations.")
.labelNames(List("classifier", "termination_type", "cause") ++ customLabels: _*)
.labelNames("classifier" +: "termination_type" +: "cause" +: customLabels: _*)
.create(),
registry,
)
Expand Down

0 comments on commit 57066e7

Please sign in to comment.