From bb8ba5c7d81d6c01ed9ca16aae9a2d64635a244a Mon Sep 17 00:00:00 2001 From: Ratko Veprek Date: Fri, 6 Dec 2024 18:02:22 +0100 Subject: [PATCH] Added val with all metric qualifications (#20418) Before this change, we had to refer to each qualification individually in order to refer to all of them. Now, there is a list of qualifiations that can be used instead. --- .../canton/metrics/MetricDoc.scala | 2 - .../com/daml/metrics/api/MetricDoc.scala | 47 ------------------- .../metrics/api/MetricQualification.scala | 3 ++ 3 files changed, 3 insertions(+), 49 deletions(-) delete mode 100644 sdk/observability/metrics/src/main/scala/com/daml/metrics/api/MetricDoc.scala diff --git a/sdk/canton/community/common/src/main/scala/com/digitalasset/canton/metrics/MetricDoc.scala b/sdk/canton/community/common/src/main/scala/com/digitalasset/canton/metrics/MetricDoc.scala index fc10aada1159..894dcad4f3f3 100644 --- a/sdk/canton/community/common/src/main/scala/com/digitalasset/canton/metrics/MetricDoc.scala +++ b/sdk/canton/community/common/src/main/scala/com/digitalasset/canton/metrics/MetricDoc.scala @@ -3,13 +3,11 @@ package com.digitalasset.canton.metrics -import com.daml.metrics.api.MetricDoc.Tag import com.daml.metrics.api.MetricQualification object MetricDoc { final case class Item( - tag: Tag, name: String, metricType: String, qualification: MetricQualification, diff --git a/sdk/observability/metrics/src/main/scala/com/daml/metrics/api/MetricDoc.scala b/sdk/observability/metrics/src/main/scala/com/daml/metrics/api/MetricDoc.scala deleted file mode 100644 index 9e8b745da44d..000000000000 --- a/sdk/observability/metrics/src/main/scala/com/daml/metrics/api/MetricDoc.scala +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -package com.daml.metrics.api - -import scala.annotation.StaticAnnotation - -object MetricDoc { - // How to use the MetricDoc tags to provide documentation for metrics: - // -- use Tag to annotate a unique metric located in a single place: a.b.c - // -- use GroupTag for similar leaf metrics that are rooted at multiple places: a.*.c - // -- use FanTag when a single root fans out into a collection of similar but distinctly named metrics: a.b.* - - // The Tag can be defined to document a single metric. Its summary, description and - // qualification will be present as a separate documentation entry unless a GroupTag is defined - // for the class that may belongs. - // labelsWithDescription must contain the labels that can be attached to the metrics. - // It must be represented as literal strings, as the documentation is built based on static annotations. - // Example: Map("label" -> "description"). Even if the label is a constant, it cannot be referenced, therefore - // this is not an acceptable use: Map(SomeObject.SomeConstant -> "description") - case class Tag( - summary: String, - description: String, - qualification: MetricQualification, - labelsWithDescription: Map[String, String] = Map.empty, - ) extends StaticAnnotation - - // The GroupTag can be defined for metrics that belong in the same class, are used in multiple - // places and can be grouped using a wildcard (the representative). The metrics of the class - // should be annotated with a Tag. - case class GroupTag(representative: String, groupableClass: Class[_]) extends StaticAnnotation - - // The FanTag is used to define a documentation entry that will fan out and represent all the - // metrics that are tagged with a FanInstanceTag and whose name matches the given representative - // wildcard. - case class FanTag( - representative: String, - summary: String, - description: String, - qualification: MetricQualification, - ) extends StaticAnnotation - - // This tag works in combination with the FanTag and declares a metric that can be represented in - // the documentation by the info of the corresponding FanTag. - case class FanInstanceTag() extends StaticAnnotation - -} diff --git a/sdk/observability/metrics/src/main/scala/com/daml/metrics/api/MetricQualification.scala b/sdk/observability/metrics/src/main/scala/com/daml/metrics/api/MetricQualification.scala index 67b3db1ab3c7..f6ef6ef78884 100644 --- a/sdk/observability/metrics/src/main/scala/com/daml/metrics/api/MetricQualification.scala +++ b/sdk/observability/metrics/src/main/scala/com/daml/metrics/api/MetricQualification.scala @@ -7,6 +7,9 @@ package com.daml.metrics.api sealed trait MetricQualification object MetricQualification { + /** All possible metric qualifications */ + lazy val All: Seq[MetricQualification] = Seq(Latency, Traffic, Errors, Saturation, Debug) + /** Any metric measuring processing time of some sort */ case object Latency extends MetricQualification