Skip to content

Commit

Permalink
Update OTLP exporter with latest proto
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Yahn committed Mar 13, 2020
1 parent 6ada85a commit 4af0f53
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 26 deletions.
5 changes: 2 additions & 3 deletions exporters/otlp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ module go.opentelemetry.io/otel/exporters/otlp
replace go.opentelemetry.io/otel => ../..

require (
github.com/golang/protobuf v1.3.2
github.com/golang/protobuf v1.3.4
github.com/google/go-cmp v0.4.0
github.com/open-telemetry/opentelemetry-proto v0.0.0-20200308012146-674ae1c8703f
github.com/open-telemetry/opentelemetry-proto v0.0.0-20200313210948-2e3afbfffa38
github.com/stretchr/testify v1.4.0
go.opentelemetry.io/otel v0.2.3
golang.org/x/net v0.0.0-20190628185345-da137c7871d7 // indirect
golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7 // indirect
golang.org/x/text v0.3.2 // indirect
google.golang.org/grpc v1.27.1
)
Expand Down
8 changes: 4 additions & 4 deletions exporters/otlp/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.4 h1:87PNWwrRvUSnqS4dlcBU/ftvOIBep4sYuBLlh6rX2wk=
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
Expand All @@ -30,8 +32,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/open-telemetry/opentelemetry-proto v0.0.0-20200308012146-674ae1c8703f h1:o21WlujGsrjoN3+n99AflASF/K0S6+SOLOj2O9nNplc=
github.com/open-telemetry/opentelemetry-proto v0.0.0-20200308012146-674ae1c8703f/go.mod h1:PMR5GI0F7BSpio+rBGFxNm6SLzg3FypDTcFuQZnO+F8=
github.com/open-telemetry/opentelemetry-proto v0.0.0-20200313210948-2e3afbfffa38 h1:oZ81PzQp61MRZ7acgKZIbJlyzcCSUSQGvK+d8mgZuf0=
github.com/open-telemetry/opentelemetry-proto v0.0.0-20200313210948-2e3afbfffa38/go.mod h1:PMR5GI0F7BSpio+rBGFxNm6SLzg3FypDTcFuQZnO+F8=
github.com/opentracing/opentracing-go v1.1.1-0.20190913142402-a7454ce5950e/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down Expand Up @@ -60,8 +62,6 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7 h1:LepdCS8Gf/MVejFIt8lsiexZATdoGVyp5bcyS+rYoUI=
golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
Expand Down
6 changes: 3 additions & 3 deletions exporters/otlp/internal/transform/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ func sum(desc *metricsdk.Descriptor, labels metricsdk.Labels, a aggregator.Sum)
switch n := desc.NumberKind(); n {
case core.Int64NumberKind, core.Uint64NumberKind:
m.MetricDescriptor.Type = metricpb.MetricDescriptor_COUNTER_INT64
m.Int64Datapoints = []*metricpb.Int64DataPoint{
m.Int64DataPoints = []*metricpb.Int64DataPoint{
{Value: sum.CoerceToInt64(n)},
}
case core.Float64NumberKind:
m.MetricDescriptor.Type = metricpb.MetricDescriptor_COUNTER_DOUBLE
m.DoubleDatapoints = []*metricpb.DoubleDataPoint{
m.DoubleDataPoints = []*metricpb.DoubleDataPoint{
{Value: sum.CoerceToFloat64(n)},
}
}
Expand Down Expand Up @@ -111,7 +111,7 @@ func minMaxSumCount(desc *metricsdk.Descriptor, labels metricsdk.Labels, a aggre
Type: metricpb.MetricDescriptor_SUMMARY,
Labels: stringKeyValues(labels.Ordered()),
},
SummaryDatapoints: []*metricpb.SummaryDataPoint{
SummaryDataPoints: []*metricpb.SummaryDataPoint{
{
Count: uint64(count),
Sum: sum.CoerceToFloat64(numKind),
Expand Down
24 changes: 12 additions & 12 deletions exporters/otlp/internal/transform/metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ func TestMinMaxSumCountDatapoints(t *testing.T) {
}
m, err := minMaxSumCount(desc, labels, mmsc)
if assert.NoError(t, err) {
assert.Equal(t, []*metricpb.Int64DataPoint(nil), m.Int64Datapoints)
assert.Equal(t, []*metricpb.DoubleDataPoint(nil), m.DoubleDatapoints)
assert.Equal(t, []*metricpb.HistogramDataPoint(nil), m.HistogramDatapoints)
assert.Equal(t, expected, m.SummaryDatapoints)
assert.Equal(t, []*metricpb.Int64DataPoint(nil), m.Int64DataPoints)
assert.Equal(t, []*metricpb.DoubleDataPoint(nil), m.DoubleDataPoints)
assert.Equal(t, []*metricpb.HistogramDataPoint(nil), m.HistogramDataPoints)
assert.Equal(t, expected, m.SummaryDataPoints)
}
}

Expand Down Expand Up @@ -257,10 +257,10 @@ func TestSumInt64Datapoints(t *testing.T) {
assert.NoError(t, s.Update(context.Background(), core.Number(1), desc))
s.Checkpoint(context.Background(), desc)
if m, err := sum(desc, labels, s); assert.NoError(t, err) {
assert.Equal(t, []*metricpb.Int64DataPoint{{Value: 1}}, m.Int64Datapoints)
assert.Equal(t, []*metricpb.DoubleDataPoint(nil), m.DoubleDatapoints)
assert.Equal(t, []*metricpb.HistogramDataPoint(nil), m.HistogramDatapoints)
assert.Equal(t, []*metricpb.SummaryDataPoint(nil), m.SummaryDatapoints)
assert.Equal(t, []*metricpb.Int64DataPoint{{Value: 1}}, m.Int64DataPoints)
assert.Equal(t, []*metricpb.DoubleDataPoint(nil), m.DoubleDataPoints)
assert.Equal(t, []*metricpb.HistogramDataPoint(nil), m.HistogramDataPoints)
assert.Equal(t, []*metricpb.SummaryDataPoint(nil), m.SummaryDataPoints)
}
}

Expand All @@ -271,9 +271,9 @@ func TestSumFloat64Datapoints(t *testing.T) {
assert.NoError(t, s.Update(context.Background(), core.NewFloat64Number(1), desc))
s.Checkpoint(context.Background(), desc)
if m, err := sum(desc, labels, s); assert.NoError(t, err) {
assert.Equal(t, []*metricpb.Int64DataPoint(nil), m.Int64Datapoints)
assert.Equal(t, []*metricpb.DoubleDataPoint{{Value: 1}}, m.DoubleDatapoints)
assert.Equal(t, []*metricpb.HistogramDataPoint(nil), m.HistogramDatapoints)
assert.Equal(t, []*metricpb.SummaryDataPoint(nil), m.SummaryDatapoints)
assert.Equal(t, []*metricpb.Int64DataPoint(nil), m.Int64DataPoints)
assert.Equal(t, []*metricpb.DoubleDataPoint{{Value: 1}}, m.DoubleDataPoints)
assert.Equal(t, []*metricpb.HistogramDataPoint(nil), m.HistogramDataPoints)
assert.Equal(t, []*metricpb.SummaryDataPoint(nil), m.SummaryDataPoints)
}
}
8 changes: 4 additions & 4 deletions exporters/otlp/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,21 +232,21 @@ func newExporterEndToEndTest(t *testing.T, additionalOpts []otlp.ExporterOption)
switch data.nKind {
case core.Int64NumberKind:
assert.Equal(t, metricpb.MetricDescriptor_COUNTER_INT64.String(), desc.GetType().String())
if dp := m.GetInt64Datapoints(); assert.Len(t, dp, 1) {
if dp := m.GetInt64DataPoints(); assert.Len(t, dp, 1) {
assert.Equal(t, data.val, dp[0].Value, "invalid value for %q", desc.Name)
}
case core.Float64NumberKind:
assert.Equal(t, metricpb.MetricDescriptor_COUNTER_DOUBLE.String(), desc.GetType().String())
if dp := m.GetDoubleDatapoints(); assert.Len(t, dp, 1) {
if dp := m.GetDoubleDataPoints(); assert.Len(t, dp, 1) {
assert.Equal(t, float64(data.val), dp[0].Value, "invalid value for %q", desc.Name)
}
default:
assert.Failf(t, "invalid number kind", data.nKind.String())
}
case metricsdk.MeasureKind, metricsdk.ObserverKind:
assert.Equal(t, metricpb.MetricDescriptor_SUMMARY.String(), desc.GetType().String())
m.GetSummaryDatapoints()
if dp := m.GetSummaryDatapoints(); assert.Len(t, dp, 1) {
m.GetSummaryDataPoints()
if dp := m.GetSummaryDataPoints(); assert.Len(t, dp, 1) {
count := dp[0].Count
assert.Equal(t, uint64(1), count, "invalid count for %q", desc.Name)
assert.Equal(t, float64(data.val*int64(count)), dp[0].Sum, "invalid sum for %q (value %d)", desc.Name, data.val)
Expand Down

0 comments on commit 4af0f53

Please sign in to comment.