Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ tool (

require (
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.139.0
github.com/oxidecomputer/oxide.go v0.10.0
github.com/oxidecomputer/oxide.go v0.10.1-0.20260812160657-6f808ccc9ea4
github.com/stretchr/testify v1.11.1
go.opentelemetry.io/collector/component v1.45.0
go.opentelemetry.io/collector/component/componenttest v0.139.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT9
github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
github.com/oxidecomputer/oxide.go v0.10.0 h1:4eGzt3OrN2jJJpXdsNnyd26D+zYAIIF7A9wswx+f4LM=
github.com/oxidecomputer/oxide.go v0.10.0/go.mod h1:H8k5p7Eb5+jQGbWNmeiJcOQPUvR3ciwwBzWf7B24lNo=
github.com/oxidecomputer/oxide.go v0.10.1-0.20260812160657-6f808ccc9ea4 h1:Ufcd/8cC8PgrvU8VtpwEylC3LecxLCQdX05XWpijenk=
github.com/oxidecomputer/oxide.go v0.10.1-0.20260812160657-6f808ccc9ea4/go.mod h1:5LzOmh5FNkx0t8nXdC5Y4d5twM7beJx/YEfk/f/6rzs=
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
Expand Down
53 changes: 34 additions & 19 deletions receiver/oxidemetricsreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,9 @@ func addHistogram(
)
}
for pointIdx, distValue := range v.Values {
if distValue == nil {
continue
}
if len(distValue.Bins) == 0 {
continue
}
Expand Down Expand Up @@ -544,6 +547,9 @@ func addHistogram(
)
}
for idx, distValue := range v.Values {
if distValue == nil {
continue
}
if len(distValue.Bins) == 0 {
continue
}
Expand Down Expand Up @@ -591,12 +597,17 @@ func addPoint(
)
}
for idx, intValue := range v.Values {
dp := dataPoints.AppendEmpty()
dp.SetTimestamp(pcommon.NewTimestampFromTime(timestamps[idx]))
if hasStartTimes {
dp.SetStartTimestamp(pcommon.NewTimestampFromTime(startTimes[idx]))
// OxQL can emit null values for metrics queries. We don't have an obvious way to
// represent these values in OTLP, and don't want to replace missing values with zero
// values, so simply omit the datapoint entirely in this case.
if intValue != nil {
dp := dataPoints.AppendEmpty()
dp.SetTimestamp(pcommon.NewTimestampFromTime(timestamps[idx]))
if hasStartTimes {
dp.SetStartTimestamp(pcommon.NewTimestampFromTime(startTimes[idx]))
}
dp.SetIntValue(int64(*intValue))
}
dp.SetIntValue(int64(intValue))
}
case *oxide.ValueArrayDouble:
if len(timestamps) != len(v.Values) {
Expand All @@ -607,12 +618,14 @@ func addPoint(
)
}
for idx, floatValue := range v.Values {
dp := dataPoints.AppendEmpty()
dp.SetTimestamp(pcommon.NewTimestampFromTime(timestamps[idx]))
if hasStartTimes {
dp.SetStartTimestamp(pcommon.NewTimestampFromTime(startTimes[idx]))
if floatValue != nil {
dp := dataPoints.AppendEmpty()
dp.SetTimestamp(pcommon.NewTimestampFromTime(timestamps[idx]))
if hasStartTimes {
dp.SetStartTimestamp(pcommon.NewTimestampFromTime(startTimes[idx]))
}
dp.SetDoubleValue(*floatValue)
}
dp.SetDoubleValue(floatValue)
}
case *oxide.ValueArrayBoolean:
if len(timestamps) != len(v.Values) {
Expand All @@ -623,16 +636,18 @@ func addPoint(
)
}
for idx, boolValue := range v.Values {
dp := dataPoints.AppendEmpty()
dp.SetTimestamp(pcommon.NewTimestampFromTime(timestamps[idx]))
if hasStartTimes {
dp.SetStartTimestamp(pcommon.NewTimestampFromTime(startTimes[idx]))
}
intValue := 0
if boolValue {
intValue = 1
if boolValue != nil {
dp := dataPoints.AppendEmpty()
dp.SetTimestamp(pcommon.NewTimestampFromTime(timestamps[idx]))
if hasStartTimes {
dp.SetStartTimestamp(pcommon.NewTimestampFromTime(startTimes[idx]))
}
intValue := 0
if *boolValue {
intValue = 1
}
dp.SetIntValue(int64(intValue))
}
dp.SetIntValue(int64(intValue))
}
default:
return fmt.Errorf("got unexpected metric value type %T", metricValue.Values.Value)
Expand Down
28 changes: 16 additions & 12 deletions receiver/oxidemetricsreceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func TestAddPoint(t *testing.T) {
Values: []oxide.Values{
{
Values: oxide.ValueArray{
Value: &oxide.ValueArrayInteger{Values: []int{42}},
Value: &oxide.ValueArrayInteger{Values: []*int{oxide.NewPointer(42)}},
},
},
},
Expand All @@ -184,7 +184,7 @@ func TestAddPoint(t *testing.T) {
Values: []oxide.Values{
{
Values: oxide.ValueArray{
Value: &oxide.ValueArrayInteger{Values: []int{42}},
Value: &oxide.ValueArrayInteger{Values: []*int{oxide.NewPointer(42)}},
},
},
},
Expand All @@ -210,7 +210,7 @@ func TestAddPoint(t *testing.T) {
Values: []oxide.Values{
{
Values: oxide.ValueArray{
Value: &oxide.ValueArrayDouble{Values: []float64{42.5}},
Value: &oxide.ValueArrayDouble{Values: []*float64{oxide.NewPointer(42.5)}},
},
},
},
Expand All @@ -236,7 +236,7 @@ func TestAddPoint(t *testing.T) {
Values: []oxide.Values{
{
Values: oxide.ValueArray{
Value: &oxide.ValueArrayBoolean{Values: []bool{true}},
Value: &oxide.ValueArrayBoolean{Values: []*bool{oxide.NewPointer(true)}},
},
},
},
Expand All @@ -262,7 +262,7 @@ func TestAddPoint(t *testing.T) {
Values: []oxide.Values{
{
Values: oxide.ValueArray{
Value: &oxide.ValueArrayString{Values: []string{"not a number"}},
Value: &oxide.ValueArrayString{Values: []*string{oxide.NewPointer("not a number")}},
},
},
},
Expand Down Expand Up @@ -382,20 +382,23 @@ func TestAddHistogram(t *testing.T) {
name: "int: success",
series: oxide.Timeseries{
Points: oxide.Points{
StartTimes: []time.Time{startTime},
Timestamps: []time.Time{now},
StartTimes: []time.Time{startTime, startTime},
Timestamps: []time.Time{now, now.Add(time.Second)},
Values: []oxide.Values{
{
Values: oxide.ValueArray{
Value: &oxide.ValueArrayIntegerDistribution{
Values: []oxide.Distributionint64{
Values: []*oxide.Distributionint64{
{
Bins: []int{0, 1, 2},
Counts: []uint64{1, 2, 3},
P50: 1.5,
P90: 1.9,
P99: 1.99,
},
// Note: Add a nil value to ensure that it's dropped as
// expected.
nil,
},
},
},
Expand All @@ -419,20 +422,21 @@ func TestAddHistogram(t *testing.T) {
name: "double: success",
series: oxide.Timeseries{
Points: oxide.Points{
StartTimes: []time.Time{startTime},
Timestamps: []time.Time{now},
StartTimes: []time.Time{startTime, startTime},
Timestamps: []time.Time{now, now.Add(time.Second)},
Values: []oxide.Values{
{
Values: oxide.ValueArray{
Value: &oxide.ValueArrayDoubleDistribution{
Values: []oxide.Distributiondouble{
Values: []*oxide.Distributiondouble{
{
Bins: []float64{0.0, 1.0, 2.0},
Counts: []uint64{1, 2, 3},
P50: 1.5,
P90: 1.9,
P99: 1.99,
},
nil,
},
},
},
Expand Down Expand Up @@ -461,7 +465,7 @@ func TestAddHistogram(t *testing.T) {
Values: []oxide.Values{
{
Values: oxide.ValueArray{
Value: &oxide.ValueArrayInteger{Values: []int{1, 2, 3}},
Value: &oxide.ValueArrayInteger{Values: []*int{oxide.NewPointer(1), oxide.NewPointer(2), oxide.NewPointer(3)}},
},
},
},
Expand Down
Loading