Branch data Line data Source code
1 : : // Copyright 2026 HPActor Contributors
2 : : //
3 : : // Licensed under the Apache License, Version 2.0 (the "License");
4 : : // you may not use this file except in compliance with the License.
5 : : // You may obtain a copy of the License at
6 : : //
7 : : // http://www.apache.org/licenses/LICENSE-2.0
8 : : //
9 : : // Unless required by applicable law or agreed to in writing, software
10 : : // distributed under the License is distributed on an "AS IS" BASIS,
11 : : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : : // See the License for the specific language governing permissions and
13 : : // limitations under the License.
14 : :
15 : : #pragma once
16 : :
17 : : #include <hpactor/actor/event_based_actor.hpp>
18 : : #include <hpactor/metrics/metrics_aggregator.hpp>
19 : : #include <hpactor/metrics/metrics_formatter.hpp>
20 : : #include <hpactor/metrics/metrics_registry.hpp>
21 : : #include <hpactor/metrics/metrics_ring_buffer.hpp>
22 : : #include <memory>
23 : :
24 : : namespace hpactor::metrics {
25 : :
26 : : class MetricsActor : public EventBasedActor {
27 : : public:
28 : : MetricsActor(ActorSystem& system,
29 : : std::shared_ptr<MpscRingBuffer<MetricEvent>> ring_buffer);
30 : :
31 : : void register_handlers() override;
32 : :
33 : 0 : bool is_system_actor() const override {
34 : 0 : return true;
35 : : }
36 : :
37 : : static constexpr const char* kActorTypeName = "MetricsActor";
38 : :
39 : : private:
40 : : std::shared_ptr<MpscRingBuffer<MetricEvent>> ring_buffer_;
41 : : MetricRegistry registry_;
42 : : Aggregator aggregator_;
43 : : OpenMetricsFormatter formatter_;
44 : : uint64_t events_lost_{0};
45 : : };
46 : :
47 : : } // namespace hpactor::metrics
|