Skip to content

Commit

Permalink
Upgrade go.opentelemetry.io/proto to v0.15.0 (#2748)
Browse files Browse the repository at this point in the history
* Upgrade go.opentelemetry.io/proto to v0.15.0

* Fix otlpmetric exporter test

* Fix lint in otlpmetric

* Update otlptrace

* Clean new line breaks

* Fix comment in otlpmetric exporter_test.go

* Add changes to changelog
  • Loading branch information
MrAlias committed Mar 30, 2022
1 parent bbcdc75 commit 6287236
Show file tree
Hide file tree
Showing 22 changed files with 106 additions and 96 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,13 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

### Changed

- Upgrade `go.opentelemetry.io/proto/otlp` in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric` from `v0.12.1` to `v0.15.0`.
This replaces the use of the now deprecated `InstrumentationLibrary` and `InstrumentationLibraryMetrics` types and fields in the proto library with the equivalent `InstrumentationScope` and `ScopeMetrics`. (#2748)
- Upgrade `go.opentelemetry.io/proto/otlp` in `go.opentelemetry.io/otel/exporters/otlp/otlptrace` from `v0.12.1` to `v0.15.0`.
This replaces the use of the now deprecated `InstrumentationLibrary` and `InstrumentationLibrarySpans` types and fields in the proto library with the equivalent `InstrumentationScope` and `ScopeSpans`. (#2748)

### Removed

- Removed module the `go.opentelemetry.io/otel/sdk/export/metric`.
Expand Down
4 changes: 2 additions & 2 deletions example/otel-collector/go.sum
Expand Up @@ -160,8 +160,8 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.opentelemetry.io/proto/otlp v0.12.1 h1:kfx2sboxOGFvGJcH2C408CiVo2wVHC2av2XHNqj4vEg=
go.opentelemetry.io/proto/otlp v0.12.1/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
go.opentelemetry.io/proto/otlp v0.15.0 h1:h0bKrvdrT/9sBwEJ6iWUqT/N/xPcS66bL4u3isneJ6w=
go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA=
go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down
60 changes: 31 additions & 29 deletions exporters/otlp/otlpmetric/exporter_test.go
Expand Up @@ -191,7 +191,7 @@ func TestNoGroupingExport(t *testing.T) {
[]*metricpb.ResourceMetrics{
{
Resource: nil,
InstrumentationLibraryMetrics: []*metricpb.InstrumentationLibraryMetrics{
ScopeMetrics: []*metricpb.ScopeMetrics{
{
Metrics: []*metricpb.Metric{
{
Expand Down Expand Up @@ -233,10 +233,11 @@ func TestHistogramInt64MetricGroupingExport(t *testing.T) {
append(baseKeyValues, cpuKey.Int(1)),
testLibName,
)
sum := 11.0
expected := []*metricpb.ResourceMetrics{
{
Resource: nil,
InstrumentationLibraryMetrics: []*metricpb.InstrumentationLibraryMetrics{
ScopeMetrics: []*metricpb.ScopeMetrics{
{
Metrics: []*metricpb.Metric{
{
Expand All @@ -250,14 +251,14 @@ func TestHistogramInt64MetricGroupingExport(t *testing.T) {
StartTimeUnixNano: startTime(),
TimeUnixNano: pointTime(),
Count: 2,
Sum: 11,
Sum: &sum,
ExplicitBounds: testHistogramBoundaries,
BucketCounts: []uint64{1, 0, 0, 1},
},
{
Attributes: cpu1Labels,
Count: 2,
Sum: 11,
Sum: &sum,
ExplicitBounds: testHistogramBoundaries,
BucketCounts: []uint64{1, 0, 0, 1},
StartTimeUnixNano: startTime(),
Expand All @@ -283,10 +284,11 @@ func TestHistogramFloat64MetricGroupingExport(t *testing.T) {
append(baseKeyValues, cpuKey.Int(1)),
testLibName,
)
sum := 11.0
expected := []*metricpb.ResourceMetrics{
{
Resource: nil,
InstrumentationLibraryMetrics: []*metricpb.InstrumentationLibraryMetrics{
ScopeMetrics: []*metricpb.ScopeMetrics{
{
Metrics: []*metricpb.Metric{
{
Expand All @@ -300,14 +302,14 @@ func TestHistogramFloat64MetricGroupingExport(t *testing.T) {
StartTimeUnixNano: startTime(),
TimeUnixNano: pointTime(),
Count: 2,
Sum: 11.0,
Sum: &sum,
ExplicitBounds: testHistogramBoundaries,
BucketCounts: []uint64{1, 0, 0, 1},
},
{
Attributes: cpu1Labels,
Count: 2,
Sum: 11.0,
Sum: &sum,
ExplicitBounds: testHistogramBoundaries,
BucketCounts: []uint64{1, 0, 0, 1},
StartTimeUnixNano: startTime(),
Expand Down Expand Up @@ -341,7 +343,7 @@ func TestCountInt64MetricGroupingExport(t *testing.T) {
[]*metricpb.ResourceMetrics{
{
Resource: nil,
InstrumentationLibraryMetrics: []*metricpb.InstrumentationLibraryMetrics{
ScopeMetrics: []*metricpb.ScopeMetrics{
{
Metrics: []*metricpb.Metric{
{
Expand Down Expand Up @@ -391,7 +393,7 @@ func TestCountFloat64MetricGroupingExport(t *testing.T) {
[]*metricpb.ResourceMetrics{
{
Resource: nil,
InstrumentationLibraryMetrics: []*metricpb.InstrumentationLibraryMetrics{
ScopeMetrics: []*metricpb.ScopeMetrics{
{
Metrics: []*metricpb.Metric{
{
Expand Down Expand Up @@ -463,7 +465,7 @@ func TestResourceMetricGroupingExport(t *testing.T) {
[]*metricpb.ResourceMetrics{
{
Resource: testerAResourcePb,
InstrumentationLibraryMetrics: []*metricpb.InstrumentationLibraryMetrics{
ScopeMetrics: []*metricpb.ScopeMetrics{
{
Metrics: []*metricpb.Metric{
{
Expand Down Expand Up @@ -564,9 +566,9 @@ func TestResourceInstLibMetricGroupingExport(t *testing.T) {
[]*metricpb.ResourceMetrics{
{
Resource: testerAResourcePb,
InstrumentationLibraryMetrics: []*metricpb.InstrumentationLibraryMetrics{
ScopeMetrics: []*metricpb.ScopeMetrics{
{
InstrumentationLibrary: &commonpb.InstrumentationLibrary{
Scope: &commonpb.InstrumentationScope{
Name: "counting-lib",
Version: "v1",
},
Expand Down Expand Up @@ -603,7 +605,7 @@ func TestResourceInstLibMetricGroupingExport(t *testing.T) {
},
},
{
InstrumentationLibrary: &commonpb.InstrumentationLibrary{
Scope: &commonpb.InstrumentationScope{
Name: "counting-lib",
Version: "v2",
},
Expand All @@ -628,7 +630,7 @@ func TestResourceInstLibMetricGroupingExport(t *testing.T) {
},
},
{
InstrumentationLibrary: &commonpb.InstrumentationLibrary{
Scope: &commonpb.InstrumentationScope{
Name: "summing-lib",
},
SchemaUrl: "schurl",
Expand Down Expand Up @@ -693,7 +695,7 @@ func TestStatelessAggregationTemporality(t *testing.T) {
[]*metricpb.ResourceMetrics{
{
Resource: testerAResourcePb,
InstrumentationLibraryMetrics: []*metricpb.InstrumentationLibraryMetrics{
ScopeMetrics: []*metricpb.ScopeMetrics{
{
Metrics: []*metricpb.Metric{
{
Expand Down Expand Up @@ -780,41 +782,41 @@ func runMetricExportTests(t *testing.T, opts []otlpmetric.Option, res *resource.

// assert.ElementsMatch does not equate nested slices of different order,
// therefore this requires the top level slice to be broken down.
// Build a map of Resource/InstrumentationLibrary pairs to Metrics, from
// that validate the metric elements match for all expected pairs. Finally,
// make we saw all expected pairs.
keyFor := func(ilm *metricpb.InstrumentationLibraryMetrics) string {
return fmt.Sprintf("%s/%s/%s", ilm.GetInstrumentationLibrary().GetName(), ilm.GetInstrumentationLibrary().GetVersion(), ilm.GetSchemaUrl())
// Build a map of Resource/Scope pairs to Metrics, from that validate the
// metric elements match for all expected pairs. Finally, make we saw all
// expected pairs.
keyFor := func(sm *metricpb.ScopeMetrics) string {
return fmt.Sprintf("%s/%s/%s", sm.GetScope().GetName(), sm.GetScope().GetVersion(), sm.GetSchemaUrl())
}
got := map[string][]*metricpb.Metric{}
for _, rm := range driver.rm {
for _, ilm := range rm.InstrumentationLibraryMetrics {
k := keyFor(ilm)
got[k] = append(got[k], ilm.GetMetrics()...)
for _, sm := range rm.ScopeMetrics {
k := keyFor(sm)
got[k] = append(got[k], sm.GetMetrics()...)
}
}

seen := map[string]struct{}{}
for _, rm := range expected {
for _, ilm := range rm.InstrumentationLibraryMetrics {
k := keyFor(ilm)
for _, sm := range rm.ScopeMetrics {
k := keyFor(sm)
seen[k] = struct{}{}
g, ok := got[k]
if !ok {
t.Errorf("missing metrics for:\n\tInstrumentationLibrary: %q\n", k)
t.Errorf("missing metrics for:\n\tInstrumentationScope: %q\n", k)
continue
}
if !assert.Len(t, g, len(ilm.GetMetrics())) {
if !assert.Len(t, g, len(sm.GetMetrics())) {
continue
}
for i, expected := range ilm.GetMetrics() {
for i, expected := range sm.GetMetrics() {
assert.Equal(t, "", cmp.Diff(expected, g[i], protocmp.Transform()))
}
}
}
for k := range got {
if _, ok := seen[k]; !ok {
t.Errorf("did not expect metrics for:\n\tInstrumentationLibrary: %s\n", k)
t.Errorf("did not expect metrics for:\n\tInstrumentationScope: %s\n", k)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/otlpmetric/go.mod
Expand Up @@ -10,7 +10,7 @@ require (
go.opentelemetry.io/otel/metric v0.28.0
go.opentelemetry.io/otel/sdk v1.6.1
go.opentelemetry.io/otel/sdk/metric v0.28.0
go.opentelemetry.io/proto/otlp v0.12.1
go.opentelemetry.io/proto/otlp v0.15.0
google.golang.org/grpc v1.45.0
google.golang.org/protobuf v1.28.0
)
Expand Down
4 changes: 2 additions & 2 deletions exporters/otlp/otlpmetric/go.sum
Expand Up @@ -163,8 +163,8 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.opentelemetry.io/proto/otlp v0.12.1 h1:kfx2sboxOGFvGJcH2C408CiVo2wVHC2av2XHNqj4vEg=
go.opentelemetry.io/proto/otlp v0.12.1/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
go.opentelemetry.io/proto/otlp v0.15.0 h1:h0bKrvdrT/9sBwEJ6iWUqT/N/xPcS66bL4u3isneJ6w=
go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down
17 changes: 9 additions & 8 deletions exporters/otlp/otlpmetric/internal/metrictransform/metric.go
Expand Up @@ -72,7 +72,7 @@ func toNanos(t time.Time) uint64 {
// InstrumentationLibraryReader transforms all records contained in a checkpoint into
// batched OTLP ResourceMetrics.
func InstrumentationLibraryReader(ctx context.Context, temporalitySelector aggregation.TemporalitySelector, res *resource.Resource, ilmr export.InstrumentationLibraryReader, numWorkers uint) (*metricpb.ResourceMetrics, error) {
var ilms []*metricpb.InstrumentationLibraryMetrics
var sms []*metricpb.ScopeMetrics

err := ilmr.ForEach(func(lib instrumentation.Library, mr export.Reader) error {

Expand Down Expand Up @@ -107,24 +107,24 @@ func InstrumentationLibraryReader(ctx context.Context, temporalitySelector aggre
return nil
}

ilms = append(ilms, &metricpb.InstrumentationLibraryMetrics{
sms = append(sms, &metricpb.ScopeMetrics{
Metrics: ms,
SchemaUrl: lib.SchemaURL,
InstrumentationLibrary: &commonpb.InstrumentationLibrary{
Scope: &commonpb.InstrumentationScope{
Name: lib.Name,
Version: lib.Version,
},
})
return nil
})
if len(ilms) == 0 {
if len(sms) == 0 {
return nil, err
}

rms := &metricpb.ResourceMetrics{
Resource: Resource(res),
SchemaUrl: res.SchemaURL(),
InstrumentationLibraryMetrics: ilms,
Resource: Resource(res),
SchemaUrl: res.SchemaURL(),
ScopeMetrics: sms,
}

return rms, err
Expand Down Expand Up @@ -415,6 +415,7 @@ func histogramPoint(record export.Record, temporality aggregation.Temporality, a
return nil, err
}

sumFloat64 := sum.CoerceToFloat64(desc.NumberKind())
m := &metricpb.Metric{
Name: desc.Name(),
Description: desc.Description(),
Expand All @@ -424,7 +425,7 @@ func histogramPoint(record export.Record, temporality aggregation.Temporality, a
AggregationTemporality: sdkTemporalityToTemporality(temporality),
DataPoints: []*metricpb.HistogramDataPoint{
{
Sum: sum.CoerceToFloat64(desc.NumberKind()),
Sum: &sumFloat64,
Attributes: Iterator(labels.Iter()),
StartTimeUnixNano: toNanos(record.StartTime()),
TimeUnixNano: toNanos(record.EndTime()),
Expand Down
Expand Up @@ -41,8 +41,8 @@ func NewMetricsStorage() MetricsStorage {
func (s *MetricsStorage) AddMetrics(request *collectormetricpb.ExportMetricsServiceRequest) {
for _, rm := range request.GetResourceMetrics() {
// TODO (rghetia) handle multiple resource and library info.
if len(rm.InstrumentationLibraryMetrics) > 0 {
s.metrics = append(s.metrics, rm.InstrumentationLibraryMetrics[0].Metrics...)
if len(rm.ScopeMetrics) > 0 {
s.metrics = append(s.metrics, rm.ScopeMetrics[0].Metrics...)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/otlpmetric/otlpmetricgrpc/go.mod
Expand Up @@ -10,7 +10,7 @@ require (
go.opentelemetry.io/otel/metric v0.28.0
go.opentelemetry.io/otel/sdk v1.6.1
go.opentelemetry.io/otel/sdk/metric v0.28.0
go.opentelemetry.io/proto/otlp v0.12.1
go.opentelemetry.io/proto/otlp v0.15.0
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1
google.golang.org/grpc v1.45.0
google.golang.org/protobuf v1.28.0
Expand Down
4 changes: 2 additions & 2 deletions exporters/otlp/otlpmetric/otlpmetricgrpc/go.sum
Expand Up @@ -163,8 +163,8 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.opentelemetry.io/proto/otlp v0.12.1 h1:kfx2sboxOGFvGJcH2C408CiVo2wVHC2av2XHNqj4vEg=
go.opentelemetry.io/proto/otlp v0.12.1/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
go.opentelemetry.io/proto/otlp v0.15.0 h1:h0bKrvdrT/9sBwEJ6iWUqT/N/xPcS66bL4u3isneJ6w=
go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/otlpmetric/otlpmetrichttp/go.mod
Expand Up @@ -7,7 +7,7 @@ require (
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.6.1
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.28.0
go.opentelemetry.io/otel/sdk v1.6.1
go.opentelemetry.io/proto/otlp v0.12.1
go.opentelemetry.io/proto/otlp v0.15.0
google.golang.org/protobuf v1.28.0
)

Expand Down
4 changes: 2 additions & 2 deletions exporters/otlp/otlpmetric/otlpmetrichttp/go.sum
Expand Up @@ -163,8 +163,8 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.opentelemetry.io/proto/otlp v0.12.1 h1:kfx2sboxOGFvGJcH2C408CiVo2wVHC2av2XHNqj4vEg=
go.opentelemetry.io/proto/otlp v0.12.1/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
go.opentelemetry.io/proto/otlp v0.15.0 h1:h0bKrvdrT/9sBwEJ6iWUqT/N/xPcS66bL4u3isneJ6w=
go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/otlptrace/go.mod
Expand Up @@ -9,7 +9,7 @@ require (
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.6.1
go.opentelemetry.io/otel/sdk v1.6.1
go.opentelemetry.io/otel/trace v1.6.1
go.opentelemetry.io/proto/otlp v0.12.1
go.opentelemetry.io/proto/otlp v0.15.0
google.golang.org/grpc v1.45.0
google.golang.org/protobuf v1.28.0
)
Expand Down
4 changes: 2 additions & 2 deletions exporters/otlp/otlptrace/go.sum
Expand Up @@ -161,8 +161,8 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.opentelemetry.io/proto/otlp v0.12.1 h1:kfx2sboxOGFvGJcH2C408CiVo2wVHC2av2XHNqj4vEg=
go.opentelemetry.io/proto/otlp v0.12.1/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
go.opentelemetry.io/proto/otlp v0.15.0 h1:h0bKrvdrT/9sBwEJ6iWUqT/N/xPcS66bL4u3isneJ6w=
go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down
16 changes: 7 additions & 9 deletions exporters/otlp/otlptrace/internal/otlptracetest/collector.go
Expand Up @@ -50,20 +50,18 @@ func (s *SpansStorage) AddSpans(request *collectortracepb.ExportTraceServiceRequ
if existingRs, ok := s.rsm[rstr]; !ok {
s.rsm[rstr] = rs
// TODO (rghetia): Add support for library Info.
if len(rs.InstrumentationLibrarySpans) == 0 {
rs.InstrumentationLibrarySpans = []*tracepb.InstrumentationLibrarySpans{
if len(rs.ScopeSpans) == 0 {
rs.ScopeSpans = []*tracepb.ScopeSpans{
{
Spans: []*tracepb.Span{},
},
}
}
s.spanCount += len(rs.InstrumentationLibrarySpans[0].Spans)
s.spanCount += len(rs.ScopeSpans[0].Spans)
} else {
if len(rs.InstrumentationLibrarySpans) > 0 {
newSpans := rs.InstrumentationLibrarySpans[0].GetSpans()
existingRs.InstrumentationLibrarySpans[0].Spans =
append(existingRs.InstrumentationLibrarySpans[0].Spans,
newSpans...)
if len(rs.ScopeSpans) > 0 {
newSpans := rs.ScopeSpans[0].GetSpans()
existingRs.ScopeSpans[0].Spans = append(existingRs.ScopeSpans[0].Spans, newSpans...)
s.spanCount += len(newSpans)
}
}
Expand All @@ -74,7 +72,7 @@ func (s *SpansStorage) AddSpans(request *collectortracepb.ExportTraceServiceRequ
func (s *SpansStorage) GetSpans() []*tracepb.Span {
spans := make([]*tracepb.Span, 0, s.spanCount)
for _, rs := range s.rsm {
spans = append(spans, rs.InstrumentationLibrarySpans[0].Spans...)
spans = append(spans, rs.ScopeSpans[0].Spans...)
}
return spans
}
Expand Down

0 comments on commit 6287236

Please sign in to comment.