@@ -152,14 +152,17 @@ func (m *meter) Int64Counter(name string, options ...metric.Int64CounterOption)
152
152
return m .delegate .Int64Counter (name , options ... )
153
153
}
154
154
155
- i := & siCounter {name : name , opts : options }
156
155
cfg := metric .NewInt64CounterConfig (options ... )
157
156
id := instID {
158
157
name : name ,
159
- kind : reflect .TypeOf (i ),
158
+ kind : reflect .TypeOf (( * siCounter )( nil ) ),
160
159
description : cfg .Description (),
161
160
unit : cfg .Unit (),
162
161
}
162
+ if f , ok := m .instruments [id ]; ok {
163
+ return f .(metric.Int64Counter ), nil
164
+ }
165
+ i := & siCounter {name : name , opts : options }
163
166
m .instruments [id ] = i
164
167
return i , nil
165
168
}
@@ -172,14 +175,17 @@ func (m *meter) Int64UpDownCounter(name string, options ...metric.Int64UpDownCou
172
175
return m .delegate .Int64UpDownCounter (name , options ... )
173
176
}
174
177
175
- i := & siUpDownCounter {name : name , opts : options }
176
178
cfg := metric .NewInt64UpDownCounterConfig (options ... )
177
179
id := instID {
178
180
name : name ,
179
- kind : reflect .TypeOf (i ),
181
+ kind : reflect .TypeOf (( * siUpDownCounter )( nil ) ),
180
182
description : cfg .Description (),
181
183
unit : cfg .Unit (),
182
184
}
185
+ if f , ok := m .instruments [id ]; ok {
186
+ return f .(metric.Int64UpDownCounter ), nil
187
+ }
188
+ i := & siUpDownCounter {name : name , opts : options }
183
189
m .instruments [id ] = i
184
190
return i , nil
185
191
}
@@ -192,14 +198,17 @@ func (m *meter) Int64Histogram(name string, options ...metric.Int64HistogramOpti
192
198
return m .delegate .Int64Histogram (name , options ... )
193
199
}
194
200
195
- i := & siHistogram {name : name , opts : options }
196
201
cfg := metric .NewInt64HistogramConfig (options ... )
197
202
id := instID {
198
203
name : name ,
199
- kind : reflect .TypeOf (i ),
204
+ kind : reflect .TypeOf (( * siHistogram )( nil ) ),
200
205
description : cfg .Description (),
201
206
unit : cfg .Unit (),
202
207
}
208
+ if f , ok := m .instruments [id ]; ok {
209
+ return f .(metric.Int64Histogram ), nil
210
+ }
211
+ i := & siHistogram {name : name , opts : options }
203
212
m .instruments [id ] = i
204
213
return i , nil
205
214
}
@@ -212,14 +221,17 @@ func (m *meter) Int64Gauge(name string, options ...metric.Int64GaugeOption) (met
212
221
return m .delegate .Int64Gauge (name , options ... )
213
222
}
214
223
215
- i := & siGauge {name : name , opts : options }
216
224
cfg := metric .NewInt64GaugeConfig (options ... )
217
225
id := instID {
218
226
name : name ,
219
- kind : reflect .TypeOf (i ),
227
+ kind : reflect .TypeOf (( * siGauge )( nil ) ),
220
228
description : cfg .Description (),
221
229
unit : cfg .Unit (),
222
230
}
231
+ if f , ok := m .instruments [id ]; ok {
232
+ return f .(metric.Int64Gauge ), nil
233
+ }
234
+ i := & siGauge {name : name , opts : options }
223
235
m .instruments [id ] = i
224
236
return i , nil
225
237
}
@@ -232,14 +244,17 @@ func (m *meter) Int64ObservableCounter(name string, options ...metric.Int64Obser
232
244
return m .delegate .Int64ObservableCounter (name , options ... )
233
245
}
234
246
235
- i := & aiCounter {name : name , opts : options }
236
247
cfg := metric .NewInt64ObservableCounterConfig (options ... )
237
248
id := instID {
238
249
name : name ,
239
- kind : reflect .TypeOf (i ),
250
+ kind : reflect .TypeOf (( * aiCounter )( nil ) ),
240
251
description : cfg .Description (),
241
252
unit : cfg .Unit (),
242
253
}
254
+ if f , ok := m .instruments [id ]; ok {
255
+ return f .(metric.Int64ObservableCounter ), nil
256
+ }
257
+ i := & aiCounter {name : name , opts : options }
243
258
m .instruments [id ] = i
244
259
return i , nil
245
260
}
@@ -252,14 +267,17 @@ func (m *meter) Int64ObservableUpDownCounter(name string, options ...metric.Int6
252
267
return m .delegate .Int64ObservableUpDownCounter (name , options ... )
253
268
}
254
269
255
- i := & aiUpDownCounter {name : name , opts : options }
256
270
cfg := metric .NewInt64ObservableUpDownCounterConfig (options ... )
257
271
id := instID {
258
272
name : name ,
259
- kind : reflect .TypeOf (i ),
273
+ kind : reflect .TypeOf (( * aiUpDownCounter )( nil ) ),
260
274
description : cfg .Description (),
261
275
unit : cfg .Unit (),
262
276
}
277
+ if f , ok := m .instruments [id ]; ok {
278
+ return f .(metric.Int64ObservableUpDownCounter ), nil
279
+ }
280
+ i := & aiUpDownCounter {name : name , opts : options }
263
281
m .instruments [id ] = i
264
282
return i , nil
265
283
}
@@ -272,14 +290,17 @@ func (m *meter) Int64ObservableGauge(name string, options ...metric.Int64Observa
272
290
return m .delegate .Int64ObservableGauge (name , options ... )
273
291
}
274
292
275
- i := & aiGauge {name : name , opts : options }
276
293
cfg := metric .NewInt64ObservableGaugeConfig (options ... )
277
294
id := instID {
278
295
name : name ,
279
- kind : reflect .TypeOf (i ),
296
+ kind : reflect .TypeOf (( * aiGauge )( nil ) ),
280
297
description : cfg .Description (),
281
298
unit : cfg .Unit (),
282
299
}
300
+ if f , ok := m .instruments [id ]; ok {
301
+ return f .(metric.Int64ObservableGauge ), nil
302
+ }
303
+ i := & aiGauge {name : name , opts : options }
283
304
m .instruments [id ] = i
284
305
return i , nil
285
306
}
@@ -292,14 +313,17 @@ func (m *meter) Float64Counter(name string, options ...metric.Float64CounterOpti
292
313
return m .delegate .Float64Counter (name , options ... )
293
314
}
294
315
295
- i := & sfCounter {name : name , opts : options }
296
316
cfg := metric .NewFloat64CounterConfig (options ... )
297
317
id := instID {
298
318
name : name ,
299
- kind : reflect .TypeOf (i ),
319
+ kind : reflect .TypeOf (( * sfCounter )( nil ) ),
300
320
description : cfg .Description (),
301
321
unit : cfg .Unit (),
302
322
}
323
+ if f , ok := m .instruments [id ]; ok {
324
+ return f .(metric.Float64Counter ), nil
325
+ }
326
+ i := & sfCounter {name : name , opts : options }
303
327
m .instruments [id ] = i
304
328
return i , nil
305
329
}
@@ -312,14 +336,17 @@ func (m *meter) Float64UpDownCounter(name string, options ...metric.Float64UpDow
312
336
return m .delegate .Float64UpDownCounter (name , options ... )
313
337
}
314
338
315
- i := & sfUpDownCounter {name : name , opts : options }
316
339
cfg := metric .NewFloat64UpDownCounterConfig (options ... )
317
340
id := instID {
318
341
name : name ,
319
- kind : reflect .TypeOf (i ),
342
+ kind : reflect .TypeOf (( * sfUpDownCounter )( nil ) ),
320
343
description : cfg .Description (),
321
344
unit : cfg .Unit (),
322
345
}
346
+ if f , ok := m .instruments [id ]; ok {
347
+ return f .(metric.Float64UpDownCounter ), nil
348
+ }
349
+ i := & sfUpDownCounter {name : name , opts : options }
323
350
m .instruments [id ] = i
324
351
return i , nil
325
352
}
@@ -332,14 +359,17 @@ func (m *meter) Float64Histogram(name string, options ...metric.Float64Histogram
332
359
return m .delegate .Float64Histogram (name , options ... )
333
360
}
334
361
335
- i := & sfHistogram {name : name , opts : options }
336
362
cfg := metric .NewFloat64HistogramConfig (options ... )
337
363
id := instID {
338
364
name : name ,
339
- kind : reflect .TypeOf (i ),
365
+ kind : reflect .TypeOf (( * sfHistogram )( nil ) ),
340
366
description : cfg .Description (),
341
367
unit : cfg .Unit (),
342
368
}
369
+ if f , ok := m .instruments [id ]; ok {
370
+ return f .(metric.Float64Histogram ), nil
371
+ }
372
+ i := & sfHistogram {name : name , opts : options }
343
373
m .instruments [id ] = i
344
374
return i , nil
345
375
}
@@ -352,14 +382,17 @@ func (m *meter) Float64Gauge(name string, options ...metric.Float64GaugeOption)
352
382
return m .delegate .Float64Gauge (name , options ... )
353
383
}
354
384
355
- i := & sfGauge {name : name , opts : options }
356
385
cfg := metric .NewFloat64GaugeConfig (options ... )
357
386
id := instID {
358
387
name : name ,
359
- kind : reflect .TypeOf (i ),
388
+ kind : reflect .TypeOf (( * sfGauge )( nil ) ),
360
389
description : cfg .Description (),
361
390
unit : cfg .Unit (),
362
391
}
392
+ if f , ok := m .instruments [id ]; ok {
393
+ return f .(metric.Float64Gauge ), nil
394
+ }
395
+ i := & sfGauge {name : name , opts : options }
363
396
m .instruments [id ] = i
364
397
return i , nil
365
398
}
@@ -372,14 +405,17 @@ func (m *meter) Float64ObservableCounter(name string, options ...metric.Float64O
372
405
return m .delegate .Float64ObservableCounter (name , options ... )
373
406
}
374
407
375
- i := & afCounter {name : name , opts : options }
376
408
cfg := metric .NewFloat64ObservableCounterConfig (options ... )
377
409
id := instID {
378
410
name : name ,
379
- kind : reflect .TypeOf (i ),
411
+ kind : reflect .TypeOf (( * afCounter )( nil ) ),
380
412
description : cfg .Description (),
381
413
unit : cfg .Unit (),
382
414
}
415
+ if f , ok := m .instruments [id ]; ok {
416
+ return f .(metric.Float64ObservableCounter ), nil
417
+ }
418
+ i := & afCounter {name : name , opts : options }
383
419
m .instruments [id ] = i
384
420
return i , nil
385
421
}
@@ -392,14 +428,17 @@ func (m *meter) Float64ObservableUpDownCounter(name string, options ...metric.Fl
392
428
return m .delegate .Float64ObservableUpDownCounter (name , options ... )
393
429
}
394
430
395
- i := & afUpDownCounter {name : name , opts : options }
396
431
cfg := metric .NewFloat64ObservableUpDownCounterConfig (options ... )
397
432
id := instID {
398
433
name : name ,
399
- kind : reflect .TypeOf (i ),
434
+ kind : reflect .TypeOf (( * afUpDownCounter )( nil ) ),
400
435
description : cfg .Description (),
401
436
unit : cfg .Unit (),
402
437
}
438
+ if f , ok := m .instruments [id ]; ok {
439
+ return f .(metric.Float64ObservableUpDownCounter ), nil
440
+ }
441
+ i := & afUpDownCounter {name : name , opts : options }
403
442
m .instruments [id ] = i
404
443
return i , nil
405
444
}
@@ -412,14 +451,17 @@ func (m *meter) Float64ObservableGauge(name string, options ...metric.Float64Obs
412
451
return m .delegate .Float64ObservableGauge (name , options ... )
413
452
}
414
453
415
- i := & afGauge {name : name , opts : options }
416
454
cfg := metric .NewFloat64ObservableGaugeConfig (options ... )
417
455
id := instID {
418
456
name : name ,
419
- kind : reflect .TypeOf (i ),
457
+ kind : reflect .TypeOf (( * afGauge )( nil ) ),
420
458
description : cfg .Description (),
421
459
unit : cfg .Unit (),
422
460
}
461
+ if f , ok := m .instruments [id ]; ok {
462
+ return f .(metric.Float64ObservableGauge ), nil
463
+ }
464
+ i := & afGauge {name : name , opts : options }
423
465
m .instruments [id ] = i
424
466
return i , nil
425
467
}
@@ -487,6 +529,7 @@ func (c *registration) setDelegate(m metric.Meter) {
487
529
reg , err := m .RegisterCallback (c .function , insts ... )
488
530
if err != nil {
489
531
GetErrorHandler ().Handle (err )
532
+ return
490
533
}
491
534
492
535
c .unreg = reg .Unregister
0 commit comments