-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for multiple metrics endpoints #25
Allow for multiple metrics endpoints #25
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice
db7d98a
to
ccbdea2
Compare
0298ea2
to
020c9ba
Compare
thread_local metrics::impl::metric_implementations metric_impls; | ||
|
||
metrics::impl::metric_implementations& metrics::impl::get_metric_implementations() { | ||
return metric_impls; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why a static thread_local
has initialisation order problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean you don't understand why it's declared here, or you don't understand why it's not static
?
It is declared here because metric_impls
needs to be alive during the reactor (declared here) cleanup as metrics are de-registered at that point. thread_local
destructors are called in reverse order of initialisation, so metric_impls
needs to initialise ahead of the reactor_holder.
It's not static as metric_impls
needs external linkage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean I don't know why its previous location as a static local had a problem.
But if it's an uninitialization order fiasco, then ok.
020c9ba
to
ae95909
Compare
ae95909
to
d91b995
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Would be nice to have another reviewer, and maybe send it to the mailing list.
I've submitted it to the mailing list: https://groups.google.com/g/seastar-dev/c/xtZnIU14u5c. |
@@ -358,7 +363,7 @@ using values_reference = shared_ptr<values_copy>; | |||
|
|||
foreign_ptr<values_reference> get_values(); | |||
|
|||
shared_ptr<impl> get_local_impl(); | |||
shared_ptr<impl> get_local_impl(int handle = default_handle()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The handle can be a strong type instead of int
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does seastar have any utility for named types? I went looking for one, but didn't find anything.
Prior to this patch seastar only exposes one global metrics::impl::impl object which holds all metric related data for one application. This patch changes the implementation details such that multiple metrics::impl::impl objects can exist for any given application. Said objects are stored into a map on each shard and created dinamically whenever requested. A metrics::impl::impl is identified by an integer handle that acts as the key for the storage map. Implementation note: in order to avoid issues caused by the ordering of static thread_local objects I had to declare the storage in reactor.cc. (cherry picked from commit 585a8af)
This patch extends the metrics internal apis to use a specific metrics::impl::impl object identified by its integer handle. (cherry picked from commit 6ee4af7)
This patch extends the metrics user facing apis to use a specific metrics::impl::impl object identified by its integer handle. Note that the constructor of 'metric_groups' is marked explicit in this patch and updates two call sites where the constructor was used implicitly.
This patch removes two subsequent calls to `get_local_impl` and reuses the returned handle in that scope.
This patch extends the user facing prometheus apis allowing the user to specify the internal metrics implementation to be used through a handle. Additionally, 'add_prometheus_routes' now takes an argument that specifies the route on which to advertise the metrics. This enables different metrics "namespaces" to be served by different endpoints in isolation. (cherry picked from commit 6189522)
This patch extends the scollectd apis with the ability to select the internal metrics implementation to be used by providing a handle. (cherry picked from commit d4331d1)
d91b995
to
91129e2
Compare
Previously, seastar collected all metrics (and metrics related metadata) in a single object (
metrics::impl::impl
). The consequence of this is that there was no way to have multiple metrics namespaces and expose each namespace through its own prometheus endpoint. If an application published a large volume of metrics, the user had to filter them by using by using thename
request parameter of the prometheus endpoint. The downside of this approach is that the user must have knowledge of the metrics set and, even in that case, some queries cannot be expressed in terms of substring matching (i.e. the existing filtering implementation).A more flexible approach is to allow applications to categorise metrics at the time of registering them and expose the different metrics set on different prometheus endpoints if required. This is the approach taken for this PR. The metrics registration api
now allows applications to specify the internal metrics implementation (think of it as a metrics bucket) via an integer handle. Internally, whenever a shard needs to handle a metric related operation for a handle it hasn't seen before, a new
metrics::impl::impl
object is created on the fly. This leads to a simple api, as applications don't need to pre-register metric implementation before adding groups.Here is an example of how to add metric groups to a specific "bucket" and expose each "bucket" on a prometheus endpoint.
Metrics in the
foo
group will be exposed on the defaultmetric
prometheus endpoint, while thebaz
group will be exposedon the
extra_metrics
endpoint.NB: Previous PR here
force push:
std::unordered_map
for storing the metric implementations. This allows for the removal ofthe handle from the implementation object itself.
force push:
try_emplace
default_handle
function to the public metrics interfaceget_local_impl
force push:
metric_groups
level. Previously, each group within ametric_groups
could beassociated with its own metrics implementation. It makes more sense for all the groups within a
metric_groups
object to push metrics into the same internal object.
force push:
force push:
seastar::metrics::default_handle
instead ofseastar::metrics::impl::default_handle
metric_groups
constructor where it was called implicitlyforce push:
v22.2.x
and fixed merge conflicts. This mostly consisted of moving thehandle
argument, that was added to much of the metrics interface, behind the
skip_when_empty
argument.