Skip to content

Commit c285221

Browse files
authored
Merge pull request #210 from prom-client-net/feat/debug-info
More debug info in exception message
2 parents 74d4c83 + 3363983 commit c285221

File tree

17 files changed

+189
-104
lines changed

17 files changed

+189
-104
lines changed

src/Prometheus.Client.Abstractions/Collectors/ICollectorRegistry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public interface ICollectorRegistry
1313

1414
TCollector GetOrAdd<TCollector, TConfig>(TConfig config, Func<TConfig, TCollector> collectorFactory)
1515
where TCollector : class, ICollector
16-
where TConfig: CollectorConfiguration;
16+
where TConfig : CollectorConfiguration;
1717

1818
ICollector Remove(string name);
1919

src/Prometheus.Client.Abstractions/CounterExtensions.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static void IncTo(this IMetricFamily<ICounter> metricFamily, double value
4949

5050
public static void Inc<TLabels>(this IMetricFamily<ICounter, TLabels> metricFamily, double increment = 1)
5151
#if HasITuple
52-
where TLabels : struct, ITuple, IEquatable<TLabels>
52+
where TLabels : struct, ITuple, IEquatable<TLabels>
5353
#else
5454
where TLabels : struct, IEquatable<TLabels>
5555
#endif
@@ -59,7 +59,7 @@ public static void Inc<TLabels>(this IMetricFamily<ICounter, TLabels> metricFami
5959

6060
public static void Inc<TLabels>(this IMetricFamily<ICounter, TLabels> metricFamily, double increment, long timestamp)
6161
#if HasITuple
62-
where TLabels : struct, ITuple, IEquatable<TLabels>
62+
where TLabels : struct, ITuple, IEquatable<TLabels>
6363
#else
6464
where TLabels : struct, IEquatable<TLabels>
6565
#endif
@@ -69,7 +69,7 @@ public static void Inc<TLabels>(this IMetricFamily<ICounter, TLabels> metricFami
6969

7070
public static void Inc<TLabels>(this IMetricFamily<ICounter, TLabels> metricFamily, double increment, DateTimeOffset timestamp)
7171
#if HasITuple
72-
where TLabels : struct, ITuple, IEquatable<TLabels>
72+
where TLabels : struct, ITuple, IEquatable<TLabels>
7373
#else
7474
where TLabels : struct, IEquatable<TLabels>
7575
#endif
@@ -79,7 +79,7 @@ public static void Inc<TLabels>(this IMetricFamily<ICounter, TLabels> metricFami
7979

8080
public static void IncTo<TLabels>(this IMetricFamily<ICounter, TLabels> metricFamily, double value)
8181
#if HasITuple
82-
where TLabels : struct, ITuple, IEquatable<TLabels>
82+
where TLabels : struct, ITuple, IEquatable<TLabels>
8383
#else
8484
where TLabels : struct, IEquatable<TLabels>
8585
#endif
@@ -89,7 +89,7 @@ public static void IncTo<TLabels>(this IMetricFamily<ICounter, TLabels> metricFa
8989

9090
public static void IncTo<TLabels>(this IMetricFamily<ICounter, TLabels> metricFamily, double value, long timestamp)
9191
#if HasITuple
92-
where TLabels : struct, ITuple, IEquatable<TLabels>
92+
where TLabels : struct, ITuple, IEquatable<TLabels>
9393
#else
9494
where TLabels : struct, IEquatable<TLabels>
9595
#endif
@@ -99,15 +99,16 @@ public static void IncTo<TLabels>(this IMetricFamily<ICounter, TLabels> metricFa
9999

100100
public static void IncTo<TLabels>(this IMetricFamily<ICounter, TLabels> metricFamily, double value, DateTimeOffset timestamp)
101101
#if HasITuple
102-
where TLabels : struct, ITuple, IEquatable<TLabels>
102+
where TLabels : struct, ITuple, IEquatable<TLabels>
103103
#else
104104
where TLabels : struct, IEquatable<TLabels>
105105
#endif
106106
{
107107
metricFamily.Unlabelled.IncTo(value, timestamp);
108108
}
109109

110-
public static IMetricFamily<ICounter, ValueTuple<string>> CreateCounter(this IMetricFactory factory, string name, string help, string labelName, bool includeTimestamp = false)
110+
public static IMetricFamily<ICounter, ValueTuple<string>> CreateCounter(this IMetricFactory factory, string name, string help, string labelName,
111+
bool includeTimestamp = false)
111112
{
112113
return factory.CreateCounter(name, help, ValueTuple.Create(labelName), includeTimestamp);
113114
}

src/Prometheus.Client.Abstractions/CounterInt64Extensions.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static void IncTo(this IMetricFamily<ICounter<long>> metricFamily, long v
4949

5050
public static void Inc<TLabels>(this IMetricFamily<ICounter<long>, TLabels> metricFamily, long increment = 1)
5151
#if HasITuple
52-
where TLabels : struct, ITuple, IEquatable<TLabels>
52+
where TLabels : struct, ITuple, IEquatable<TLabels>
5353
#else
5454
where TLabels : struct, IEquatable<TLabels>
5555
#endif
@@ -59,7 +59,7 @@ public static void Inc<TLabels>(this IMetricFamily<ICounter<long>, TLabels> metr
5959

6060
public static void Inc<TLabels>(this IMetricFamily<ICounter<long>, TLabels> metricFamily, long increment, long timestamp)
6161
#if HasITuple
62-
where TLabels : struct, ITuple, IEquatable<TLabels>
62+
where TLabels : struct, ITuple, IEquatable<TLabels>
6363
#else
6464
where TLabels : struct, IEquatable<TLabels>
6565
#endif
@@ -69,7 +69,7 @@ public static void Inc<TLabels>(this IMetricFamily<ICounter<long>, TLabels> metr
6969

7070
public static void Inc<TLabels>(this IMetricFamily<ICounter<long>, TLabels> metricFamily, long increment, DateTimeOffset timestamp)
7171
#if HasITuple
72-
where TLabels : struct, ITuple, IEquatable<TLabels>
72+
where TLabels : struct, ITuple, IEquatable<TLabels>
7373
#else
7474
where TLabels : struct, IEquatable<TLabels>
7575
#endif
@@ -79,7 +79,7 @@ public static void Inc<TLabels>(this IMetricFamily<ICounter<long>, TLabels> metr
7979

8080
public static void IncTo<TLabels>(this IMetricFamily<ICounter<long>, TLabels> metricFamily, long value)
8181
#if HasITuple
82-
where TLabels : struct, ITuple, IEquatable<TLabels>
82+
where TLabels : struct, ITuple, IEquatable<TLabels>
8383
#else
8484
where TLabels : struct, IEquatable<TLabels>
8585
#endif
@@ -89,7 +89,7 @@ public static void IncTo<TLabels>(this IMetricFamily<ICounter<long>, TLabels> me
8989

9090
public static void IncTo<TLabels>(this IMetricFamily<ICounter<long>, TLabels> metricFamily, long value, long timestamp)
9191
#if HasITuple
92-
where TLabels : struct, ITuple, IEquatable<TLabels>
92+
where TLabels : struct, ITuple, IEquatable<TLabels>
9393
#else
9494
where TLabels : struct, IEquatable<TLabels>
9595
#endif
@@ -99,15 +99,16 @@ public static void IncTo<TLabels>(this IMetricFamily<ICounter<long>, TLabels> me
9999

100100
public static void IncTo<TLabels>(this IMetricFamily<ICounter<long>, TLabels> metricFamily, long value, DateTimeOffset timestamp)
101101
#if HasITuple
102-
where TLabels : struct, ITuple, IEquatable<TLabels>
102+
where TLabels : struct, ITuple, IEquatable<TLabels>
103103
#else
104104
where TLabels : struct, IEquatable<TLabels>
105105
#endif
106106
{
107107
metricFamily.Unlabelled.IncTo(value, timestamp);
108108
}
109109

110-
public static IMetricFamily<ICounter<long>, ValueTuple<string>> CreateCounterInt64(this IMetricFactory factory, string name, string help, string labelName, bool includeTimestamp = false)
110+
public static IMetricFamily<ICounter<long>, ValueTuple<string>> CreateCounterInt64(this IMetricFactory factory, string name, string help, string labelName,
111+
bool includeTimestamp = false)
111112
{
112113
return factory.CreateCounterInt64(name, help, ValueTuple.Create(labelName), includeTimestamp);
113114
}

src/Prometheus.Client.Abstractions/GaugeExtensions.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public static void Set(this IMetricFamily<IGauge> metricFamily, double value, Da
109109

110110
public static void Inc<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double increment = 1)
111111
#if HasITuple
112-
where TLabels : struct, ITuple, IEquatable<TLabels>
112+
where TLabels : struct, ITuple, IEquatable<TLabels>
113113
#else
114114
where TLabels : struct, IEquatable<TLabels>
115115
#endif
@@ -119,7 +119,7 @@ public static void Inc<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily
119119

120120
public static void Inc<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double increment, long timestamp)
121121
#if HasITuple
122-
where TLabels : struct, ITuple, IEquatable<TLabels>
122+
where TLabels : struct, ITuple, IEquatable<TLabels>
123123
#else
124124
where TLabels : struct, IEquatable<TLabels>
125125
#endif
@@ -129,7 +129,7 @@ public static void Inc<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily
129129

130130
public static void Inc<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double increment, DateTimeOffset timestamp)
131131
#if HasITuple
132-
where TLabels : struct, ITuple, IEquatable<TLabels>
132+
where TLabels : struct, ITuple, IEquatable<TLabels>
133133
#else
134134
where TLabels : struct, IEquatable<TLabels>
135135
#endif
@@ -139,7 +139,7 @@ public static void Inc<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily
139139

140140
public static void IncTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double value)
141141
#if HasITuple
142-
where TLabels : struct, ITuple, IEquatable<TLabels>
142+
where TLabels : struct, ITuple, IEquatable<TLabels>
143143
#else
144144
where TLabels : struct, IEquatable<TLabels>
145145
#endif
@@ -149,7 +149,7 @@ public static void IncTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFami
149149

150150
public static void IncTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double value, long timestamp)
151151
#if HasITuple
152-
where TLabels : struct, ITuple, IEquatable<TLabels>
152+
where TLabels : struct, ITuple, IEquatable<TLabels>
153153
#else
154154
where TLabels : struct, IEquatable<TLabels>
155155
#endif
@@ -159,7 +159,7 @@ public static void IncTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFami
159159

160160
public static void IncTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double value, DateTimeOffset timestamp)
161161
#if HasITuple
162-
where TLabels : struct, ITuple, IEquatable<TLabels>
162+
where TLabels : struct, ITuple, IEquatable<TLabels>
163163
#else
164164
where TLabels : struct, IEquatable<TLabels>
165165
#endif
@@ -169,7 +169,7 @@ public static void IncTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFami
169169

170170
public static void Dec<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double decrement = 1)
171171
#if HasITuple
172-
where TLabels : struct, ITuple, IEquatable<TLabels>
172+
where TLabels : struct, ITuple, IEquatable<TLabels>
173173
#else
174174
where TLabels : struct, IEquatable<TLabels>
175175
#endif
@@ -179,7 +179,7 @@ public static void Dec<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily
179179

180180
public static void Dec<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double decrement, long timestamp)
181181
#if HasITuple
182-
where TLabels : struct, ITuple, IEquatable<TLabels>
182+
where TLabels : struct, ITuple, IEquatable<TLabels>
183183
#else
184184
where TLabels : struct, IEquatable<TLabels>
185185
#endif
@@ -189,7 +189,7 @@ public static void Dec<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily
189189

190190
public static void Dec<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double decrement, DateTimeOffset timestamp)
191191
#if HasITuple
192-
where TLabels : struct, ITuple, IEquatable<TLabels>
192+
where TLabels : struct, ITuple, IEquatable<TLabels>
193193
#else
194194
where TLabels : struct, IEquatable<TLabels>
195195
#endif
@@ -199,7 +199,7 @@ public static void Dec<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily
199199

200200
public static void DecTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double value)
201201
#if HasITuple
202-
where TLabels : struct, ITuple, IEquatable<TLabels>
202+
where TLabels : struct, ITuple, IEquatable<TLabels>
203203
#else
204204
where TLabels : struct, IEquatable<TLabels>
205205
#endif
@@ -209,7 +209,7 @@ public static void DecTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFami
209209

210210
public static void DecTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double value, long timestamp)
211211
#if HasITuple
212-
where TLabels : struct, ITuple, IEquatable<TLabels>
212+
where TLabels : struct, ITuple, IEquatable<TLabels>
213213
#else
214214
where TLabels : struct, IEquatable<TLabels>
215215
#endif
@@ -219,7 +219,7 @@ public static void DecTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFami
219219

220220
public static void DecTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double value, DateTimeOffset timestamp)
221221
#if HasITuple
222-
where TLabels : struct, ITuple, IEquatable<TLabels>
222+
where TLabels : struct, ITuple, IEquatable<TLabels>
223223
#else
224224
where TLabels : struct, IEquatable<TLabels>
225225
#endif
@@ -229,7 +229,7 @@ public static void DecTo<TLabels>(this IMetricFamily<IGauge, TLabels> metricFami
229229

230230
public static void Set<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double value)
231231
#if HasITuple
232-
where TLabels : struct, ITuple, IEquatable<TLabels>
232+
where TLabels : struct, ITuple, IEquatable<TLabels>
233233
#else
234234
where TLabels : struct, IEquatable<TLabels>
235235
#endif
@@ -239,7 +239,7 @@ public static void Set<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily
239239

240240
public static void Set<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double value, long timestamp)
241241
#if HasITuple
242-
where TLabels : struct, ITuple, IEquatable<TLabels>
242+
where TLabels : struct, ITuple, IEquatable<TLabels>
243243
#else
244244
where TLabels : struct, IEquatable<TLabels>
245245
#endif
@@ -249,7 +249,7 @@ public static void Set<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily
249249

250250
public static void Set<TLabels>(this IMetricFamily<IGauge, TLabels> metricFamily, double value, DateTimeOffset timestamp)
251251
#if HasITuple
252-
where TLabels : struct, ITuple, IEquatable<TLabels>
252+
where TLabels : struct, ITuple, IEquatable<TLabels>
253253
#else
254254
where TLabels : struct, IEquatable<TLabels>
255255
#endif

src/Prometheus.Client.Abstractions/GaugeInt64Extensions.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public static void Set(this IMetricFamily<IGauge<long>> metricFamily, long value
109109

110110
public static void Inc<TLabels>(this IMetricFamily<IGauge<long>, TLabels> metricFamily, long increment = 1)
111111
#if HasITuple
112-
where TLabels : struct, ITuple, IEquatable<TLabels>
112+
where TLabels : struct, ITuple, IEquatable<TLabels>
113113
#else
114114
where TLabels : struct, IEquatable<TLabels>
115115
#endif
@@ -119,7 +119,7 @@ public static void Inc<TLabels>(this IMetricFamily<IGauge<long>, TLabels> metric
119119

120120
public static void Inc<TLabels>(this IMetricFamily<IGauge<long>, TLabels> metricFamily, long increment, long timestamp)
121121
#if HasITuple
122-
where TLabels : struct, ITuple, IEquatable<TLabels>
122+
where TLabels : struct, ITuple, IEquatable<TLabels>
123123
#else
124124
where TLabels : struct, IEquatable<TLabels>
125125
#endif
@@ -129,7 +129,7 @@ public static void Inc<TLabels>(this IMetricFamily<IGauge<long>, TLabels> metric
129129

130130
public static void Inc<TLabels>(this IMetricFamily<IGauge<long>, TLabels> metricFamily, long increment, DateTimeOffset timestamp)
131131
#if HasITuple
132-
where TLabels : struct, ITuple, IEquatable<TLabels>
132+
where TLabels : struct, ITuple, IEquatable<TLabels>
133133
#else
134134
where TLabels : struct, IEquatable<TLabels>
135135
#endif
@@ -169,7 +169,7 @@ public static void IncTo<TLabels>(this IMetricFamily<IGauge<long>, TLabels> metr
169169

170170
public static void Dec<TLabels>(this IMetricFamily<IGauge<long>, TLabels> metricFamily, long decrement = 1)
171171
#if HasITuple
172-
where TLabels : struct, ITuple, IEquatable<TLabels>
172+
where TLabels : struct, ITuple, IEquatable<TLabels>
173173
#else
174174
where TLabels : struct, IEquatable<TLabels>
175175
#endif
@@ -189,7 +189,7 @@ public static void Dec<TLabels>(this IMetricFamily<IGauge<long>, TLabels> metric
189189

190190
public static void Dec<TLabels>(this IMetricFamily<IGauge<long>, TLabels> metricFamily, long decrement, DateTimeOffset timestamp)
191191
#if HasITuple
192-
where TLabels : struct, ITuple, IEquatable<TLabels>
192+
where TLabels : struct, ITuple, IEquatable<TLabels>
193193
#else
194194
where TLabels : struct, IEquatable<TLabels>
195195
#endif
@@ -229,7 +229,7 @@ public static void DecTo<TLabels>(this IMetricFamily<IGauge<long>, TLabels> metr
229229

230230
public static void Set<TLabels>(this IMetricFamily<IGauge<long>, TLabels> metricFamily, long value)
231231
#if HasITuple
232-
where TLabels : struct, ITuple, IEquatable<TLabels>
232+
where TLabels : struct, ITuple, IEquatable<TLabels>
233233
#else
234234
where TLabels : struct, IEquatable<TLabels>
235235
#endif
@@ -239,7 +239,7 @@ public static void Set<TLabels>(this IMetricFamily<IGauge<long>, TLabels> metric
239239

240240
public static void Set<TLabels>(this IMetricFamily<IGauge<long>, TLabels> metricFamily, long value, long timestamp)
241241
#if HasITuple
242-
where TLabels : struct, ITuple, IEquatable<TLabels>
242+
where TLabels : struct, ITuple, IEquatable<TLabels>
243243
#else
244244
where TLabels : struct, IEquatable<TLabels>
245245
#endif
@@ -249,15 +249,16 @@ public static void Set<TLabels>(this IMetricFamily<IGauge<long>, TLabels> metric
249249

250250
public static void Set<TLabels>(this IMetricFamily<IGauge<long>, TLabels> metricFamily, long value, DateTimeOffset timestamp)
251251
#if HasITuple
252-
where TLabels : struct, ITuple, IEquatable<TLabels>
252+
where TLabels : struct, ITuple, IEquatable<TLabels>
253253
#else
254254
where TLabels : struct, IEquatable<TLabels>
255255
#endif
256256
{
257257
metricFamily.Unlabelled.Set(value, timestamp);
258258
}
259259

260-
public static IMetricFamily<IGauge<long>, ValueTuple<string>> CreateGaugeInt64(this IMetricFactory factory, string name, string help, string labelName, bool includeTimestamp = false)
260+
public static IMetricFamily<IGauge<long>, ValueTuple<string>> CreateGaugeInt64(this IMetricFactory factory, string name, string help, string labelName,
261+
bool includeTimestamp = false)
261262
{
262263
return factory.CreateGaugeInt64(name, help, ValueTuple.Create(labelName), includeTimestamp);
263264
}

src/Prometheus.Client.Abstractions/HistogramExtensions.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static void Observe(this IMetricFamily<IHistogram> metricFamily, double v
2929

3030
public static void Observe<TLabels>(this IMetricFamily<IHistogram, TLabels> metricFamily, double val)
3131
#if HasITuple
32-
where TLabels : struct, ITuple, IEquatable<TLabels>
32+
where TLabels : struct, ITuple, IEquatable<TLabels>
3333
#else
3434
where TLabels : struct, IEquatable<TLabels>
3535
#endif
@@ -49,15 +49,16 @@ public static void Observe<TLabels>(this IMetricFamily<IHistogram, TLabels> metr
4949

5050
public static void Observe<TLabels>(this IMetricFamily<IHistogram, TLabels> metricFamily, double val, DateTimeOffset timestamp)
5151
#if HasITuple
52-
where TLabels : struct, ITuple, IEquatable<TLabels>
52+
where TLabels : struct, ITuple, IEquatable<TLabels>
5353
#else
5454
where TLabels : struct, IEquatable<TLabels>
5555
#endif
5656
{
5757
metricFamily.Unlabelled.Observe(val, timestamp.ToUnixTimeMilliseconds());
5858
}
5959

60-
public static IMetricFamily<IHistogram, ValueTuple<string>> CreateHistogram(this IMetricFactory factory, string name, string help, string labelName, bool includeTimestamp = false, double[] buckets = null)
60+
public static IMetricFamily<IHistogram, ValueTuple<string>> CreateHistogram(this IMetricFactory factory, string name, string help, string labelName,
61+
bool includeTimestamp = false, double[] buckets = null)
6162
{
6263
return factory.CreateHistogram(name, help, ValueTuple.Create(labelName), includeTimestamp, buckets);
6364
}

src/Prometheus.Client.Abstractions/IGauge.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ public interface IGauge<T> : IMetric<T>
3535
}
3636

3737
public interface IGauge : IGauge<double>
38-
{}
38+
{
39+
}
3940
}

0 commit comments

Comments
 (0)