ashishk-1 commented on a change in pull request #1969: Integration of envoy 
fetcher in pagespeed
URL: 
https://github.com/apache/incubator-pagespeed-mod/pull/1969#discussion_r356634137
 
 

 ##########
 File path: pagespeed/envoy/envoy_cluster_manager.cc
 ##########
 @@ -0,0 +1,104 @@
+#include "envoy_cluster_manager.h"
+
+#include <sys/file.h>
+
+#include <chrono>
+#include <fstream>
+#include <iostream>
+#include <memory>
+#include <random>
+
+#include "envoy/stats/store.h"
+
+#include "external/envoy/include/envoy/event/dispatcher.h"
+#include "external/envoy/source/common/api/api_impl.h"
+#include "external/envoy/source/common/config/utility.h"
+#include "external/envoy/source/common/event/real_time_system.h"
+#include "external/envoy/source/common/init/manager_impl.h"
+#include "external/envoy/source/common/local_info/local_info_impl.h"
+#include "external/envoy/source/common/protobuf/message_validator_impl.h"
+#include "external/envoy/source/common/runtime/runtime_impl.h"
+#include "external/envoy/source/common/singleton/manager_impl.h"
+#include "external/envoy/source/common/stats/allocator_impl.h"
+#include "external/envoy/source/common/stats/thread_local_store.h"
+#include "external/envoy/source/common/thread_local/thread_local_impl.h"
+#include "external/envoy/source/common/upstream/cluster_manager_impl.h"
+#include "external/envoy/source/exe/platform_impl.h"
+#include "external/envoy/source/exe/process_wide.h"
+#include 
"external/envoy/source/extensions/transport_sockets/tls/context_manager_impl.h"
+#include 
"external/envoy/source/extensions/transport_sockets/well_known_names.h"
+#include "external/envoy/source/server/config_validation/admin.h"
+#include "external/envoy/source/server/options_impl_platform.h"
+
+namespace net_instaweb {
+
+EnvoyClusterManager::EnvoyClusterManager()
+    : init_watcher_("envoyfetcher", []() {}), secret_manager_(config_tracker_),
+      validation_context_(false, false), init_manager_("init_manager"),
+      local_info_(new Envoy::LocalInfo::LocalInfoImpl(
+          {}, 
Envoy::Network::Utility::getLocalAddress(Envoy::Network::Address::IpVersion::v4),
+          "envoyfetcher_service_zone", "envoyfetcher_service_cluster",
+          "envoyfetcher_service_node")),
+      stats_allocator_(symbol_table_), store_root_(stats_allocator_),
+      http_context_(store_root_.symbolTable()) {
+  initClusterManager();
+}
+
+EnvoyClusterManager::~EnvoyClusterManager() {
+  tls_.shutdownGlobalThreading();
+  store_root_.shutdownThreading();
+  if (cluster_manager_ != nullptr) {
+    cluster_manager_->shutdown();
+  }
+  tls_.shutdownThread();
+}
+
+void configureComponentLogLevels(spdlog::level::level_enum level) {
+  // TODO(oschaaf): Add options to tweak the log level of the various log tags
+  // that are available.
+  Envoy::Logger::Registry::setLogLevel(level);
+  Envoy::Logger::Logger* logger_to_change = 
Envoy::Logger::Registry::logger("main");
+  logger_to_change->setLevel(level);
+}
+
+void EnvoyClusterManager::initClusterManager() {
+  auto logging_context = 
std::make_unique<Envoy::Logger::Context>(spdlog::level::from_str("trace"),
+                                                                  
"[%T.%f][%t][%L] %v", log_lock);
+  configureComponentLogLevels(spdlog::level::from_str("trace"));
 
 Review comment:
   I had kept it at trace level to get all dumps since there were many cluster 
configuration issues earlier.
   Now I have moved to error level. Code pushed in 
https://github.com/apache/incubator-pagespeed-mod/pull/1969/commits/05e80e98faba31ff5a94f1244b1833fa88a1fae4
   I will also implement log sink to redirect the logs to pagespeed logging 
module.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to