> For the complete documentation index, see [llms.txt](https://obsrv.sunbird.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://obsrv.sunbird.org/guides/connectors-developer-guide/classes/metricdata-class.md).

# MetricData Class

### Overview

The `MetricData` case class is a part of the `org.sunbird.obsrv.job.model.Models` package. It encapsulates metric information, including a map of metric names to their values and a list of labels associated with these metrics. This class is useful for representing and managing metrics data within the application.

### Class Definition

```scala
package org.sunbird.obsrv.job.model.Models

case class MetricData(
  metric: Map[String, Long],
  labels: List[Map[String, String]]
)
```

### Fields

#### `metric: Map[String, Long]`

* **Description**: A map where the keys are metric names and the values are the corresponding metric values.
* **Type**: `Map[String, Long]`

#### `labels: List[Map[String, String]]`

* **Description**: A list of maps, where each map represents a set of labels associated with the metrics.
* **Type**: `List[Map[String, String]]`

### Usage

The `MetricData` case class is used to encapsulate and manage metrics data, including the metric values and their associated labels. It provides a structured way to represent metrics in the application.

#### Example

```scala
import org.sunbird.obsrv.job.model.Models.MetricData

val metric = Map("metric1" -> 100L, "metric2" -> 200L)
val labels = List(
  Map("label1" -> "value1", "label2" -> "value2"),
  Map("label3" -> "value3", "label4" -> "value4")
)

val metricData = MetricData(metric, labels)

// Accessing metric data fields
println(s"Metrics: ${metricData.metric}")
println(s"Labels: ${metricData.labels}")
```

### JSON Representation

An instance of `MetricData` can be serialized to JSON as follows:

```json
{
  "metric": {
    "metric1": 100,
    "metric2": 200
  },
  "labels": [
    {
      "label1": "value1",
      "label2": "value2"
    },
    {
      "label3": "value3",
      "label4": "value4"
    }
  ]
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://obsrv.sunbird.org/guides/connectors-developer-guide/classes/metricdata-class.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
