MCPcopy Create free account
hub / github.com/apache/impala / WriteAsPrometheus

Method WriteAsPrometheus

be/src/kudu/util/metrics.cc:407–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

405}
406
407Status MetricEntity::WriteAsPrometheus(PrometheusWriter* writer) const {
408 static const string kIdMaster = "kudu.master";
409 static const string kIdTabletServer = "kudu.tabletserver";
410
411 if (strcmp(prototype_->name(), "server") != 0) {
412 // Only server-level metrics are emitted in Prometheus format as of now,
413 // non-server metric entities are currently silently skipped.
414 //
415 // TODO(KUDU-3563): output tablet-level metrics in Prometheus format as well
416 return Status::OK();
417 }
418
419 // Empty filters result in getting all the metrics for this MetricEntity.
420 //
421 // TODO(aserbin): instead of hard-coding, pass MetricFilters as a parameter
422 MetricFilters filters;
423 filters.entity_level = "debug";
424
425 MetricMap metrics;
426 AttributeMap attrs;
427 const auto s = GetMetricsAndAttrs(filters, &metrics, &attrs);
428 if (s.IsNotFound()) {
429 // Status::NotFound is returned when this entity has been filtered, treat it
430 // as OK, and skip printing it.
431 return Status::OK();
432 }
433 RETURN_NOT_OK(s);
434
435 if (id_ == kIdMaster) {
436 // Prefix all master metrics with 'kudu_master_'.
437 static const string kMasterPrefix = "kudu_master_";
438 WriteMetricsPrometheus(writer, metrics, kMasterPrefix);
439 return Status::OK();
440 }
441 if (id_ == kIdTabletServer) {
442 // Prefix all tablet server metrics with 'kudu_tserver_'.
443 static const string kTabletServerPrefix = "kudu_tserver_";
444 WriteMetricsPrometheus(writer, metrics, kTabletServerPrefix);
445 return Status::OK();
446 }
447
448 return Status::NotSupported(
449 Substitute("$0: unexpected server-level metric entity", id_));
450}
451
452Status MetricEntity::CollectTo(MergedEntityMetrics* collections,
453 const MetricFilters& filters,

Callers 2

WriteMetricsPrometheusFunction · 0.80
TEST_FFunction · 0.80

Calls 15

OKFunction · 0.85
WriteMetricsPrometheusFunction · 0.85
NotSupportedFunction · 0.85
SubstituteFunction · 0.85
SubstituteAndAppendFunction · 0.85
RetireOldMetricsMethod · 0.80
WriteEntryMethod · 0.80
clearMethod · 0.65
nameMethod · 0.45
idMethod · 0.45
WriteHelpAndTypeMethod · 0.45
unitMethod · 0.45

Tested by 1

TEST_FFunction · 0.64