Class ISOMsgCounter
java.lang.Object
org.jpos.metrics.iso.ISOMsgCounter
- All Implemented Interfaces:
Configurable, ISOMsgMetrics, LogSource
Counts ISO messages using Micrometer meters and tags resolved from message fields.
-
Nested Class Summary
Nested classes/interfaces inherited from interface ISOMsgMetrics
ISOMsgMetrics.SourceModifier and TypeInterfaceDescriptionstatic interfaceImplemented by components that expose anISOMsgMetricsinstance. -
Field Summary
Fields inherited from interface ISOMsgMetrics
DEFAULT_CHANNEL_FIELDS, DEFAULT_CHANNEL_METRIC_NAME, DEFAULT_TAGS, ENV_CHANNEL_FIELDS, ENV_CHANNEL_TAGSModifier and TypeFieldDescriptionstatic final StringDefault channel fields for metrics.static final StringDefault channel metric name.static final StringDefault tags for channel metrics.static final StringEnvironment variable name for channel fields configuration.static final StringEnvironment variable name for channel tags configuration. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.micrometer.core.instrument.TagsaddTags(io.micrometer.core.instrument.Tags tags) Adds metric tags to the given Tags object.Returns the configured field set map.Returns the Logger associated with this source.protected Set<io.micrometer.core.instrument.Meter> Returns a clone set, which may not be up to date next time you use it.Returns the metric description.Returns the metric name.Returns the metric meters.getRealm()Returns the log realm associated with this source.io.micrometer.core.instrument.MeterRegistryReturns the meter registry.io.micrometer.core.instrument.TagsgetTags()Returns all metric tags.Returns the metric tags as a map.parseTagPairs(String tp, boolean copySingleTag) Parses tag-value pairs from a string.voidRecords anISOMsgin the meter registry.
The metric name and tags will be taken strictly from this object's configuration.voidrecordMessage(ISOMsg m, MeterInfo meterInfo) Records anISOMsgin the meter registry.
Similar toISOMsgMetrics.recordMessage(ISOMsg)but using the metric name, description and maybe some tags taken from theMeterInfoargument.booleanregister(io.micrometer.core.instrument.MeterRegistry registry) Register this object to work with a givenMeterRegistry.
This method may serve more than one purpose in the object's lifecycle: Assign aMeterRegistryto be used for the created meters.voidRemoves all registered meters.protected StringresolveValExpr(ISOMsg m, String val) Hook for subclasses to resolve, against an ISOMsg, the valexpr part of a tag:valexpr in a fieldset.voidConfigures this object with the suppliedConfiguration.voidAttaches aLoggerand realm to this log source.voidsetMetricDescription(String metricDescription) Sets the metric description.voidsetMetricName(String metricName) Sets the metric name.voidIt callsISOMsgMetrics.removeMeters()and clears its internal reference to itsMeterRegistry.
It will also "unfreeze" the object, making it available for reconfiguration.protected voidvalidateFieldSetMap(Map<String, String> fieldsMap) Validates the field set map.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ISOMsgMetrics
addTags
-
Constructor Details
-
ISOMsgCounter
Default constructor.- Throws:
ConfigurationException- if configuration fails
-
-
Method Details
-
getMetricSignature
Returns the metric meters.- Specified by:
getMetricSignaturein interfaceISOMsgMetrics- Returns:
- This overrides the default implementation, also including the keys from the internal field set.
-
getMetricName
Description copied from interface:ISOMsgMetricsReturns the metric name.- Specified by:
getMetricNamein interfaceISOMsgMetrics- Returns:
- the metric name
-
setMetricName
Description copied from interface:ISOMsgMetricsSets the metric name.- Specified by:
setMetricNamein interfaceISOMsgMetrics- Parameters:
metricName- the metric name
-
getMetricDescription
Description copied from interface:ISOMsgMetricsReturns the metric description.- Specified by:
getMetricDescriptionin interfaceISOMsgMetrics- Returns:
- the metric description
-
setMetricDescription
Description copied from interface:ISOMsgMetricsSets the metric description.- Specified by:
setMetricDescriptionin interfaceISOMsgMetrics- Parameters:
metricDescription- the metric description
-
addTags
Description copied from interface:ISOMsgMetricsAdds metric tags to the given Tags object.- Specified by:
addTagsin interfaceISOMsgMetrics- Parameters:
tags- the Tags to add to- Returns:
- the updated Tags
-
getTags
Description copied from interface:ISOMsgMetricsReturns all metric tags.- Specified by:
getTagsin interfaceISOMsgMetrics- Returns:
- the metric tags
-
recordMessage
Description copied from interface:ISOMsgMetricsRecords anISOMsgin the meter registry.
The metric name and tags will be taken strictly from this object's configuration.
If this object hasn't been successfully registered, it throws anIllegalStateException.- Specified by:
recordMessagein interfaceISOMsgMetrics- Parameters:
m- theISOMsgto record.
-
recordMessage
Description copied from interface:ISOMsgMetricsRecords anISOMsgin the meter registry.
Similar toISOMsgMetrics.recordMessage(ISOMsg)but using the metric name, description and maybe some tags taken from theMeterInfoargument.If the metric for that combination of
MeterInfovalues and local values fails to register in the globalMeterRegistry(or any underlying one like the Prometheus registry), the method may throw anIllegalStateException. This also happens if this object hasn't been successfully registered by The metric name and tags will be taken from what has been configured. If this object hasn't been successfully registered, it throws anIllegalStateException.- Specified by:
recordMessagein interfaceISOMsgMetrics- Parameters:
m- the ISO messagemeterInfo- the meter info to record
-
register
Description copied from interface:ISOMsgMetricsRegister this object to work with a givenMeterRegistry.
This method may serve more than one purpose in the object's lifecycle:- Assign a
MeterRegistryto be used for the created meters. (The registry can be obtained by callingISOMsgMetrics.getRegistry()) - Before this object has been registered, it can be configured by setting tags, etc.,
but attempting to record a message (e.g. through
ISOMsgMetrics.recordMessage(ISOMsg)) will throw anIllegalStateException. - After it has been registered, it's ready to record messages.
However, it can't be configured any longer, or it will throw an
IllegalStateException. The object's configuration can be considered "frozen". - In some (future) implementation, it may make use of the
ISOMsgMetrics.getMetricSignature()to do some caching to ensure that every metric name has only one set of tag keys, thus avoiding metrics name+keyset collision inPrometheusMeterRegistry.
ISOMsgMetrics.unregister()method should be called when done using this object.- Specified by:
registerin interfaceISOMsgMetrics- Parameters:
registry- the meter registry to register with- Returns:
- true if successful, false if there was an error
- Assign a
-
unregister
Description copied from interface:ISOMsgMetricsIt callsISOMsgMetrics.removeMeters()and clears its internal reference to itsMeterRegistry.
It will also "unfreeze" the object, making it available for reconfiguration.- Specified by:
unregisterin interfaceISOMsgMetrics
-
getRegistry
Description copied from interface:ISOMsgMetricsReturns the meter registry.- Specified by:
getRegistryin interfaceISOMsgMetrics- Returns:
- the MeterRegistry
-
removeMeters
Description copied from interface:ISOMsgMetricsRemoves all registered meters.- Specified by:
removeMetersin interfaceISOMsgMetrics
-
setConfiguration
Description copied from interface:ConfigurableConfigures this object with the suppliedConfiguration.- Specified by:
setConfigurationin interfaceConfigurable- Parameters:
cfg- Configuration object- Throws:
ConfigurationException- if the configuration is invalid
-
parseTagPairs
Parses tag-value pairs from a string.- Parameters:
tp- tag-pair string to parsecopySingleTag- if true, copy single tags- Returns:
- the parsed tag pairs
-
validateFieldSetMap
Validates the field set map.- Parameters:
fieldsMap- the field set map to validate- Throws:
ConfigurationException- if validation fails
-
getMeters
-
getFieldSet
Returns the configured field set map.- Returns:
- the field set map
-
getTagsAsMap
-
resolveValExpr
Hook for subclasses to resolve, against an ISOMsg, the valexpr part of a tag:valexpr in a fieldset.
A subclass may add or override its own aliases, or have a special way to convert "valexpr" to a String taken from the given ISOMsg.
If the subclass can't resolve the alias/valexpr, it may call super (i.e. this method) as a fallback.- Parameters:
m- the ISOMsg whose fields are inspectedval- the valexpr (alias name or field path) to resolve- Returns:
- the resolved value, or an empty string when no value is available
-
setLogger
-
getRealm
-
getLogger
-