Skip to content

Commit 8108119

Browse files
committed
Restore TRITONSERVER_MetricObserve
1 parent c80bd7e commit 8108119

File tree

1 file changed

+1
-24
lines changed

1 file changed

+1
-24
lines changed

src/metric.cc

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -358,38 +358,15 @@ Metric::Increment(const double& value)
358358
void
359359
Metric::SetValue(const double& value)
360360
{
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-
371361
auto triton_metric = reinterpret_cast<TRITONSERVER_Metric*>(metric_address_);
372362
THROW_IF_TRITON_ERROR(TRITONSERVER_MetricSet(triton_metric, value));
373363
}
374364

375365
void
376366
Metric::Observe(const double& value)
377367
{
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-
391368
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));
393370
}
394371

395372
double

0 commit comments

Comments
 (0)