Skip to content

Commit

Permalink
mqbconf.xsd: Move flag to publish appId metircs from mqbcfg.xsd (#353)
Browse files Browse the repository at this point in the history
* mqbconf.xsd: Add flag to publish appId metircs

Signed-off-by: Yuan Jing Vincent Yan <yyan82@bloomberg.net>

* mqbcfg.xsd: Remove flag to publish appId metircs

Signed-off-by: Yuan Jing Vincent Yan <yyan82@bloomberg.net>

* mqbstat::QueueStatsDomain: Use domain flag for publish appId metrics

Signed-off-by: Yuan Jing Vincent Yan <yyan82@bloomberg.net>

* docs plugins.md: Remove appIdTagDomains

Signed-off-by: Yuan Jing Vincent Yan <yyan82@bloomberg.net>

* configurator/__init__.py: Clean up removed config option

Signed-off-by: Yuan Jing Vincent Yan <yyan82@bloomberg.net>

* mqbconf, mqbcfg: Generated Python code

Signed-off-by: Yuan Jing Vincent Yan <yyan82@bloomberg.net>

* test_admin_client.py: Use new publish appId metrics flag

Signed-off-by: Yuan Jing Vincent Yan <yyan82@bloomberg.net>

---------

Signed-off-by: Yuan Jing Vincent Yan <yyan82@bloomberg.net>
  • Loading branch information
kaikulimu authored Jul 30, 2024
1 parent f99b265 commit 410f71c
Show file tree
Hide file tree
Showing 13 changed files with 1,532 additions and 2,112 deletions.
11 changes: 1 addition & 10 deletions docs/docs/features/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ By default, plugin is disabled. To enable and configure it, edit `bmqbrkcfg.json
"appConfig": {
"stats": {
"snapshotInterval": 1,
"appIdTagDomains": ["<fanout-domain-1-name>", "<fanout-domain-2-name>"],
"plugins": [
...
{
Expand All @@ -44,7 +43,7 @@ By default, plugin is disabled. To enable and configure it, edit `bmqbrkcfg.json
"prometheusSpecific": {
"host": "localhost",
"port": 9091,
"mode": "E_PUSH"
"mode": "E_PUSH"
}
}
],
Expand All @@ -59,14 +58,6 @@ where

- `snapshotInterval`: represents how often stats are computed by broker
internally, in seconds (typically every 1s);
- [OPTIONAL] `appIdTagDomains`: used for troubleshooting, represents
the list of *fanout* mode domains for which *applicationId* tag will be
applied on `queue.confirm_time_max` and `queue.queue_time_max` metrics.
It can be *extremely* useful to detect slow responding consumer by
*applicationId*. If this setting is omitted/empty, or domain name not
in the list - *applicationId* tag will not be applied;<br/>
**NOTE**: This feature is available for all BlazingMQ broker roles except
*PROXY*;

2. Prometheus plugin configuration

