You've already forked opentelemetry-go
							
							
				mirror of
				https://github.com/open-telemetry/opentelemetry-go.git
				synced 2025-10-31 00:07:40 +02:00 
			
		
		
		
	Fix exported instrument kind const value change (#5385)
#5304 introduced the following incompatible changes: - `InstrumentKindObservableCounter`: value changed from 4 to 5 - `InstrumentKindObservableGauge`: value changed from 6 to 7 - `InstrumentKindObservableUpDownCounter`: value changed from 5 to 6 This reverts that change, making `InstrumentKindGauge` explicitly `7`. Additionally, this removes the use of `iota` to prevent this kind of breaking change from being accidentally introduced in the future.
This commit is contained in:
		| @@ -30,32 +30,32 @@ type InstrumentKind uint8 | ||||
| const ( | ||||
| 	// instrumentKindUndefined is an undefined instrument kind, it should not | ||||
| 	// be used by any initialized type. | ||||
| 	instrumentKindUndefined InstrumentKind = iota // nolint:deadcode,varcheck,unused | ||||
| 	instrumentKindUndefined InstrumentKind = 0 // nolint:deadcode,varcheck,unused | ||||
| 	// InstrumentKindCounter identifies a group of instruments that record | ||||
| 	// increasing values synchronously with the code path they are measuring. | ||||
| 	InstrumentKindCounter | ||||
| 	InstrumentKindCounter InstrumentKind = 1 | ||||
| 	// InstrumentKindUpDownCounter identifies a group of instruments that | ||||
| 	// record increasing and decreasing values synchronously with the code path | ||||
| 	// they are measuring. | ||||
| 	InstrumentKindUpDownCounter | ||||
| 	InstrumentKindUpDownCounter InstrumentKind = 2 | ||||
| 	// InstrumentKindHistogram identifies a group of instruments that record a | ||||
| 	// distribution of values synchronously with the code path they are | ||||
| 	// measuring. | ||||
| 	InstrumentKindHistogram | ||||
| 	// InstrumentKindGauge identifies a group of instruments that record | ||||
| 	// instantaneous values synchronously with the code path they are | ||||
| 	// measuring. | ||||
| 	InstrumentKindGauge | ||||
| 	InstrumentKindHistogram InstrumentKind = 3 | ||||
| 	// InstrumentKindObservableCounter identifies a group of instruments that | ||||
| 	// record increasing values in an asynchronous callback. | ||||
| 	InstrumentKindObservableCounter | ||||
| 	InstrumentKindObservableCounter InstrumentKind = 4 | ||||
| 	// InstrumentKindObservableUpDownCounter identifies a group of instruments | ||||
| 	// that record increasing and decreasing values in an asynchronous | ||||
| 	// callback. | ||||
| 	InstrumentKindObservableUpDownCounter | ||||
| 	InstrumentKindObservableUpDownCounter InstrumentKind = 5 | ||||
| 	// InstrumentKindObservableGauge identifies a group of instruments that | ||||
| 	// record current values in an asynchronous callback. | ||||
| 	InstrumentKindObservableGauge | ||||
| 	InstrumentKindObservableGauge InstrumentKind = 6 | ||||
| 	// InstrumentKindGauge identifies a group of instruments that record | ||||
| 	// instantaneous values synchronously with the code path they are | ||||
| 	// measuring. | ||||
| 	InstrumentKindGauge InstrumentKind = 7 | ||||
| ) | ||||
|  | ||||
| type nonComparable [0]func() // nolint: unused  // This is indeed used. | ||||
|   | ||||
| @@ -12,15 +12,15 @@ func _() { | ||||
| 	_ = x[InstrumentKindCounter-1] | ||||
| 	_ = x[InstrumentKindUpDownCounter-2] | ||||
| 	_ = x[InstrumentKindHistogram-3] | ||||
| 	_ = x[InstrumentKindGauge-4] | ||||
| 	_ = x[InstrumentKindObservableCounter-5] | ||||
| 	_ = x[InstrumentKindObservableUpDownCounter-6] | ||||
| 	_ = x[InstrumentKindObservableGauge-7] | ||||
| 	_ = x[InstrumentKindObservableCounter-4] | ||||
| 	_ = x[InstrumentKindObservableUpDownCounter-5] | ||||
| 	_ = x[InstrumentKindObservableGauge-6] | ||||
| 	_ = x[InstrumentKindGauge-7] | ||||
| } | ||||
|  | ||||
| const _InstrumentKind_name = "instrumentKindUndefinedCounterUpDownCounterHistogramGaugeObservableCounterObservableUpDownCounterObservableGauge" | ||||
| const _InstrumentKind_name = "instrumentKindUndefinedCounterUpDownCounterHistogramObservableCounterObservableUpDownCounterObservableGaugeGauge" | ||||
|  | ||||
| var _InstrumentKind_index = [...]uint8{0, 23, 30, 43, 52, 57, 74, 97, 112} | ||||
| var _InstrumentKind_index = [...]uint8{0, 23, 30, 43, 52, 69, 92, 107, 112} | ||||
|  | ||||
| func (i InstrumentKind) String() string { | ||||
| 	if i >= InstrumentKind(len(_InstrumentKind_index)-1) { | ||||
|   | ||||
| @@ -145,14 +145,14 @@ func testCreateAggregators[N int64 | float64](t *testing.T) { | ||||
| 	) | ||||
|  | ||||
| 	instruments := []Instrument{ | ||||
| 		{Name: "foo", Kind: InstrumentKind(0)}, // Unknown kind | ||||
| 		{Name: "foo", Kind: InstrumentKindCounter}, | ||||
| 		{Name: "foo", Kind: InstrumentKindUpDownCounter}, | ||||
| 		{Name: "foo", Kind: InstrumentKindHistogram}, | ||||
| 		{Name: "foo", Kind: InstrumentKindGauge}, | ||||
| 		{Name: "foo", Kind: InstrumentKindObservableCounter}, | ||||
| 		{Name: "foo", Kind: InstrumentKindObservableUpDownCounter}, | ||||
| 		{Name: "foo", Kind: InstrumentKindObservableGauge}, | ||||
| 		InstrumentKind(0):                     {Name: "foo", Kind: InstrumentKind(0)}, // Unknown kind | ||||
| 		InstrumentKindCounter:                 {Name: "foo", Kind: InstrumentKindCounter}, | ||||
| 		InstrumentKindUpDownCounter:           {Name: "foo", Kind: InstrumentKindUpDownCounter}, | ||||
| 		InstrumentKindHistogram:               {Name: "foo", Kind: InstrumentKindHistogram}, | ||||
| 		InstrumentKindGauge:                   {Name: "foo", Kind: InstrumentKindGauge}, | ||||
| 		InstrumentKindObservableCounter:       {Name: "foo", Kind: InstrumentKindObservableCounter}, | ||||
| 		InstrumentKindObservableUpDownCounter: {Name: "foo", Kind: InstrumentKindObservableUpDownCounter}, | ||||
| 		InstrumentKindObservableGauge:         {Name: "foo", Kind: InstrumentKindObservableGauge}, | ||||
| 	} | ||||
|  | ||||
| 	testcases := []struct { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user