implementation/src/main/java/io/smallrye/metrics/JmxWorker.java
public void expandMultiValueEntries(List<ExtendedMetadataAndTags> entries) {
        List<ExtendedMetadataAndTags> result = new ArrayList<>();
        List<ExtendedMetadataAndTags> toBeRemoved = new ArrayList<>(entries.size());
        for (ExtendedMetadataAndTags entry : entries) {
            if (entry.getMetadata().isMulti()) {
                String name = entry.getMetadata().getMbean();
                String attName;
                String queryableName;
                int slashIndex = name.indexOf('/');

                // MBeanName is invalid, lets skip this altogether
                if (slashIndex < 0) {
                    toBeRemoved.add(entry);
                    continue;
                }

                queryableName = name.substring(0, slashIndex);
                attName = name.substring(slashIndex + 1);

                try {
                    ObjectName objectNameWithPlaceholders = new ObjectName(queryableName);
                    final Map<String, String> keyHolders = findComponentPairsWithPlaceholders(objectNameWithPlaceholders);

                    ObjectName objectName = new ObjectName(queryableName.replaceAll(PLACEHOLDER + "(\\d)?+", "*"));

                    Set<ObjectName> objNames = mbs.queryNames(objectName, null);
                    for (ObjectName oName : objNames) {
                        String newName = entry.getMetadata().getName();
                        if (!newName.contains(PLACEHOLDER) && entry.getTags().isEmpty()) {
                            SmallRyeMetricsLogging.log.nameDoesNotContainPlaceHoldersOrTags(newName);
                        }
                        String newDisplayName = entry.getMetadata().getDisplayName();
                        String newDescription = entry.getMetadata().getDescription();
                        List<Tag> newTags = new ArrayList<>(entry.getTags());
                        for (final Entry<String, String> keyHolder : keyHolders.entrySet()) {
                            String keyValue = oName.getKeyPropertyList().get(keyHolder.getValue());
                            newName = newName.replaceAll(Pattern.quote(keyHolder.getKey()), keyValue);
                            newDisplayName = newDisplayName.replaceAll(Pattern.quote(keyHolder.getKey()), keyValue);
                            newDescription = newDescription.replaceAll(Pattern.quote(keyHolder.getKey()), keyValue);
                            newTags = newTags.stream()
                                    .map(originalTag -> new Tag(originalTag.getTagName(),
                                            originalTag.getTagValue().replaceAll(Pattern.quote(keyHolder.getKey()), keyValue)))
                                    .collect(Collectors.toList());
                        }

                        String newObjectName = oName.getCanonicalName() + "/" + attName;

                        ExtendedMetadata newEntryMetadata = new ExtendedMetadata(newName, newDisplayName, newDescription,
                                entry.getMetadata().getTypeRaw(), entry.getMetadata().getUnit(), newObjectName,
                                true);
                        ExtendedMetadataAndTags newEntry = new ExtendedMetadataAndTags(newEntryMetadata, newTags);
                        result.add(newEntry);
                    }
                    toBeRemoved.add(entry);
                } catch (MalformedObjectNameException e) {
                    throw SmallRyeMetricsMessages.msg.malformedObjectName(e);
                }
            }
        }
        entries.removeAll(toBeRemoved);
        entries.addAll(result);
    }
/**
     * We need to expand entries that are marked with the <b>multi</b> flag
     * into the actual MBeans. This is done by replacing a placeholder of <b>%s</b>
     * in the name and MBean name with the real Mbean key-value.
     *
     * @param entries List of entries
     */
We need to expand entries that are marked with the multi flag
into the actual MBeans. This is done by replacing a placeholder of %s
in the name and MBean name with the real Mbean key-value.

