@@ -45,11 +45,13 @@ import org.opensearch.observability.util.logger
4545 * "application_id": "KE1Ie34BbsTr-CsB4G6Y",
4646 * "user_configs": "{\"dataConfig\":\"{}\",\"layoutConfig\": \"{}\"}",
4747 * "sub_type": "metric",
48+ * "metric_type": "OpenTelemetryMetric",
4849 * "units_of_measure: "hours (h)",
4950 * "labels": [
5051 * {"label":"avg"},
5152 * {"label":"count"},
5253 * ]
54+
5355 * }
5456 * }</pre>
5557 */
@@ -65,6 +67,7 @@ internal data class SavedVisualization(
6567 val applicationId : String? = null ,
6668 val userConfigs : String? = null ,
6769 val subType : String? ,
70+ val metricType : String? = null ,
6871 val unitsOfMeasure : String? = null ,
6972 val selectedLabels : SelectedLabels ? = null ,
7073) : BaseObjectData {
@@ -81,6 +84,7 @@ internal data class SavedVisualization(
8184 private const val APPLICATION_ID_TAG = " application_id"
8285 private const val USER_CONFIGS_TAG = " user_configs"
8386 private const val SUB_TYPE_TAG = " sub_type"
87+ private const val METRIC_TYPE_TAG = " metric_type"
8488 private const val UNITS_OF_MEASURE_TAG = " units_of_measure"
8589 private const val SELECTED_LABELS_TAG = " selected_labels"
8690
@@ -111,6 +115,7 @@ internal data class SavedVisualization(
111115 var applicationId: String? = null
112116 var userConfigs: String? = null
113117 var subType: String? = null
118+ var metricType: String? = null
114119 var unitsOfMeasure: String? = null
115120 var selectedLabels: SelectedLabels ? = null
116121 XContentParserUtils .ensureExpectedToken(XContentParser .Token .START_OBJECT , parser.currentToken(), parser)
@@ -128,6 +133,7 @@ internal data class SavedVisualization(
128133 APPLICATION_ID_TAG -> applicationId = parser.text()
129134 USER_CONFIGS_TAG -> userConfigs = parser.text()
130135 SUB_TYPE_TAG -> subType = parser.text()
136+ METRIC_TYPE_TAG -> metricType = parser.text()
131137 UNITS_OF_MEASURE_TAG -> unitsOfMeasure = parser.text()
132138 SELECTED_LABELS_TAG -> selectedLabels = SelectedLabels .parse(parser)
133139 else -> {
@@ -147,8 +153,9 @@ internal data class SavedVisualization(
147153 applicationId,
148154 userConfigs,
149155 subType,
156+ metricType,
150157 unitsOfMeasure,
151- selectedLabels
158+ selectedLabels,
152159 )
153160 }
154161 }
@@ -177,6 +184,7 @@ internal data class SavedVisualization(
177184 applicationId = input.readOptionalString(),
178185 userConfigs = input.readOptionalString(),
179186 subType = input.readString(),
187+ metricType = input.readOptionalString(),
180188 unitsOfMeasure = input.readOptionalString(),
181189 selectedLabels = input.readOptionalWriteable(SelectedLabels .reader),
182190 )
@@ -195,6 +203,7 @@ internal data class SavedVisualization(
195203 output.writeOptionalString(applicationId)
196204 output.writeOptionalString(userConfigs)
197205 output.writeString(subType)
206+ output.writeOptionalString(metricType)
198207 output.writeOptionalString(unitsOfMeasure)
199208 output.writeOptionalWriteable(selectedLabels)
200209 }
@@ -215,6 +224,7 @@ internal data class SavedVisualization(
215224 .fieldIfNotNull(APPLICATION_ID_TAG , applicationId)
216225 .fieldIfNotNull(USER_CONFIGS_TAG , userConfigs)
217226 .fieldIfNotNull(SUB_TYPE_TAG , subType)
227+ .fieldIfNotNull(METRIC_TYPE_TAG , metricType)
218228 .fieldIfNotNull(UNITS_OF_MEASURE_TAG , unitsOfMeasure)
219229 .fieldIfNotNull(SELECTED_LABELS_TAG , selectedLabels)
220230 return builder.endObject()
0 commit comments