LCOV - code coverage report
Current view: top level - source/common/upstream - health_checker_event_logger.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 0 11 0.0 %
Date: 2024-01-05 06:35:25 Functions: 0 1 0.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "envoy/access_log/access_log.h"
       4             : #include "envoy/common/callback.h"
       5             : #include "envoy/config/accesslog/v3/accesslog.pb.h"
       6             : #include "envoy/config/accesslog/v3/accesslog.pb.validate.h"
       7             : #include "envoy/config/core/v3/health_check.pb.h"
       8             : #include "envoy/data/core/v3/health_check_event.pb.h"
       9             : #include "envoy/event/timer.h"
      10             : #include "envoy/runtime/runtime.h"
      11             : #include "envoy/server/factory_context.h"
      12             : #include "envoy/server/health_checker_config.h"
      13             : #include "envoy/stats/scope.h"
      14             : #include "envoy/type/matcher/string.pb.h"
      15             : #include "envoy/upstream/health_check_event_sink.h"
      16             : #include "envoy/upstream/health_checker.h"
      17             : 
      18             : #include "source/common/access_log/access_log_impl.h"
      19             : #include "source/common/common/logger.h"
      20             : #include "source/common/config/utility.h"
      21             : #include "source/common/protobuf/utility.h"
      22             : 
      23             : namespace Envoy {
      24             : namespace Upstream {
      25             : 
      26             : class HealthCheckEventLoggerImpl : public HealthCheckEventLogger {
      27             : public:
      28             :   HealthCheckEventLoggerImpl(const envoy::config::core::v3::HealthCheck& health_check_config,
      29             :                              Server::Configuration::HealthCheckerFactoryContext& context)
      30           0 :       : time_source_(context.serverFactoryContext().mainThreadDispatcher().timeSource()) {
      31             : 
      32             :     // TODO(botengyao): Remove the file_ creation here into the file based health check
      33             :     // event sink. In this way you can remove the file_ based code from the createHealthCheckEvent
      34           0 :     if (!health_check_config.event_log_path().empty() /* deprecated */) {
      35           0 :       file_ = context.serverFactoryContext().accessLogManager().createAccessLog(
      36           0 :           Filesystem::FilePathAndType{Filesystem::DestinationType::File,
      37           0 :                                       health_check_config.event_log_path()});
      38           0 :     }
      39           0 :     for (const auto& config : health_check_config.event_logger()) {
      40           0 :       auto& factory = Config::Utility::getAndCheckFactory<HealthCheckEventSinkFactory>(config);
      41           0 :       event_sinks_.push_back(factory.createHealthCheckEventSink(config.typed_config(), context));
      42           0 :     }
      43           0 :   }
      44             : 
      45             :   void logEjectUnhealthy(envoy::data::core::v3::HealthCheckerType health_checker_type,
      46             :                          const HostDescriptionConstSharedPtr& host,
      47             :                          envoy::data::core::v3::HealthCheckFailureType failure_type) override;
      48             :   void logAddHealthy(envoy::data::core::v3::HealthCheckerType health_checker_type,
      49             :                      const HostDescriptionConstSharedPtr& host, bool first_check) override;
      50             :   void logUnhealthy(envoy::data::core::v3::HealthCheckerType health_checker_type,
      51             :                     const HostDescriptionConstSharedPtr& host,
      52             :                     envoy::data::core::v3::HealthCheckFailureType failure_type,
      53             :                     bool first_check) override;
      54             :   void logDegraded(envoy::data::core::v3::HealthCheckerType health_checker_type,
      55             :                    const HostDescriptionConstSharedPtr& host) override;
      56             :   void logNoLongerDegraded(envoy::data::core::v3::HealthCheckerType health_checker_type,
      57             :                            const HostDescriptionConstSharedPtr& host) override;
      58             : 
      59             : private:
      60             :   void createHealthCheckEvent(
      61             :       envoy::data::core::v3::HealthCheckerType health_checker_type, const HostDescription& host,
      62             :       std::function<void(envoy::data::core::v3::HealthCheckEvent&)> callback) const;
      63             :   TimeSource& time_source_;
      64             :   AccessLog::AccessLogFileSharedPtr file_;
      65             :   std::vector<HealthCheckEventSinkPtr> event_sinks_;
      66             : };
      67             : 
      68             : } // namespace Upstream
      69             : } // namespace Envoy

Generated by: LCOV version 1.15