@@ -358,38 +358,15 @@ Metric::Increment(const double& value)
358
358
void
359
359
Metric::SetValue (const double & value)
360
360
{
361
- // SetValue and Observe share the same C API TRITONSERVER_MetricSet.
362
- // Throws if SetValue is called by a histogram metric.
363
- TRITONSERVER_MetricKind kind;
364
- THROW_IF_TRITON_ERROR (TRITONSERVER_GetMetricKind (
365
- reinterpret_cast <TRITONSERVER_Metric*>(metric_address_), &kind));
366
- if (kind == TRITONSERVER_METRIC_KIND_HISTOGRAM) {
367
- throw PythonBackendException (
368
- " TRITONSERVER_METRIC_KIND_HISTOGRAM does not support SetValue" );
369
- }
370
-
371
361
auto triton_metric = reinterpret_cast <TRITONSERVER_Metric*>(metric_address_);
372
362
THROW_IF_TRITON_ERROR (TRITONSERVER_MetricSet (triton_metric, value));
373
363
}
374
364
375
365
void
376
366
Metric::Observe (const double & value)
377
367
{
378
- // SetValue and Observe share the same C API TRITONSERVER_MetricSet.
379
- // Throws if Observe is called by a non-histogram metric.
380
- TRITONSERVER_MetricKind kind;
381
- THROW_IF_TRITON_ERROR (TRITONSERVER_GetMetricKind (
382
- reinterpret_cast <TRITONSERVER_Metric*>(metric_address_), &kind));
383
- if (kind == TRITONSERVER_METRIC_KIND_COUNTER) {
384
- throw PythonBackendException (
385
- " TRITONSERVER_METRIC_KIND_COUNTER does not support Observe" );
386
- } else if (kind == TRITONSERVER_METRIC_KIND_GAUGE) {
387
- throw PythonBackendException (
388
- " TRITONSERVER_METRIC_KIND_GAUGE does not support Observe" );
389
- }
390
-
391
368
auto triton_metric = reinterpret_cast <TRITONSERVER_Metric*>(metric_address_);
392
- THROW_IF_TRITON_ERROR (TRITONSERVER_MetricSet (triton_metric, value));
369
+ THROW_IF_TRITON_ERROR (TRITONSERVER_MetricObserve (triton_metric, value));
393
370
}
394
371
395
372
double
0 commit comments