Skip to content

Metrics Tags support? #16

Description

@HassanWahba

Hello there!

is there an export function for the build-in tags that sonarqube assigns to every metric?

edits are needed in PrometheusWebService.

I thought of something like this:

String tags = "[";
                for(int i = 0; i < component.getTags().getTagsCount(); i++){
                		tags += component.getTags().getTags(i);
                		tags += (i == component.getTags().getTagsCount() -1)? "]" : ", ";
                }

                this.gauges.get(measure.getMetric())
                                        .labels(projectName, componentPath, String.valueOf(componentLevel), componentName, parentName, tags)
                                        .set(Double.valueOf(measure.getValue()));
              }

with this small update here...

  private void updateEnabledGauges() {

    CollectorRegistry.defaultRegistry.clear();

    this.enabledMetrics.forEach(metric -> this.gauges.put(  // For each enabled metric add to the gauges map:
        metric.getKey(), Gauge.build()                      // ... add key value pair: key = metric key, value = Gauge object
            .name(METRIC_PREFIX + metric.getKey())          // ... build gauge name from prefix and metric key
            .help(metric.getDescription())                  // ... set help text as metric description (shown in settings UI)
            .labelNames("project", "component", "level", "name", "parent", "**_tags_**")
            .register()));
  }

but it doesn't seem to work when deploying... help ?
thanks

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions