Skip to content

Conversation

cmgt
Copy link
Contributor

@cmgt cmgt commented Nov 25, 2022

It's probably just a typo. But the problem is blocking.
Here prometheus-net-dotpulsar is an example to reproduce the error.

When you create a custom Meter specifying a unit, such as this:

m = new Meter("prometheus-dotpulsar", "1.0.0");
_ = m.CreateObservableGauge("dotpulsar.client.count", Inc, "{clients}", "Number of clients");

an unhandled exception occurs in the TranslateInstrumentDescriptionToPrometheusHelp method of the MeterAdapter class

sb.AppendFormat($"({instrument.Unit}) ");

System.FormatException: Input string was not in a correct format.
   at System.ThrowHelper.ThrowFormatInvalidString()
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
System.FormatException: Input string was not in a correct format.
   at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ReadOnlySpan`1 args)
   at System.Text.StringBuilder.AppendFormat(String format, Object[] args)
   at Prometheus.MeterAdapter.TranslateInstrumentDescriptionToPrometheusHelp(Instrument instrument)
   at Prometheus.MeterAdapter.OnInstrumentPublished(Instrument instrument, MeterListener listener)
   at System.Diagnostics.Metrics.MeterListener.Start()
   at Prometheus.MeterAdapter..ctor(MeterAdapterOptions options)
   at Prometheus.MeterAdapter.StartListening(MeterAdapterOptions options)
   at Prometheus.SuppressDefaultMetricOptions.Configure(CollectorRegistry registry, ConfigurationCallbacks configurationCallbacks)
   at Prometheus.Metrics.<>c__DisplayClass23_0.<SuppressDefaultMetrics>b__0()
   at Prometheus.CollectorRegistry.CollectAndSerializeAsync(IMetricsSerializer serializer, CancellationToken cancel)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

@sandersaares sandersaares merged commit 7eec46b into prometheus-net:master Nov 30, 2022
@sandersaares
Copy link
Member

Good catch, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants