Skip to content

Commit

Permalink
execution_stage: fix wrong exception thrown for non-unique stages
Browse files Browse the repository at this point in the history
The metrics API now also enforces uniqueness, and as it is called before
execution stage registration, it throws earlier, and confuses the unit test
because a different exception type is expected.

Fix by reversing the order of metrics registration and execution stage
registration.
  • Loading branch information
avikivity committed May 3, 2017
1 parent e7fbd02 commit 4a3118c
Showing 1 changed file with 30 additions and 26 deletions.
56 changes: 30 additions & 26 deletions core/execution_stage.hh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "metrics.hh"
#include "util/reference_wrapper.hh"
#include "util/gcc6-concepts.hh"
#include "../util/defer.hh"

namespace seastar {

Expand Down Expand Up @@ -407,34 +408,37 @@ auto make_execution_stage(const sstring& name, Ret (Object::*fn)(Args...) const)

inline execution_stage::execution_stage(const sstring& name)
: _name(name)
, _metric_group("execution_stages", {
metrics::make_derive("tasks_scheduled",
metrics::description("Counts tasks scheduled by execution stages"),
{ metrics::label_instance("execution_stage", name), },
[name, &esm = internal::execution_stage_manager::get()] {
return esm.get_stage(name)->get_stats().tasks_scheduled;
}),
metrics::make_derive("tasks_preempted",
metrics::description("Counts tasks which were preempted before execution all queued operations"),
{ metrics::label_instance("execution_stage", name), },
[name, &esm = internal::execution_stage_manager::get()] {
return esm.get_stage(name)->get_stats().tasks_preempted;
}),
metrics::make_derive("function_calls_enqueued",
metrics::description("Counts function calls added to execution stages queues"),
{ metrics::label_instance("execution_stage", name), },
[name, &esm = internal::execution_stage_manager::get()] {
return esm.get_stage(name)->get_stats().function_calls_enqueued;
}),
metrics::make_derive("function_calls_executed",
metrics::description("Counts function calls executed by execution stages"),
{ metrics::label_instance("execution_stage", name), },
[name, &esm = internal::execution_stage_manager::get()] {
return esm.get_stage(name)->get_stats().function_calls_executed;
}),
})

{
internal::execution_stage_manager::get().register_execution_stage(*this);
auto undo = defer([&] { internal::execution_stage_manager::get().unregister_execution_stage(*this); });
_metric_group = metrics::metric_group("execution_stages", {
metrics::make_derive("tasks_scheduled",
metrics::description("Counts tasks scheduled by execution stages"),
{ metrics::label_instance("execution_stage", name), },
[name, &esm = internal::execution_stage_manager::get()] {
return esm.get_stage(name)->get_stats().tasks_scheduled;
}),
metrics::make_derive("tasks_preempted",
metrics::description("Counts tasks which were preempted before execution all queued operations"),
{ metrics::label_instance("execution_stage", name), },
[name, &esm = internal::execution_stage_manager::get()] {
return esm.get_stage(name)->get_stats().tasks_preempted;
}),
metrics::make_derive("function_calls_enqueued",
metrics::description("Counts function calls added to execution stages queues"),
{ metrics::label_instance("execution_stage", name), },
[name, &esm = internal::execution_stage_manager::get()] {
return esm.get_stage(name)->get_stats().function_calls_enqueued;
}),
metrics::make_derive("function_calls_executed",
metrics::description("Counts function calls executed by execution stages"),
{ metrics::label_instance("execution_stage", name), },
[name, &esm = internal::execution_stage_manager::get()] {
return esm.get_stage(name)->get_stats().function_calls_executed;
}),
});
undo.cancel();
}

inline execution_stage::~execution_stage()
Expand Down

0 comments on commit 4a3118c

Please sign in to comment.