diff --git a/CMakeLists.txt b/CMakeLists.txt index cf530c24e..5629f08d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,7 +126,7 @@ if (NOT DEFINED INSTALL_TARGETS) set(BMQ_TARGET_MQB_NEEDED YES) set(BMQ_TARGET_E_BMQBRKR_NEEDED YES) set(BMQ_TARGET_TUTORIAL_NEEDED YES) - set(BMQ_TARGET_PLUGINS_NEEDED NO) + set(BMQ_TARGET_PROMETHEUS_NEEDED NO) else() bbproject_check_install_target("bmqbrkr" installBMQBRKR) bbproject_check_install_target("BMQBRKR_NIGHTLY" installNightly) @@ -147,7 +147,7 @@ else() set(BMQ_TARGET_BMQ_NEEDED NO) set(BMQ_TARGET_MQB_NEEDED NO) set(BMQ_TARGET_TUTORIAL_NEEDED NO) - set(BMQ_TARGET_PLUGINS_NEEDED NO) + set(BMQ_TARGET_PROMETHEUS_NEEDED NO) bbproject_check_install_target("mwc" installMWC) bbproject_check_install_target("bmq" installBMQ) @@ -197,7 +197,7 @@ else() set(BMQ_TARGET_MQB_NEEDED YES) set(BMQ_TARGET_E_BMQBRKR_NEEDED YES) set(BMQ_TARGET_TUTORIAL_NEEDED YES) - set(BMQ_TARGET_PLUGINS_NEEDED YES) + set(BMQ_TARGET_PROMETHEUS_NEEDED YES) endif() endif() diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index b7fb42489..2dc41f6ac 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -1,10 +1 @@ -# plugins -# ------------ - -if (NOT BMQ_TARGET_PLUGINS_NEEDED) - return() -endif() - -find_package( PkgConfig REQUIRED ) - -bmq_add_plugin( plugins ) +add_subdirectory( "prometheus" ) diff --git a/src/plugins/package/plugins.mem b/src/plugins/package/plugins.mem deleted file mode 100644 index db19ed7ce..000000000 --- a/src/plugins/package/plugins.mem +++ /dev/null @@ -1,5 +0,0 @@ -plugins_entry -plugins_pluginlibrary -plugins_prometheusstatconsumer -plugins_version -plugins_versiontag diff --git a/src/plugins/prometheus/CMakeLists.txt b/src/plugins/prometheus/CMakeLists.txt new file mode 100644 index 000000000..f68dd4d52 --- /dev/null +++ b/src/plugins/prometheus/CMakeLists.txt @@ -0,0 +1,10 @@ +# Prometheus plugin +# ------------ + +if (NOT BMQ_TARGET_PROMETHEUS_NEEDED ) + return() +endif() + +find_package( PkgConfig REQUIRED ) + +bmq_add_plugin( prometheus ) diff --git a/src/plugins/package/plugins.dep b/src/plugins/prometheus/package/prometheus.dep similarity index 100% rename from src/plugins/package/plugins.dep rename to src/plugins/prometheus/package/prometheus.dep diff --git a/src/plugins/prometheus/package/prometheus.mem b/src/plugins/prometheus/package/prometheus.mem new file mode 100644 index 000000000..73263cbf6 --- /dev/null +++ b/src/plugins/prometheus/package/prometheus.mem @@ -0,0 +1,5 @@ +prometheus_entry +prometheus_pluginlibrary +prometheus_prometheusstatconsumer +prometheus_version +prometheus_versiontag diff --git a/src/plugins/plugins_entry.cpp b/src/plugins/prometheus/prometheus_entry.cpp similarity index 74% rename from src/plugins/plugins_entry.cpp rename to src/plugins/prometheus/prometheus_entry.cpp index 26bdc1303..bfa045f89 100644 --- a/src/plugins/plugins_entry.cpp +++ b/src/plugins/prometheus/prometheus_entry.cpp @@ -13,11 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -// plugins_entry.cpp -*-C++-*- +// prometheus_entry.cpp -*-C++-*- -// PLUGINS -#include -#include +// PROMETHEUS +#include +#include // MQB #include @@ -40,12 +40,13 @@ void instantiatePluginLibrary( bslma::ManagedPtr* library, bslma::Allocator* allocator) { - BALL_LOG_SET_CATEGORY("PLUGINS.ENTRY"); + BALL_LOG_SET_CATEGORY("PROMETHEUS.ENTRY"); - BALL_LOG_INFO << "Instantiating 'libplugins.so' plugin library " + BALL_LOG_INFO << "Instantiating 'libprometheus.so' plugin library " "(version: " - << plugins::Version::version() << ")"; + << prometheus::Version::version() << ")"; - *library = bslma::ManagedPtrUtil::allocateManaged( - allocator); + *library = + bslma::ManagedPtrUtil::allocateManaged( + allocator); } diff --git a/src/plugins/plugins_pluginlibrary.cpp b/src/plugins/prometheus/prometheus_pluginlibrary.cpp similarity index 88% rename from src/plugins/plugins_pluginlibrary.cpp rename to src/plugins/prometheus/prometheus_pluginlibrary.cpp index 3d6b3c209..2961c9123 100644 --- a/src/plugins/plugins_pluginlibrary.cpp +++ b/src/plugins/prometheus/prometheus_pluginlibrary.cpp @@ -13,25 +13,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -// plugins_pluginlibrary.cpp -*-C++-*- -#include +// prometheus_pluginlibrary.cpp -*-C++-*- +#include -// PLUGINS -#include -#include - -//// BUL -// #include - -//// SIM -// #include +// PROMETHEUS +#include +#include // BDE #include #include namespace BloombergLP { -namespace plugins { +namespace prometheus { // ------------------- // class PluginLibrary @@ -67,6 +61,7 @@ int PluginLibrary::activate() void PluginLibrary::deactivate() { + // NOTHING } const bsl::vector& PluginLibrary::plugins() const diff --git a/src/plugins/plugins_pluginlibrary.h b/src/plugins/prometheus/prometheus_pluginlibrary.h similarity index 83% rename from src/plugins/plugins_pluginlibrary.h rename to src/plugins/prometheus/prometheus_pluginlibrary.h index cbeb62551..55a0f91bf 100644 --- a/src/plugins/plugins_pluginlibrary.h +++ b/src/plugins/prometheus/prometheus_pluginlibrary.h @@ -13,19 +13,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -// plugins_pluginlibrary.h -*-C++-*- -#ifndef INCLUDED_PLUGINS_PLUGINLIBRARY -#define INCLUDED_PLUGINS_PLUGINLIBRARY +// prometheus_pluginlibrary.h -*-C++-*- +#ifndef INCLUDED_PROMETHEUS_PLUGINLIBRARY +#define INCLUDED_PROMETHEUS_PLUGINLIBRARY -//@PURPOSE: Provide library of enterprise broker plugins for Bloomberg. +//@PURPOSE: Provide library of Prometheus plugin for broker. // //@CLASSES: -// plugins::PluginLibrary: Library of Bloomberg enterprise broker plugins. +// prometheus::PluginLibrary: Library of Prometheus plugin. // //@DESCRIPTION: This component provides the definition for the 'PluginLibrary' -// class, which represents and publishes various plugins for interfacing -// between the BMQ broker (i.e., 'bmqbrkr.tsk') and various enterprise services -// available only within Bloomberg. +// class, which represents and publishes Prometheus plugin for interfacing +// with the BMQ broker (i.e., 'bmqbrkr.tsk'). // MQB #include @@ -39,7 +38,7 @@ #include namespace BloombergLP { -namespace plugins { +namespace prometheus { // =================== // class PluginLibrary // =================== diff --git a/src/plugins/plugins_prometheusstatconsumer.cpp b/src/plugins/prometheus/prometheus_prometheusstatconsumer.cpp similarity index 92% rename from src/plugins/plugins_prometheusstatconsumer.cpp rename to src/plugins/prometheus/prometheus_prometheusstatconsumer.cpp index 45e573b4e..7454eb02e 100644 --- a/src/plugins/plugins_prometheusstatconsumer.cpp +++ b/src/plugins/prometheus/prometheus_prometheusstatconsumer.cpp @@ -13,11 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -// plugins_prometheusstatconsumer.cpp -*-C++-*- -#include +// prometheus_prometheusstatconsumer.cpp -*-C++-*- +#include -// PLUGINS -#include +// PROMETHEUS +#include // MQB #include @@ -46,7 +46,7 @@ #include "prometheus/labels.h" namespace BloombergLP { -namespace plugins { +namespace prometheus { namespace { @@ -57,7 +57,7 @@ const char* k_THREADNAME = "bmqPrometheusPush"; class Tagger { private: // DATA - prometheus::Labels labels; + ::prometheus::Labels labels; public: // MANIPULATORS @@ -110,14 +110,14 @@ class Tagger { } // ACCESSORS - prometheus::Labels& getLabels() { return labels; } + ::prometheus::Labels& getLabels() { return labels; } }; bsl::unique_ptr -makeExporter(const bsl::string& mode, - const bsl::string& host, - const bsl::size_t port, - std::shared_ptr& registry); +makeExporter(const bsl::string& mode, + const bsl::string& host, + const bsl::size_t port, + std::shared_ptr< ::prometheus::Registry>& registry); } // close unnamed namespace @@ -148,7 +148,7 @@ PrometheusStatConsumer::PrometheusStatConsumer( , d_snapshotId(0) , d_actionCounter(0) , d_isStarted(false) -, d_prometheusRegistry_p(std::make_shared()) +, d_prometheusRegistry_p(std::make_shared< ::prometheus::Registry>()) { // Initialize stat contexts d_systemStatContext_p = getStatContext("system"); @@ -274,7 +274,7 @@ void PrometheusStatConsumer::captureQueueStats() // a time series containing all the tags that can be leveraged // in Grafana. - auto& heartbeatGauge = prometheus::BuildGauge() + auto& heartbeatGauge = ::prometheus::BuildGauge() .Name("queue_heartbeat") .Register(*d_prometheusRegistry_p); heartbeatGauge.Add(labels).Set(0); @@ -374,8 +374,8 @@ void PrometheusStatConsumer::captureSystemStats() #undef COPY_METRIC - prometheus::Labels labels{{"DataType", "host-data"}}; - bslstl::StringRef instanceName = + ::prometheus::Labels labels{{"DataType", "host-data"}}; + bslstl::StringRef instanceName = mqbcfg::BrokerConfig::get().brokerInstanceName(); if (!instanceName.empty()) { labels.emplace("instanceName", instanceName); @@ -385,7 +385,7 @@ void PrometheusStatConsumer::captureSystemStats() datapoints.begin(); it != datapoints.end(); ++it) { - auto& gauge = prometheus::BuildGauge().Name(it->first).Register( + auto& gauge = ::prometheus::BuildGauge().Name(it->first).Register( *d_prometheusRegistry_p); gauge.Add(labels).Set(it->second); } @@ -422,8 +422,8 @@ void PrometheusStatConsumer::captureNetworkStats() #undef RETRIEVE_METRIC - prometheus::Labels labels{{"DataType", "host-data"}}; - bslstl::StringRef instanceName = + ::prometheus::Labels labels{{"DataType", "host-data"}}; + bslstl::StringRef instanceName = mqbcfg::BrokerConfig::get().brokerInstanceName(); if (!instanceName.empty()) { labels.emplace("instanceName", instanceName); @@ -433,7 +433,7 @@ void PrometheusStatConsumer::captureNetworkStats() datapoints.begin(); it != datapoints.end(); ++it) { - auto& counter = prometheus::BuildCounter().Name(it->first).Register( + auto& counter = ::prometheus::BuildCounter().Name(it->first).Register( *d_prometheusRegistry_p); counter.Add(labels).Increment(it->second); } @@ -673,20 +673,20 @@ void PrometheusStatConsumer::captureDomainStats(const LeaderSet& leaders) } } -void PrometheusStatConsumer::updateMetric(const DatapointDef* def_p, - const prometheus::Labels& labels, - const bsls::Types::Int64 value) +void PrometheusStatConsumer::updateMetric(const DatapointDef* def_p, + const ::prometheus::Labels& labels, + const bsls::Types::Int64 value) { if (value != 0) { // To save metrics, only report non-null values if (def_p->d_isCounter) { - auto& counter = prometheus::BuildCounter() + auto& counter = ::prometheus::BuildCounter() .Name(def_p->d_name) .Register(*d_prometheusRegistry_p); counter.Add(labels).Increment(static_cast(value)); } else { - auto& gauge = prometheus::BuildGauge() + auto& gauge = ::prometheus::BuildGauge() .Name(def_p->d_name) .Register(*d_prometheusRegistry_p); gauge.Add(labels).Set(static_cast(value)); @@ -773,15 +773,15 @@ bslma::ManagedPtr PrometheusStatConsumerPluginFactory::create( // -------------------------------- class PrometheusPullStatExporter : public PrometheusStatExporter { - std::weak_ptr d_registry_p; - bsl::unique_ptr d_exposer_p; - bsl::string d_exposerEndpoint; + std::weak_ptr< ::prometheus::Registry> d_registry_p; + bsl::unique_ptr< ::prometheus::Exposer> d_exposer_p; + bsl::string d_exposerEndpoint; public: PrometheusPullStatExporter( - const bsl::string& host, - const bsl::size_t port, - const std::shared_ptr& registry) + const bsl::string& host, + const bsl::size_t port, + const std::shared_ptr< ::prometheus::Registry>& registry) : d_registry_p(registry) { bsl::ostringstream endpoint; @@ -791,7 +791,8 @@ class PrometheusPullStatExporter : public PrometheusStatExporter { void start() override { - d_exposer_p = bsl::make_unique(d_exposerEndpoint); + d_exposer_p = bsl::make_unique< ::prometheus::Exposer>( + d_exposerEndpoint); d_exposer_p->RegisterCollectable(d_registry_p); } @@ -803,7 +804,7 @@ class PrometheusPullStatExporter : public PrometheusStatExporter { // -------------------------------- class PrometheusPushStatExporter : public PrometheusStatExporter { - bsl::unique_ptr d_prometheusGateway_p; + bsl::unique_ptr< ::prometheus::Gateway> d_prometheusGateway_p; /// Handle of the Prometheus publishing thread bslmt::ThreadUtil::Handle d_prometheusPushThreadHandle; bslmt::Mutex d_prometheusThreadMutex; @@ -849,15 +850,15 @@ class PrometheusPushStatExporter : public PrometheusStatExporter { public: PrometheusPushStatExporter( - const bsl::string& host, - const bsl::size_t& port, - const std::shared_ptr& registry) + const bsl::string& host, + const bsl::size_t& port, + const std::shared_ptr< ::prometheus::Registry>& registry) : d_threadStop(false) { // create a push gateway - const auto label = prometheus::Gateway::GetInstanceLabel( + const auto label = ::prometheus::Gateway::GetInstanceLabel( mqbcfg::BrokerConfig::get().hostName()); - d_prometheusGateway_p = bsl::make_unique( + d_prometheusGateway_p = bsl::make_unique< ::prometheus::Gateway>( host, bsl::to_string(port), "bmq", @@ -892,10 +893,10 @@ class PrometheusPushStatExporter : public PrometheusStatExporter { namespace { bsl::unique_ptr -makeExporter(const bsl::string& mode, - const bsl::string& host, - const bsl::size_t port, - std::shared_ptr& registry) +makeExporter(const bsl::string& mode, + const bsl::string& host, + const bsl::size_t port, + std::shared_ptr< ::prometheus::Registry>& registry) { bsl::unique_ptr result; if (mode == "pull") { diff --git a/src/plugins/plugins_prometheusstatconsumer.h b/src/plugins/prometheus/prometheus_prometheusstatconsumer.h similarity index 93% rename from src/plugins/plugins_prometheusstatconsumer.h rename to src/plugins/prometheus/prometheus_prometheusstatconsumer.h index 301af1fd0..5ef61e0f3 100644 --- a/src/plugins/plugins_prometheusstatconsumer.h +++ b/src/plugins/prometheus/prometheus_prometheusstatconsumer.h @@ -13,17 +13,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -// plugins_prometheusstatconsumer.h -*-C++-*- -#ifndef INCLUDED_PLUGINS_PROMETHEUSSTATCONSUMER -#define INCLUDED_PLUGINS_PROMETHEUSSTATCONSUMER +// prometheus_prometheusstatconsumer.h -*-C++-*- +#ifndef INCLUDED_PROMETHEUS_PROMETHEUSSTATCONSUMER +#define INCLUDED_PROMETHEUS_PROMETHEUSSTATCONSUMER //@PURPOSE: Provide a 'StatConsumer' plugin for publishing stats to Prometheus. // //@CLASSES: -// plugins::PrometheusStatConsumer: bmqbrkr plugin for publishing stats to +// prometheus::PrometheusStatConsumer: bmqbrkr plugin for publishing stats to // Prometheus. // -//@DESCRIPTION: 'plugins::PrometheusStatConsumer' handles the publishing of +//@DESCRIPTION: 'prometheus::PrometheusStatConsumer' handles the publishing of // statistics to Prometheus. // MQB @@ -69,7 +69,7 @@ namespace mwcst { class StatContext; } -namespace plugins { +namespace prometheus { typedef mqbplug::StatConsumer StatConsumer; typedef StatConsumer::StatContextsMap StatContextsMap; @@ -165,7 +165,7 @@ class PrometheusStatConsumer : public mqbplug::StatConsumer { bsl::unique_ptr d_prometheusStatExporter_p; // Entity responsible for sending statistics to Prometheus backend - std::shared_ptr d_prometheusRegistry_p; + std::shared_ptr< ::prometheus::Registry> d_prometheusRegistry_p; // Container for storing statistics in Prometheus format private: @@ -213,9 +213,9 @@ class PrometheusStatConsumer : public mqbplug::StatConsumer { /// Update metric by given 'def_p', 'labels' and 'value' in Prometheus /// Registry. - void updateMetric(const DatapointDef* def_p, - const prometheus::Labels& labels, - const bsls::Types::Int64 value); + void updateMetric(const DatapointDef* def_p, + const ::prometheus::Labels& labels, + const bsls::Types::Int64 value); /// Stop plugin void stopImpl(); @@ -260,7 +260,7 @@ class PrometheusStatConsumer : public mqbplug::StatConsumer { // ACCESSORS - /// Return plugins name + /// Return plugin name bslstl::StringRef name() const override; /// Return true if Prometheus reporting is enabled, false otherwise. @@ -274,7 +274,7 @@ class PrometheusStatConsumer : public mqbplug::StatConsumer { // class PrometheusStatConsumerPluginFactory // ========================================= -/// This is the factory class for plugins of type 'PrometheusStatConsumer'. +/// This is the factory class for plugin of type 'PrometheusStatConsumer'. /// All it does is allows to instantiate a concrete object of the /// 'PrometheusStatConsumer' interface, taking any required arguments. class PrometheusStatConsumerPluginFactory diff --git a/src/plugins/plugins_version.cpp b/src/plugins/prometheus/prometheus_version.cpp similarity index 60% rename from src/plugins/plugins_version.cpp rename to src/plugins/prometheus/prometheus_version.cpp index 97546bcc4..631a75bcd 100644 --- a/src/plugins/plugins_version.cpp +++ b/src/plugins/prometheus/prometheus_version.cpp @@ -13,26 +13,28 @@ // See the License for the specific language governing permissions and // limitations under the License. -// plugins_version.cpp -*-C++-*- -#include +// prometheus_version.cpp -*-C++-*- +#include namespace BloombergLP { #define STRINGIFY2(a) #a #define STRINGIFY(a) STRINGIFY2(a) -#define PLUGINS_VERSION_STRING \ - "BLP_LIB_PLUGINS_" STRINGIFY(PLUGINS_VERSION_MAJOR) "." STRINGIFY( \ - PLUGINS_VERSION_MINOR) "." STRINGIFY(PLUGINS_VERSION_PATCH) +#define PROMETHEUS_VERSION_STRING \ + "BLP_LIB_PROMETHEUS_" STRINGIFY(PROMETHEUS_VERSION_MAJOR) "." STRINGIFY( \ + PROMETHEUS_VERSION_MINOR) "." STRINGIFY(PROMETHEUS_VERSION_PATCH) -const char* plugins::Version::s_ident = "$Id: " PLUGINS_VERSION_STRING " $"; -const char* plugins::Version::s_what = "@(#)" PLUGINS_VERSION_STRING; +const char* prometheus::Version::s_ident = "$Id: " PROMETHEUS_VERSION_STRING + " $"; +const char* prometheus::Version::s_what = "@(#)" PROMETHEUS_VERSION_STRING; -const char* plugins::Version::PLUGINS_S_VERSION = PLUGINS_VERSION_STRING; -const char* plugins::Version::s_dependencies = ""; -const char* plugins::Version::s_buildInfo = ""; -const char* plugins::Version::s_timestamp = ""; -const char* plugins::Version::s_sourceControlInfo = ""; +const char* prometheus::Version::PROMETHEUS_S_VERSION = + PROMETHEUS_VERSION_STRING; +const char* prometheus::Version::s_dependencies = ""; +const char* prometheus::Version::s_buildInfo = ""; +const char* prometheus::Version::s_timestamp = ""; +const char* prometheus::Version::s_sourceControlInfo = ""; } // close enterprise namespace diff --git a/src/plugins/plugins_version.h b/src/plugins/prometheus/prometheus_version.h similarity index 58% rename from src/plugins/plugins_version.h rename to src/plugins/prometheus/prometheus_version.h index 2da8efff7..693f955db 100644 --- a/src/plugins/plugins_version.h +++ b/src/plugins/prometheus/prometheus_version.h @@ -13,59 +13,59 @@ // See the License for the specific language governing permissions and // limitations under the License. -// plugins_version.h -*-C++-*- -#ifndef INCLUDED_PLUGINS_VERSION -#define INCLUDED_PLUGINS_VERSION +// prometheus_version.h -*-C++-*- +#ifndef INCLUDED_PROMETHEUS_VERSION +#define INCLUDED_PROMETHEUS_VERSION //@PURPOSE: Provide source control management (versioning) information. // //@CLASSES: -// plugins::Version: namespace for 'plugins' SCM versioning information +// prometheus::Version: namespace for 'prometheus' SCM versioning information // //@DESCRIPTION: This component provides source control management (versioning) -// information for the 'plugins' plugin. In particular, this component +// information for the 'prometheus' plugin. In particular, this component // embeds RCS-style and SCCS-style version strings in binary executable files -// that use one or more components from the 'plugins' plugin. This version +// that use one or more components from the 'prometheus' plugin. This version // information may be extracted from binary files using common UNIX utilities // (e.g., 'ident' and 'what'). In addition, the 'version' 'static' member -// function in the 'plugins::Version' struct can be used to query version -// information for the 'plugins' plugin at runtime. The following USAGE +// function in the 'prometheus::Version' struct can be used to query version +// information for the 'prometheus' plugin at runtime. The following USAGE // examples illustrate these two basic capabilities. // // Note that unless the 'version' method will be called, it is not necessary to -// "#include" this component header file to get 'plugins' version information -// embedded in an executable. It is only necessary to use one or more -// 'plugins' components (and, hence, link in the 'plugins' library). +// "#include" this component header file to get 'prometheus' version +// information embedded in an executable. It is only necessary to use one or +// more 'prometheus' components (and, hence, link in the 'prometheus' library). -// PLUGINS -#include +// PROMETHEUS +#include // BDE #include namespace BloombergLP { -namespace plugins { +namespace prometheus { struct Version { // PUBLIC CLASS DATA static const char* s_ident; static const char* s_what; -#define PLUGINS_CONCAT2(a, b, c, d, e) a##b##c##d##e -#define PLUGINS_CONCAT(a, b, c, d, e) PLUGINS_CONCAT2(a, b, c, d, e) +#define PROMETHEUS_CONCAT2(a, b, c, d, e) a##b##c##d##e +#define PROMETHEUS_CONCAT(a, b, c, d, e) PROMETHEUS_CONCAT2(a, b, c, d, e) -// 'PLUGINS_S_VERSION' is a symbol whose name warns users of version mismatch -// linking errors. Note that the exact string "compiled_this_object" must be -// present in this version coercion symbol. Tools may look for this pattern to -// warn users of mismatches. -#define PLUGINS_S_VERSION \ - PLUGINS_CONCAT(d_version_PLUGINS_, \ - PLUGINS_VERSION_MAJOR, \ - _, \ - PLUGINS_VERSION_MINOR, \ - _compiled_this_object) +// 'PROMETHEUS_S_VERSION' is a symbol whose name warns users of version +// mismatch linking errors. Note that the exact string "compiled_this_object" +// must be present in this version coercion symbol. Tools may look for this +// pattern to warn users of mismatches. +#define PROMETHEUS_S_VERSION \ + PROMETHEUS_CONCAT(d_version_PROMETHEUS_, \ + PROMETHEUS_VERSION_MAJOR, \ + _, \ + PROMETHEUS_VERSION_MINOR, \ + _compiled_this_object) - static const char* PLUGINS_S_VERSION; + static const char* PROMETHEUS_S_VERSION; static const char* s_dependencies; static const char* s_buildInfo; @@ -75,7 +75,7 @@ struct Version { // CLASS METHODS static const char* version(); // Return the formatted string corresponding to the version. Format is - // BLP_LIB_PLUGINS_.. + // BLP_LIB_PROMETHEUS_.. static int versionAsInt(); // Return the int corresponding to the version, using the following @@ -87,24 +87,25 @@ struct Version { // ============================================================================ // ------------------------ -// class plugins::Version +// class prometheus::Version // ------------------------ inline const char* Version::version() { - return PLUGINS_S_VERSION; + return PROMETHEUS_S_VERSION; } inline int Version::versionAsInt() { - return PLUGINS_EXT_VERSION; + return PROMETHEUS_EXT_VERSION; } } // close package namespace -BSLS_LINKCOERCION_FORCE_SYMBOL_DEPENDENCY(const char*, - plugins_version_assertion, - plugins::Version::PLUGINS_S_VERSION) +BSLS_LINKCOERCION_FORCE_SYMBOL_DEPENDENCY( + const char*, + prometheus_version_assertion, + prometheus::Version::PROMETHEUS_S_VERSION) } // close enterprise namespace diff --git a/src/plugins/plugins_versiontag.cpp b/src/plugins/prometheus/prometheus_versiontag.cpp similarity index 90% rename from src/plugins/plugins_versiontag.cpp rename to src/plugins/prometheus/prometheus_versiontag.cpp index 0d9eb1463..e461c3036 100644 --- a/src/plugins/plugins_versiontag.cpp +++ b/src/plugins/prometheus/prometheus_versiontag.cpp @@ -13,8 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -// plugins_versiontag.cpp -*-C++-*- -#include +// prometheus_versiontag.cpp -*-C++-*- +#include // ---------------------------------------------------------------------------- // NOTICE: diff --git a/src/plugins/plugins_versiontag.h b/src/plugins/prometheus/prometheus_versiontag.h similarity index 61% rename from src/plugins/plugins_versiontag.h rename to src/plugins/prometheus/prometheus_versiontag.h index d9eb6a19a..9e388f623 100644 --- a/src/plugins/plugins_versiontag.h +++ b/src/plugins/prometheus/prometheus_versiontag.h @@ -13,51 +13,51 @@ // See the License for the specific language governing permissions and // limitations under the License. -// plugins_versiontag.h -*-C++-*- -#ifndef INCLUDED_PLUGINS_VERSIONTAG -#define INCLUDED_PLUGINS_VERSIONTAG +// prometheus_versiontag.h -*-C++-*- +#ifndef INCLUDED_PROMETHEUS_VERSIONTAG +#define INCLUDED_PROMETHEUS_VERSIONTAG -//@PURPOSE: Provide versioning information for the 'plugins' plugin. +//@PURPOSE: Provide versioning information for the 'prometheus' plugin. // -//@SEE_ALSO: plugins::Version +//@SEE_ALSO: prometheus::Version // //@DESCRIPTION: This component provides versioning information for the -// 'plugins' plugin. The 'PLUGINS_VERSION' macro that is supplied can be -// used for conditional-compilation based on 'plugins' version information. +// 'prometheus' plugin. The 'PROMETHEUS_VERSION' macro that is supplied can be +// used for conditional-compilation based on 'prometheus' version information. // The following usage example illustrates this basic capability. // /// Usage ///----- -// At compile time, the version of PLUGINS can be used to select an older or +// At compile time, the version of PROMETHEUS can be used to select an older or // newer way to accomplish a task, to enable new functionality, or to // accommodate an interface change. For example, if the name of a function // changes (a rare occurrence, but potentially disruptive when it does happen), // the impact on affected code can be minimized by conditionally calling the // function by its old or new name using conditional compilation. In the -// following, the '#if' preprocessor directive compares 'PLUGINS_VERSION' -// (i.e., the latest PLUGINS version, excluding the patch version) to a +// following, the '#if' preprocessor directive compares 'PROMETHEUS_VERSION' +// (i.e., the latest PROMETHEUS version, excluding the patch version) to a // specified major and minor version composed using the 'BDE_MAKE_VERSION' // macro: //.. -// #if PLUGINS_VERSION > BDE_MAKE_VERSION(1, 3) -// // Call 'newFunction' for PLUGINS versions later than 1.3. +// #if PROMETHEUS_VERSION > BDE_MAKE_VERSION(1, 3) +// // Call 'newFunction' for PROMETHEUS versions later than 1.3. // int result = newFunction(); // #else -// // Call 'oldFunction' for PLUGINS version 1.3 or earlier. +// // Call 'oldFunction' for PROMETHEUS version 1.3 or earlier. // int result = oldFunction(); // #endif //.. -#define PLUGINS_VERSION_MAJOR 99 -// PLUGINS release major version +#define PROMETHEUS_VERSION_MAJOR 99 +// PROMETHEUS release major version -#define PLUGINS_VERSION_MINOR 99 -// PLUGINS release minor version +#define PROMETHEUS_VERSION_MINOR 99 +// PROMETHEUS release minor version -#define PLUGINS_VERSION_PATCH 99 -// PLUGINS patch level +#define PROMETHEUS_VERSION_PATCH 99 +// PROMETHEUS patch level -#define PLUGINS_MAKE_VERSION(major, minor) ((major)*10000 + (minor)*100) +#define PROMETHEUS_MAKE_VERSION(major, minor) ((major)*10000 + (minor)*100) // Construct a composite version number in the range [ 0 .. 999900 ] from // the specified 'major' and 'minor' version numbers. The resulting value, // when expressed as a 6-digit decimal string, has "00" as the two @@ -72,25 +72,25 @@ // intentionally not included. The behavior is undefined unless 'major' // and 'minor' are integral values in the range '[ 0 .. 99 ]'. -#define PLUGINS_MAKE_EXT_VERSION(major, minor, patch) \ +#define PROMETHEUS_MAKE_EXT_VERSION(major, minor, patch) \ ((major)*10000 + (minor)*100 + (patch)) -// Similar to PLUGINS_MAKE_VERSION(), but include patch number as well. +// Similar to PROMETHEUS_MAKE_VERSION(), but include patch number as well. -#define PLUGINS_VERSION \ - PLUGINS_MAKE_VERSION(PLUGINS_VERSION_MAJOR, PLUGINS_VERSION_MINOR) +#define PROMETHEUS_VERSION \ + PROMETHEUS_MAKE_VERSION(PROMETHEUS_VERSION_MAJOR, PROMETHEUS_VERSION_MINOR) // Construct a composite version number in the range [ 0 .. 999900 ] from -// the specified 'PLUGINS_VERSION_MAJOR' and 'PLUGINS_VERSION_MINOR' +// the specified 'PROMETHEUS_VERSION_MAJOR' and 'PROMETHEUS_VERSION_MINOR' // numbers corresponding to the major and minor version numbers, -// respectively, of the current (latest) PLUGINS release. Note that the +// respectively, of the current (latest) PROMETHEUS release. Note that the // patch version number is intentionally not included. For example, -// 'PLUGINS_VERSION' produces 10300 (decimal) for PLUGINS version +// 'PROMETHEUS_VERSION' produces 10300 (decimal) for PROMETHEUS version // 1.3.1. -#define PLUGINS_EXT_VERSION \ - PLUGINS_MAKE_EXT_VERSION(PLUGINS_VERSION_MAJOR, \ - PLUGINS_VERSION_MINOR, \ - PLUGINS_VERSION_PATCH) -// Similar to PLUGINS_VERSION, but include the patch number as well +#define PROMETHEUS_EXT_VERSION \ + PROMETHEUS_MAKE_EXT_VERSION(PROMETHEUS_VERSION_MAJOR, \ + PROMETHEUS_VERSION_MINOR, \ + PROMETHEUS_VERSION_PATCH) +// Similar to PROMETHEUS_VERSION, but include the patch number as well #endif diff --git a/src/plugins/tests/docker/Dockerfile b/src/plugins/prometheus/tests/docker/Dockerfile similarity index 100% rename from src/plugins/tests/docker/Dockerfile rename to src/plugins/prometheus/tests/docker/Dockerfile diff --git a/src/plugins/tests/docker/docker-compose.yml b/src/plugins/prometheus/tests/docker/docker-compose.yml similarity index 100% rename from src/plugins/tests/docker/docker-compose.yml rename to src/plugins/prometheus/tests/docker/docker-compose.yml diff --git a/src/plugins/tests/docker/prometheus.yml b/src/plugins/prometheus/tests/docker/prometheus.yml similarity index 100% rename from src/plugins/tests/docker/prometheus.yml rename to src/plugins/prometheus/tests/docker/prometheus.yml diff --git a/src/plugins/tests/localBMQ/etc/bmqbrkrcfg.json b/src/plugins/prometheus/tests/localBMQ/etc/bmqbrkrcfg.json similarity index 100% rename from src/plugins/tests/localBMQ/etc/bmqbrkrcfg.json rename to src/plugins/prometheus/tests/localBMQ/etc/bmqbrkrcfg.json diff --git a/src/plugins/tests/localBMQ/etc/clusters.json b/src/plugins/prometheus/tests/localBMQ/etc/clusters.json similarity index 100% rename from src/plugins/tests/localBMQ/etc/clusters.json rename to src/plugins/prometheus/tests/localBMQ/etc/clusters.json diff --git a/src/plugins/tests/localBMQ/etc/domains/bmq.test.mem.broadcast.json b/src/plugins/prometheus/tests/localBMQ/etc/domains/bmq.test.mem.broadcast.json similarity index 100% rename from src/plugins/tests/localBMQ/etc/domains/bmq.test.mem.broadcast.json rename to src/plugins/prometheus/tests/localBMQ/etc/domains/bmq.test.mem.broadcast.json diff --git a/src/plugins/tests/localBMQ/etc/domains/bmq.test.mem.fanout.json b/src/plugins/prometheus/tests/localBMQ/etc/domains/bmq.test.mem.fanout.json similarity index 100% rename from src/plugins/tests/localBMQ/etc/domains/bmq.test.mem.fanout.json rename to src/plugins/prometheus/tests/localBMQ/etc/domains/bmq.test.mem.fanout.json diff --git a/src/plugins/tests/localBMQ/etc/domains/bmq.test.mem.priority.json b/src/plugins/prometheus/tests/localBMQ/etc/domains/bmq.test.mem.priority.json similarity index 100% rename from src/plugins/tests/localBMQ/etc/domains/bmq.test.mem.priority.json rename to src/plugins/prometheus/tests/localBMQ/etc/domains/bmq.test.mem.priority.json diff --git a/src/plugins/tests/localBMQ/etc/domains/bmq.test.persistent.fanout.json b/src/plugins/prometheus/tests/localBMQ/etc/domains/bmq.test.persistent.fanout.json similarity index 100% rename from src/plugins/tests/localBMQ/etc/domains/bmq.test.persistent.fanout.json rename to src/plugins/prometheus/tests/localBMQ/etc/domains/bmq.test.persistent.fanout.json diff --git a/src/plugins/tests/localBMQ/etc/domains/bmq.test.persistent.fanout.sc.json b/src/plugins/prometheus/tests/localBMQ/etc/domains/bmq.test.persistent.fanout.sc.json similarity index 100% rename from src/plugins/tests/localBMQ/etc/domains/bmq.test.persistent.fanout.sc.json rename to src/plugins/prometheus/tests/localBMQ/etc/domains/bmq.test.persistent.fanout.sc.json diff --git a/src/plugins/tests/localBMQ/etc/domains/bmq.test.persistent.priority.json b/src/plugins/prometheus/tests/localBMQ/etc/domains/bmq.test.persistent.priority.json similarity index 100% rename from src/plugins/tests/localBMQ/etc/domains/bmq.test.persistent.priority.json rename to src/plugins/prometheus/tests/localBMQ/etc/domains/bmq.test.persistent.priority.json diff --git a/src/plugins/tests/localBMQ/etc/domains/bmq.test.persistent.priority.sc.json b/src/plugins/prometheus/tests/localBMQ/etc/domains/bmq.test.persistent.priority.sc.json similarity index 100% rename from src/plugins/tests/localBMQ/etc/domains/bmq.test.persistent.priority.sc.json rename to src/plugins/prometheus/tests/localBMQ/etc/domains/bmq.test.persistent.priority.sc.json diff --git a/src/plugins/tests/localBMQ/logs/.keep b/src/plugins/prometheus/tests/localBMQ/logs/.keep similarity index 100% rename from src/plugins/tests/localBMQ/logs/.keep rename to src/plugins/prometheus/tests/localBMQ/logs/.keep diff --git a/src/plugins/tests/localBMQ/storage/local/archive/.keep b/src/plugins/prometheus/tests/localBMQ/storage/local/archive/.keep similarity index 100% rename from src/plugins/tests/localBMQ/storage/local/archive/.keep rename to src/plugins/prometheus/tests/localBMQ/storage/local/archive/.keep diff --git a/src/plugins/tests/plugins_prometheusstatconsumer_test.py b/src/plugins/prometheus/tests/prometheus_prometheusstatconsumer_test.py similarity index 96% rename from src/plugins/tests/plugins_prometheusstatconsumer_test.py rename to src/plugins/prometheus/tests/prometheus_prometheusstatconsumer_test.py index 3dfa14d4e..b09657764 100755 --- a/src/plugins/tests/plugins_prometheusstatconsumer_test.py +++ b/src/plugins/prometheus/tests/prometheus_prometheusstatconsumer_test.py @@ -18,7 +18,7 @@ 2. Python3 should be installed; 3. Docker should be installed, user launching the test script must be included into the group 'docker'. -Usage: ./plugins_prometheusstatconsumer_test.py [-h] -p PATH +Usage: ./prometheus_prometheusstatconsumer_test.py [-h] -p PATH options: -h, --help show this help message and exit -p PATH, --path PATH absolute path to BlasingMQ folder @@ -67,7 +67,7 @@ def test_local_cluster(plugin_path, broker_path, broker_cfg_path, tool_path, pro # Create sandbox in temp folder with tempfile.TemporaryDirectory() as tmpdirname: # Copy broker and plugins lib into sandbox - shutil.copy(plugin_path.joinpath('libplugins.so'), tmpdirname) + shutil.copy(plugin_path.joinpath('libprometheus.so'), tmpdirname) shutil.copy(broker_path.joinpath('bmqbrkr.tsk'), tmpdirname) # Copy broker config folder into sandbox local_cfg_path = shutil.copytree( @@ -122,7 +122,7 @@ def test_local_cluster(plugin_path, broker_path, broker_cfg_path, tool_path, pro _check_statistic(prometheus_host) except AssertionError as error: - print('Statistic check failed: ', error) + print('ERROR: Prometheus metrics check failed: ', error) return False finally: os.chdir(current_dir) @@ -137,10 +137,11 @@ def test_local_cluster(plugin_path, broker_path, broker_cfg_path, tool_path, pro def main(args): prometheus_docker_file_path = Path(args.path).joinpath( - 'src/plugins/tests/docker/docker-compose.yml') + 'src/plugins/prometheus/tests/docker/docker-compose.yml') broker_path = Path(args.path).joinpath( 'build/blazingmq/src/applications/bmqbrkr') - broker_cfg_path = Path(args.path).joinpath('src/plugins/tests/localBMQ') + broker_cfg_path = Path(args.path).joinpath( + 'src/plugins/prometheus/tests/localBMQ') tool_path = Path(args.path).joinpath( 'build/blazingmq/src/applications/bmqtool/bmqtool.tsk') plugin_path = Path(args.path).joinpath('build/blazingmq/src/plugins')