Skip to content

Commit 7c051c0

Browse files
committed
Implemented offline discussion
1 parent c5cb641 commit 7c051c0

File tree

8 files changed

+119
-708
lines changed

8 files changed

+119
-708
lines changed

experimental/stats/metricregistry.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ type Int64CountHandle struct {
5555

5656
// RecordInt64Count records the int64 count value on the metrics recorder
5757
// provided.
58-
func (h *Int64CountHandle) RecordInt64Count(recorder MetricsRecorder, labels []Label, optionalLabels []Label, incr int64) {
59-
recorder.RecordIntCount(*h, labels, optionalLabels, incr)
58+
func (h Int64CountHandle) RecordInt64Count(recorder MetricsRecorder, incr int64, labels ...string) {
59+
recorder.RecordIntCount(h, incr, labels...)
6060
}
6161

6262
// Float64CountHandle is a typed handle for a float count instrument. This handle
@@ -68,8 +68,8 @@ type Float64CountHandle struct {
6868

6969
// RecordFloat64Count records the float64 count value on the metrics recorder
7070
// provided.
71-
func (h *Float64CountHandle) RecordFloat64Count(recorder MetricsRecorder, labels []Label, optionalLabels []Label, incr float64) {
72-
recorder.RecordFloatCount(*h, labels, optionalLabels, incr)
71+
func (h Float64CountHandle) RecordFloat64Count(recorder MetricsRecorder, incr float64, labels ...string) {
72+
recorder.RecordFloatCount(h, incr, labels...)
7373
}
7474

7575
// Int64HistoHandle is a typed handle for an int histogram instrument. This
@@ -81,8 +81,8 @@ type Int64HistoHandle struct {
8181

8282
// RecordInt64Histo records the int64 histo value on the metrics recorder
8383
// provided.
84-
func (h *Int64HistoHandle) RecordInt64Histo(recorder MetricsRecorder, labels []Label, optionalLabels []Label, incr int64) {
85-
recorder.RecordIntHisto(*h, labels, optionalLabels, incr)
84+
func (h Int64HistoHandle) RecordInt64Histo(recorder MetricsRecorder, incr int64, labels ...string) {
85+
recorder.RecordIntHisto(h, incr, labels...)
8686
}
8787

8888
// Float64HistoHandle is a typed handle for a float histogram instrument. This
@@ -94,8 +94,8 @@ type Float64HistoHandle struct {
9494

9595
// RecordFloat64Histo records the float64 histo value on the metrics recorder
9696
// provided.
97-
func (h *Float64HistoHandle) RecordFloat64Histo(recorder MetricsRecorder, labels []Label, optionalLabels []Label, incr float64) {
98-
recorder.RecordFloatHisto(*h, labels, optionalLabels, incr)
97+
func (h Float64HistoHandle) RecordFloat64Histo(recorder MetricsRecorder, incr float64, labels ...string) {
98+
recorder.RecordFloatHisto(h, incr, labels...)
9999
}
100100

101101
// Int64GaugeHandle is a typed handle for an int gauge instrument. This handle
@@ -107,8 +107,8 @@ type Int64GaugeHandle struct {
107107

108108
// RecordInt64Histo records the int64 histo value on the metrics recorder
109109
// provided.
110-
func (h *Int64GaugeHandle) RecordInt64Gauge(recorder MetricsRecorder, labels []Label, optionalLabels []Label, incr int64) {
111-
recorder.RecordIntGauge(*h, labels, optionalLabels, incr)
110+
func (h Int64GaugeHandle) RecordInt64Gauge(recorder MetricsRecorder, incr int64, labels ...string) {
111+
recorder.RecordIntGauge(h, incr, labels...)
112112
}
113113

114114
// registeredInsts are the registered instrument descriptor names.

experimental/stats/metricregistry/metric_registry.go

Lines changed: 0 additions & 68 deletions
This file was deleted.

experimental/stats/metricregistry_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ func verifyLabels(t *testing.T, labelsWant []string, optionalLabelsWant []string
7474
if len(optionalLabelsWant) != len(optionalLabelsGot) {
7575
t.Fatalf("length of optional labels expected did not match got %v, want %v", len(optionalLabelsGot), len(optionalLabelsWant))
7676
}
77+
78+
// This is essentially now a check of len(labels + optional labels) vs labels provided...
79+
7780
}
7881

7982
// Test 2 for each? 5 different maps...?
@@ -133,3 +136,15 @@ func (r *fakeMetricsRecorder) RecordIntGauge(handle Int64GaugeHandle, labels []L
133136

134137
// If run out of time just push implementation...otel and metrics recorder list still come after I guess...
135138
// just push the extra file....
139+
140+
141+
// Tests sound good to Doug get this plumbing working...
142+
143+
// switch the labels to be variadic args based on position, length check on labels + optional labels
144+
145+
// optional labels are always plumbed up through otel, otel decides whether it
146+
// wants the optional labels or not...
147+
148+
// on handle and metrics recorder
149+
150+

experimental/stats/stats.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,17 @@ package stats
2424
type MetricsRecorder interface {
2525
// RecordIntCount records the measurement alongside labels on the int count
2626
// associated with the provided handle.
27-
RecordIntCount(Int64CountHandle, []Label, []Label, int64)
27+
RecordIntCount(Int64CountHandle, int64, ...string)
2828
// RecordFloatCount records the measurement alongside labels on the float count
2929
// associated with the provided handle.
30-
RecordFloatCount(Float64CountHandle, []Label, []Label, float64)
30+
RecordFloatCount(Float64CountHandle, float64, ...string)
3131
// RecordIntHisto records the measurement alongside labels on the int histo
3232
// associated with the provided handle.
33-
RecordIntHisto(Int64HistoHandle, []Label, []Label, int64)
33+
RecordIntHisto(Int64HistoHandle, int64, ...string)
3434
// RecordFloatHisto records the measurement alongside labels on the float
3535
// histo associated with the provided handle.
36-
RecordFloatHisto(Float64HistoHandle, []Label, []Label, float64)
36+
RecordFloatHisto(Float64HistoHandle, float64, ...string)
3737
// RecordIntGauge records the measurement alongside labels on the int gauge
3838
// associated with the provided handle.
39-
RecordIntGauge(Int64GaugeHandle, []Label, []Label, int64)
40-
}
41-
42-
// Label represents a string attribute/label to attach to metrics.
43-
type Label struct {
44-
// Key is the key of the label.
45-
Key string
46-
// Value is the value of the label.
47-
Value string
39+
RecordIntGauge(Int64GaugeHandle, int64, ...string)
4840
}

internal/stats/instrumentregistry/instrument_registry.go

Lines changed: 0 additions & 199 deletions
This file was deleted.

0 commit comments

Comments
 (0)