@param entries List of entries
We need to expand entries that are marked with the multi flag into the actual MBeans . This is done by replacing a placeholder of %s in the name and MBean name with the real Mbean key - value . @param entries List of entries
public void expandMultiValueEntries(List<ExtendedMetadataAndTags> entries) {
        List<ExtendedMetadataAndTags> result = new ArrayList<>();
        List<ExtendedMetadataAndTags> toBeRemoved = new ArrayList<>(entries.size());
        for (ExtendedMetadataAndTags entry : entries) {
            if (entry.getMetadata().isMulti()) {
                String name = entry.getMetadata().getMbean();
                String attName;
                String queryableName;
                int slashIndex = name.indexOf('/');
                if (slashIndex < 0) {
                    toBeRemoved.add(entry);
                    continue;
                }
                queryableName = name.substring(0, slashIndex);
                attName = name.substring(slashIndex + 1);
                try {
                    ObjectName objectNameWithPlaceholders = new ObjectName(queryableName);
                    final Map<String, String> keyHolders = findComponentPairsWithPlaceholders(objectNameWithPlaceholders);
                    ObjectName objectName = new ObjectName(queryableName.replaceAll(PLACEHOLDER + "(\\d)?+", "*"));
                    Set<ObjectName> objNames = mbs.queryNames(objectName, null);
                    for (ObjectName oName : objNames) {
                        String newName = entry.getMetadata().getName();
                        if (!newName.contains(PLACEHOLDER) && entry.getTags().isEmpty()) {
                            SmallRyeMetricsLogging.log.nameDoesNotContainPlaceHoldersOrTags(newName);
                        }
                        String newDisplayName = entry.getMetadata().getDisplayName();
                        String newDescription = entry.getMetadata().getDescription();
                        List<Tag> newTags = new ArrayList<>(entry.getTags());
                        for (final Entry<String, String> keyHolder : keyHolders.entrySet()) {
                            String keyValue = oName.getKeyPropertyList().get(keyHolder.getValue());
                            newName = newName.replaceAll(Pattern.quote(keyHolder.getKey()), keyValue);
                            newDisplayName = newDisplayName.replaceAll(Pattern.quote(keyHolder.getKey()), keyValue);
                            newDescription = newDescription.replaceAll(Pattern.quote(keyHolder.getKey()), keyValue);
                            newTags = newTags.stream()
                                    .map(originalTag -> new Tag(originalTag.getTagName(),
                                            originalTag.getTagValue().replaceAll(Pattern.quote(keyHolder.getKey()), keyValue)))
                                    .collect(Collectors.toList());
                        }
                        String newObjectName = oName.getCanonicalName() + "/" + attName;
                        ExtendedMetadata newEntryMetadata = new ExtendedMetadata(newName, newDisplayName, newDescription,
                                entry.getMetadata().getTypeRaw(), entry.getMetadata().getUnit(), newObjectName,
                                true);
                        ExtendedMetadataAndTags newEntry = new ExtendedMetadataAndTags(newEntryMetadata, newTags);
                        result.add(newEntry);
                    }
                    toBeRemoved.add(entry);
                } catch (MalformedObjectNameException e) {
                    throw SmallRyeMetricsMessages.msg.malformedObjectName(e);
                }
            }
        }
        entries.removeAll(toBeRemoved);
        entries.addAll(result);
    }
public void expandMultiValueEntries ( List < ExtendedMetadataAndTags > entries ) { List < ExtendedMetadataAndTags > result = new ArrayList < > ( ) ; List < ExtendedMetadataAndTags > toBeRemoved = new ArrayList < > ( entries . size ( ) ) ; for ( ExtendedMetadataAndTags entry : entries ) { if ( entry . getMetadata ( ) . isMulti ( ) ) { String name = entry . getMetadata ( ) . getMbean ( ) ; String attName ; String queryableName ; int slashIndex = name . indexOf ( '/' ) ; if ( slashIndex < 0 ) { toBeRemoved . add ( entry ) ; continue ; } queryableName = name . substring ( 0 , slashIndex ) ; attName = name . substring ( slashIndex + 1 ) ; try { ObjectName objectNameWithPlaceholders = new ObjectName ( queryableName ) ; final Map < String , String > keyHolders = findComponentPairsWithPlaceholders ( objectNameWithPlaceholders ) ; ObjectName objectName = new ObjectName ( queryableName . replaceAll ( PLACEHOLDER + "(\\d)?+" , "*" ) ) ; Set < ObjectName > objNames = mbs . queryNames ( objectName , null ) ; for ( ObjectName oName : objNames ) { String newName = entry . getMetadata ( ) . getName ( ) ; if ( ! newName . contains ( PLACEHOLDER ) && entry . getTags ( ) . isEmpty ( ) ) { SmallRyeMetricsLogging . log . nameDoesNotContainPlaceHoldersOrTags ( newName ) ; } String newDisplayName = entry . getMetadata ( ) . getDisplayName ( ) ; String newDescription = entry . getMetadata ( ) . getDescription ( ) ; List < Tag > newTags = new ArrayList < > ( entry . getTags ( ) ) ; for ( final Entry < String , String > keyHolder : keyHolders . entrySet ( ) ) { String keyValue = oName . getKeyPropertyList ( ) . get ( keyHolder . getValue ( ) ) ; newName = newName . replaceAll ( Pattern . quote ( keyHolder . getKey ( ) ) , keyValue ) ; newDisplayName = newDisplayName . replaceAll ( Pattern . quote ( keyHolder . getKey ( ) ) , keyValue ) ; newDescription = newDescription . replaceAll ( Pattern . quote ( keyHolder . getKey ( ) ) , keyValue ) ; newTags = newTags . stream ( ) . map ( originalTag -> new Tag ( originalTag . getTagName ( ) , originalTag . getTagValue ( ) . replaceAll ( Pattern . quote ( keyHolder . getKey ( ) ) , keyValue ) ) ) . collect ( Collectors . toList ( ) ) ; } String newObjectName = oName . getCanonicalName ( ) + "/" + attName ; ExtendedMetadata newEntryMetadata = new ExtendedMetadata ( newName , newDisplayName , newDescription , entry . getMetadata ( ) . getTypeRaw ( ) , entry . getMetadata ( ) . getUnit ( ) , newObjectName , true ) ; ExtendedMetadataAndTags newEntry = new ExtendedMetadataAndTags ( newEntryMetadata , newTags ) ; result . add ( newEntry ) ; } toBeRemoved . add ( entry ) ; } catch ( MalformedObjectNameException e ) { throw SmallRyeMetricsMessages . msg . malformedObjectName ( e ) ; } } } entries . removeAll ( toBeRemoved ) ; entries . addAll ( result ) ; }
We need to expand entries that are marked with the <b>multi</b> flag
 into the actual MBeans.
We need to expand entries that are marked with the <b > multi< / b > flag into the actual MBeans .
// MBeanName is invalid, lets skip this altogether