Class VManagerMetricsClient

java.lang.Object
org.jenkinsci.plugins.vmanager.charts.util.VManagerMetricsClient

public final class VManagerMetricsClient extends Object
Thin client around the vManager /rest/metrics/get endpoint used to obtain coverage / vPlan attribute values for a build.

The endpoint expects a POST with a JSON body of the form:

{
   "hierarchy": "Verification Metrics/Instances",
   "sticky-context": {
     "runs-rs": {
       "filter": {
         "@c":         ".RelationFilter",
         "relationName":"session",
         "filter": { "@c":".InFilter", "attName":"name", "operand":"IN",
                     "values":["session_1","session_2"] }
       }
     },
     "refinement-files": ["/abs/path/to/file1", "/abs/path/to/file2"]
   },
   "projection": { "selection": ["attribute_id_1", "attribute_id_2"] },
   "verification-scope": "..."
 }

The response is a JSON array of objects; each object contains the projected attribute ids as keys. Numeric values are summed across rows.

  • Field Details

    • DEFAULT_HIERARCHY

      public static final String DEFAULT_HIERARCHY
      Default value used when the user-supplied hierarchy is blank.
      See Also:
  • Method Details

    • fetchMetricSums

      public static Map<String,Double> fetchMetricSums(String baseUrl, String hierarchy, String verificationScope, Collection<String> sessionNames, Collection<String> refinementFiles, Collection<String> attributeIds, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials creds, CoverageRoutingContext routingCtx, TaskListener listener) throws IOException
      Posts a metrics-get query and returns the summed numeric value for each requested attribute id across all rows the server returns.
      Parameters:
      baseUrl - vManager server base URL.
      hierarchy - coverage / vPlan hierarchy path; if null/blank, DEFAULT_HIERARCHY is used.
      verificationScope - verification scope string; null is sent as empty.
      sessionNames - session names that drive the RelationFilter; null/empty returns zeros.
      refinementFiles - absolute filesystem paths to refinement files; may be null/empty.
      attributeIds - attribute ids to project; null/empty returns an empty map.
      creds - HTTP Basic credentials; may be null.
      routingCtx - per-build routing-OID holder. The first call within a build is sent without x-vmgr-routing-oid; subsequent calls echo back the value the server returned in the previous response. May be null (no routing headers sent).
      listener - build console for payload / header logging; may be null.
      Returns:
      map of attribute id → summed value (entries pre-seeded to 0.0 for every requested id). Never null.
      Throws:
      IOException