Expand Down
1 change: 0 additions & 1 deletion src/groups/mqb/mqbcfg/mqbcfg.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@
<complexType name='StatsConfig'>
<sequence>
<element name='snapshotInterval' type='int' default='1'/> <!-- 0 to disable -->
<element name='appIdTagDomains' type='string' maxOccurs='unbounded'/>
<element name='plugins' type='tns:StatPluginConfig' maxOccurs='unbounded'/>
<element name='printer' type='tns:StatsPrinterConfig'/>
</sequence>
Expand Down
27 changes: 6 additions & 21 deletions src/groups/mqb/mqbcfg/mqbcfg_messages.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2024 Bloomberg Finance L.P.
// Copyright 2014-2024 Bloomberg Finance L.P.
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -4984,11 +4984,6 @@ const bdlat_AttributeInfo StatsConfig::ATTRIBUTE_INFO_ARRAY[] = {
sizeof("snapshotInterval") - 1,
"",
bdlat_FormattingMode::e_DEC},
{ATTRIBUTE_ID_APP_ID_TAG_DOMAINS,
"appIdTagDomains",
sizeof("appIdTagDomains") - 1,
"",
bdlat_FormattingMode::e_TEXT},
{ATTRIBUTE_ID_PLUGINS,
"plugins",
sizeof("plugins") - 1,
Expand All @@ -5005,7 +5000,7 @@ const bdlat_AttributeInfo StatsConfig::ATTRIBUTE_INFO_ARRAY[] = {
const bdlat_AttributeInfo* StatsConfig::lookupAttributeInfo(const char* name,
int nameLength)
{
for (int i = 0; i < 4; ++i) {
for (int i = 0; i < 3; ++i) {
const bdlat_AttributeInfo& attributeInfo =
StatsConfig::ATTRIBUTE_INFO_ARRAY[i];

Expand All @@ -5023,8 +5018,6 @@ const bdlat_AttributeInfo* StatsConfig::lookupAttributeInfo(int id)
switch (id) {
case ATTRIBUTE_ID_SNAPSHOT_INTERVAL:
return &ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SNAPSHOT_INTERVAL];
case ATTRIBUTE_ID_APP_ID_TAG_DOMAINS:
return &ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_APP_ID_TAG_DOMAINS];
case ATTRIBUTE_ID_PLUGINS:
return &ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_PLUGINS];
case ATTRIBUTE_ID_PRINTER:
Expand All @@ -5036,17 +5029,15 @@ const bdlat_AttributeInfo* StatsConfig::lookupAttributeInfo(int id)
// CREATORS

StatsConfig::StatsConfig(bslma::Allocator* basicAllocator)
: d_appIdTagDomains(basicAllocator)
, d_plugins(basicAllocator)
: d_plugins(basicAllocator)
, d_printer(basicAllocator)
, d_snapshotInterval(DEFAULT_INITIALIZER_SNAPSHOT_INTERVAL)
{
}

StatsConfig::StatsConfig(const StatsConfig& original,
bslma::Allocator* basicAllocator)
: d_appIdTagDomains(original.d_appIdTagDomains, basicAllocator)
, d_plugins(original.d_plugins, basicAllocator)
: d_plugins(original.d_plugins, basicAllocator)
, d_printer(original.d_printer, basicAllocator)
, d_snapshotInterval(original.d_snapshotInterval)
{
Expand All @@ -5055,17 +5046,15 @@ StatsConfig::StatsConfig(const StatsConfig& original,
#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \
defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
StatsConfig::StatsConfig(StatsConfig&& original) noexcept
: d_appIdTagDomains(bsl::move(original.d_appIdTagDomains)),
d_plugins(bsl::move(original.d_plugins)),
: d_plugins(bsl::move(original.d_plugins)),
d_printer(bsl::move(original.d_printer)),
d_snapshotInterval(bsl::move(original.d_snapshotInterval))
{
}

StatsConfig::StatsConfig(StatsConfig&& original,
bslma::Allocator* basicAllocator)
: d_appIdTagDomains(bsl::move(original.d_appIdTagDomains), basicAllocator)
, d_plugins(bsl::move(original.d_plugins), basicAllocator)
: d_plugins(bsl::move(original.d_plugins), basicAllocator)
, d_printer(bsl::move(original.d_printer), basicAllocator)
, d_snapshotInterval(bsl::move(original.d_snapshotInterval))
{
Expand All @@ -5082,7 +5071,6 @@ StatsConfig& StatsConfig::operator=(const StatsConfig& rhs)
{
if (this != &rhs) {
d_snapshotInterval = rhs.d_snapshotInterval;
d_appIdTagDomains = rhs.d_appIdTagDomains;
d_plugins = rhs.d_plugins;
d_printer = rhs.d_printer;
}
Expand All @@ -5096,7 +5084,6 @@ StatsConfig& StatsConfig::operator=(StatsConfig&& rhs)
{
if (this != &rhs) {
d_snapshotInterval = bsl::move(rhs.d_snapshotInterval);
d_appIdTagDomains = bsl::move(rhs.d_appIdTagDomains);
d_plugins = bsl::move(rhs.d_plugins);
d_printer = bsl::move(rhs.d_printer);
}
Expand All @@ -5108,7 +5095,6 @@ StatsConfig& StatsConfig::operator=(StatsConfig&& rhs)
void StatsConfig::reset()
{
d_snapshotInterval = DEFAULT_INITIALIZER_SNAPSHOT_INTERVAL;
bdlat_ValueTypeFunctions::reset(&d_appIdTagDomains);
bdlat_ValueTypeFunctions::reset(&d_plugins);
bdlat_ValueTypeFunctions::reset(&d_printer);
}
Expand All @@ -5121,7 +5107,6 @@ StatsConfig::print(bsl::ostream& stream, int level, int spacesPerLevel) const
bslim::Printer printer(&stream, level, spacesPerLevel);
printer.start();
printer.printAttribute("snapshotInterval", this->snapshotInterval());
printer.printAttribute("appIdTagDomains", this->appIdTagDomains());
printer.printAttribute("plugins", this->plugins());
printer.printAttribute("printer", this->printer());
printer.end();
Expand Down
75 changes: 11 additions & 64 deletions src/groups/mqb/mqbcfg/mqbcfg_messages.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2024 Bloomberg Finance L.P.
// Copyright 2014-2024 Bloomberg Finance L.P.
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -7922,7 +7922,6 @@ namespace mqbcfg {

class StatsConfig {
// INSTANCE DATA
bsl::vector<bsl::string> d_appIdTagDomains;
bsl::vector<StatPluginConfig> d_plugins;
StatsPrinterConfig d_printer;
int d_snapshotInterval;
Expand All @@ -7931,24 +7930,20 @@ class StatsConfig {
template <typename t_HASH_ALGORITHM>
void hashAppendImpl(t_HASH_ALGORITHM& hashAlgorithm) const;

bool isEqualTo(const StatsConfig& rhs) const;

public:
// TYPES
enum {
ATTRIBUTE_ID_SNAPSHOT_INTERVAL = 0,
ATTRIBUTE_ID_APP_ID_TAG_DOMAINS = 1,
ATTRIBUTE_ID_PLUGINS = 2,
ATTRIBUTE_ID_PRINTER = 3
ATTRIBUTE_ID_SNAPSHOT_INTERVAL = 0,
ATTRIBUTE_ID_PLUGINS = 1,
ATTRIBUTE_ID_PRINTER = 2
};

enum { NUM_ATTRIBUTES = 4 };
enum { NUM_ATTRIBUTES = 3 };

enum {
ATTRIBUTE_INDEX_SNAPSHOT_INTERVAL = 0,
ATTRIBUTE_INDEX_APP_ID_TAG_DOMAINS = 1,
ATTRIBUTE_INDEX_PLUGINS = 2,
ATTRIBUTE_INDEX_PRINTER = 3
ATTRIBUTE_INDEX_SNAPSHOT_INTERVAL = 0,
ATTRIBUTE_INDEX_PLUGINS = 1,
ATTRIBUTE_INDEX_PRINTER = 2
};

// CONSTANTS
Expand Down Expand Up @@ -8052,10 +8047,6 @@ class StatsConfig {
// Return a reference to the modifiable "SnapshotInterval" attribute of
// this object.

bsl::vector<bsl::string>& appIdTagDomains();
// Return a reference to the modifiable "AppIdTagDomains" attribute of
// this object.

bsl::vector<StatPluginConfig>& plugins();
// Return a reference to the modifiable "Plugins" attribute of this
// object.
Expand Down Expand Up @@ -8110,10 +8101,6 @@ class StatsConfig {
int snapshotInterval() const;
// Return the value of the "SnapshotInterval" attribute of this object.

const bsl::vector<bsl::string>& appIdTagDomains() const;
// Return a reference offering non-modifiable access to the
// "AppIdTagDomains" attribute of this object.

const bsl::vector<StatPluginConfig>& plugins() const;
// Return a reference offering non-modifiable access to the "Plugins"
// attribute of this object.
Expand All @@ -8128,7 +8115,9 @@ class StatsConfig {
// have the same value, and 'false' otherwise. Two attribute objects
// have the same value if each respective attribute has the same value.
{
return lhs.isEqualTo(rhs);
return lhs.snapshotInterval() == rhs.snapshotInterval() &&
lhs.plugins() == rhs.plugins() &&
lhs.printer() == rhs.printer();
}

friend bool operator!=(const StatsConfig& lhs, const StatsConfig& rhs)
Expand Down Expand Up @@ -16387,19 +16376,10 @@ void StatsConfig::hashAppendImpl(t_HASH_ALGORITHM& hashAlgorithm) const
{
using bslh::hashAppend;
hashAppend(hashAlgorithm, this->snapshotInterval());
hashAppend(hashAlgorithm, this->appIdTagDomains());
hashAppend(hashAlgorithm, this->plugins());
hashAppend(hashAlgorithm, this->printer());
}

inline bool StatsConfig::isEqualTo(const StatsConfig& rhs) const
{
return this->snapshotInterval() == rhs.snapshotInterval() &&
this->appIdTagDomains() == rhs.appIdTagDomains() &&
this->plugins() == rhs.plugins() &&
this->printer() == rhs.printer();
}

// CLASS METHODS
// MANIPULATORS
template <typename t_MANIPULATOR>
Expand All @@ -16413,13 +16393,6 @@ int StatsConfig::manipulateAttributes(t_MANIPULATOR& manipulator)
return ret;
}

ret = manipulator(
&d_appIdTagDomains,
ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_APP_ID_TAG_DOMAINS]);
if (ret) {
return ret;
}

ret = manipulator(&d_plugins,
ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_PLUGINS]);
if (ret) {
Expand All @@ -16446,11 +16419,6 @@ int StatsConfig::manipulateAttribute(t_MANIPULATOR& manipulator, int id)
&d_snapshotInterval,
ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SNAPSHOT_INTERVAL]);
}
case ATTRIBUTE_ID_APP_ID_TAG_DOMAINS: {
return manipulator(
&d_appIdTagDomains,
ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_APP_ID_TAG_DOMAINS]);
}
case ATTRIBUTE_ID_PLUGINS: {
return manipulator(&d_plugins,
ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_PLUGINS]);
Expand Down Expand Up @@ -16484,11 +16452,6 @@ inline int& StatsConfig::snapshotInterval()
return d_snapshotInterval;
}

inline bsl::vector<bsl::string>& StatsConfig::appIdTagDomains()
{
return d_appIdTagDomains;
}

inline bsl::vector<StatPluginConfig>& StatsConfig::plugins()
{
return d_plugins;
Expand All @@ -16511,12 +16474,6 @@ int StatsConfig::accessAttributes(t_ACCESSOR& accessor) const
return ret;
}

ret = accessor(d_appIdTagDomains,
ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_APP_ID_TAG_DOMAINS]);
if (ret) {
return ret;
}

ret = accessor(d_plugins, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_PLUGINS]);
if (ret) {
return ret;
Expand All @@ -16541,11 +16498,6 @@ int StatsConfig::accessAttribute(t_ACCESSOR& accessor, int id) const
d_snapshotInterval,
ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SNAPSHOT_INTERVAL]);
}
case ATTRIBUTE_ID_APP_ID_TAG_DOMAINS: {
return accessor(
d_appIdTagDomains,
ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_APP_ID_TAG_DOMAINS]);
}
case ATTRIBUTE_ID_PLUGINS: {
return accessor(d_plugins,
ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_PLUGINS]);
Expand Down Expand Up @@ -16579,11 +16531,6 @@ inline int StatsConfig::snapshotInterval() const
return d_snapshotInterval;
}

inline const bsl::vector<bsl::string>& StatsConfig::appIdTagDomains() const
{
return d_appIdTagDomains;
}

inline const bsl::vector<StatPluginConfig>& StatsConfig::plugins() const
{
return d_plugins;
Expand Down
7 changes: 5 additions & 2 deletions src/groups/mqb/mqbconfm/mqbconf.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,14 @@
<documentation>
Configuration for a fanout queue.

appIDs.: List of appIDs authorized to consume from the queue.
appIDs.............: List of appIDs authorized to consume from the
queue.
publishAppIdMetrics: Whether to publish appId metrics.
</documentation>
</annotation>
<sequence>
<element name='appIDs' type='string' maxOccurs='unbounded'/>
<element name='appIDs' type='string' maxOccurs='unbounded'/>
<element name='publishAppIdMetrics' type='boolean' default='false'/>
</sequence>
</complexType>

Expand Down
Loading

0 comments on commit 410f71c

Please sign in to comment.