Add key_property support for dynamic_tags#601
Add key_property support for dynamic_tags#601gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
Conversation
Extend dynamic_tags to extract tag values from JMX bean name key
properties, not just attribute values. This enables tagging metrics
with values like Kafka's broker ID which only exists as a key property
in bean names (e.g. kafka.server:type=app-info,id=1).
New syntax:
dynamic_tags:
- tag_name: broker_id
bean_name: kafka.server:type=app-info,id=*
key_property: id
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@codex review |
| } | ||
|
|
||
| @Test | ||
| public void testConfigDynamicTagsKeyProperty() throws Exception { |
There was a problem hiding this comment.
Thank you for adding these tests ❤️
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b7df6615fc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ObjectName matchedBean = matchingBeans.iterator().next(); | ||
| String value = matchedBean.getKeyProperty(keyProperty); |
There was a problem hiding this comment.
Handle multiple key-property matches deterministically
The new key_property resolver takes the first element from queryNames() via matchingBeans.iterator().next(), but wildcard bean_name patterns can legally match multiple MBeans and Set iteration order is not stable. In those cases, the chosen bean (and emitted dynamic tag value) becomes nondeterministic across runs, which can mis-tag metrics and corrupt aggregations. Please enforce a single-match contract (or deterministic selection with explicit tie-breaking) before extracting the key property.
Useful? React with 👍 / 👎.
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
Summary
dynamic_tagsto support extracting tag values from JMX bean name key propertieskey_propertyfield as an alternative toattribute— usesObjectName.getKeyProperty()to extract the value*) are supported viaqueryNames()Motivation
Some important values only exist as key properties in JMX bean names, not as attribute values. For example, Kafka's broker ID is only available in beans like
kafka.server:type=app-info,id=1— there is no attribute that returns the broker ID.This makes it possible to write:
Test plan
testConfigDynamicTagsKeyProperty— verifies key property extraction from bean nametestConfigDynamicTagsKeyPropertyAndAttribute— verifies key_property and attribute dynamic tags work together on the same metric🤖 Generated with Claude Code