LCOV - code coverage report
Current view: top level - media/server/main/include - IMetricsReporter.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2026-09-11 17:36:12 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /*
       2              :  * If not stated otherwise in this file or this component's LICENSE file the
       3              :  * following copyright and licenses apply:
       4              :  *
       5              :  * Copyright 2026 Sky UK
       6              :  *
       7              :  * Licensed under the Apache License, Version 2.0 (the "License");
       8              :  * you may not use this file except in compliance with the License.
       9              :  * You may obtain a copy of the License at
      10              :  *
      11              :  * http://www.apache.org/licenses/LICENSE-2.0
      12              :  *
      13              :  * Unless required by applicable law or agreed to in writing, software
      14              :  * distributed under the License is distributed on an "AS IS" BASIS,
      15              :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      16              :  * See the License for the specific language governing permissions and
      17              :  * limitations under the License.
      18              :  */
      19              : 
      20              : #ifndef FIREBOLT_RIALTO_SERVER_I_METRICS_REPORTER_H_
      21              : #define FIREBOLT_RIALTO_SERVER_I_METRICS_REPORTER_H_
      22              : 
      23              : #include "ControlCommon.h"
      24              : #include "StateMetricsAggregator.h"
      25              : #include <cstdint>
      26              : #include <memory>
      27              : #include <string>
      28              : 
      29              : namespace firebolt::rialto::server
      30              : {
      31              : /**
      32              :  * @brief Periodic sample data reported each sampling interval.
      33              :  */
      34              : struct PeriodicMetricsReport
      35              : {
      36              :     std::uint64_t sampleId{0};
      37              :     std::uint64_t monotonicTimeMs{0};
      38              :     std::string reason;
      39              :     ApplicationState applicationState{ApplicationState::UNKNOWN};
      40              :     std::string appName;
      41              :     std::uint32_t clientPid{0};
      42              :     double clientCpuPercent{0.0};
      43              :     double serverCpuPercent{0.0};
      44              :     double combinedCpuPercent{0.0};
      45              :     std::uint64_t clientCpuTimeMs{0};
      46              :     std::uint64_t serverCpuTimeMs{0};
      47              :     std::uint64_t clientMemoryKb{0};
      48              :     std::uint64_t serverMemoryKb{0};
      49              :     std::uint64_t cgroupMemoryUsageKb{0};
      50              :     std::uint64_t cgroupMemoryLimitKb{0};
      51              :     std::uint64_t shmMemoryKb{0};
      52              : };
      53              : 
      54              : /**
      55              :  * @brief Report emitted when a state period ends (playback state or application state).
      56              :  */
      57              : struct StateTransitionReport
      58              : {
      59              :     std::string context; // e.g. "session=1" or "global"
      60              :     StateMetricsReport metrics;
      61              : };
      62              : 
      63              : /**
      64              :  * @brief Severity level for threshold alerts.
      65              :  */
      66              : enum class ThresholdSeverity
      67              : {
      68              :     WARNING,
      69              :     CRITICAL
      70              : };
      71              : 
      72              : /**
      73              :  * @brief Alert emitted when a metric exceeds a configured threshold.
      74              :  */
      75              : struct ThresholdAlert
      76              : {
      77              :     std::string metricName;
      78              :     double currentValue{0.0};
      79              :     double thresholdValue{0.0};
      80              :     ThresholdSeverity severity{ThresholdSeverity::WARNING};
      81              : };
      82              : 
      83              : /**
      84              :  * @brief Abstract interface for metrics output.
      85              :  *        Implementations can log, push to remote telemetry, or both.
      86              :  */
      87              : class IMetricsReporter
      88              : {
      89              : public:
      90            9 :     IMetricsReporter() = default;
      91           16 :     virtual ~IMetricsReporter() = default;
      92              : 
      93              :     IMetricsReporter(const IMetricsReporter &) = delete;
      94              :     IMetricsReporter &operator=(const IMetricsReporter &) = delete;
      95              :     IMetricsReporter(IMetricsReporter &&) = delete;
      96              :     IMetricsReporter &operator=(IMetricsReporter &&) = delete;
      97              : 
      98              :     virtual void reportPeriodicSample(const PeriodicMetricsReport &report) = 0;
      99              :     virtual void reportStateTransition(const StateTransitionReport &report) = 0;
     100              :     virtual void reportThresholdExceeded(const ThresholdAlert &alert) = 0;
     101              : };
     102              : } // namespace firebolt::rialto::server
     103              : 
     104              : #endif // FIREBOLT_RIALTO_SERVER_I_METRICS_REPORTER_H_
        

Generated by: LCOV version 2.0-1