1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-06-03 18:35:08 +02:00

Upgrade go.opentelemetry.io/proto to v0.15.0 (#2748)

* 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
This commit is contained in:
Tyler Yahn
2022-03-30 08:18:59 -07:00
committed by GitHub
parent bbcdc75ede
commit 628723630f
22 changed files with 106 additions and 96 deletions
+7
View File
@@ -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`.
+2 -2
View File
@@ -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=
+31 -29
View File
@@ -191,7 +191,7 @@ func TestNoGroupingExport(t *testing.T) {
[]*metricpb.ResourceMetrics{
{
Resource: nil,
InstrumentationLibraryMetrics: []*metricpb.InstrumentationLibraryMetrics{
ScopeMetrics: []*metricpb.ScopeMetrics{
{
Metrics: []*metricpb.Metric{
{
@@ -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{
{
@@ -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(),
@@ -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{
{
@@ -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(),
@@ -341,7 +343,7 @@ func TestCountInt64MetricGroupingExport(t *testing.T) {
[]*metricpb.ResourceMetrics{
{
Resource: nil,
InstrumentationLibraryMetrics: []*metricpb.InstrumentationLibraryMetrics{
ScopeMetrics: []*metricpb.ScopeMetrics{
{
Metrics: []*metricpb.Metric{
{
@@ -391,7 +393,7 @@ func TestCountFloat64MetricGroupingExport(t *testing.T) {
[]*metricpb.ResourceMetrics{
{
Resource: nil,
InstrumentationLibraryMetrics: []*metricpb.InstrumentationLibraryMetrics{
ScopeMetrics: []*metricpb.ScopeMetrics{
{
Metrics: []*metricpb.Metric{
{
@@ -463,7 +465,7 @@ func TestResourceMetricGroupingExport(t *testing.T) {
[]*metricpb.ResourceMetrics{
{
Resource: testerAResourcePb,
InstrumentationLibraryMetrics: []*metricpb.InstrumentationLibraryMetrics{
ScopeMetrics: []*metricpb.ScopeMetrics{
{
Metrics: []*metricpb.Metric{
{
@@ -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",
},
@@ -603,7 +605,7 @@ func TestResourceInstLibMetricGroupingExport(t *testing.T) {
},
},
{
InstrumentationLibrary: &commonpb.InstrumentationLibrary{
Scope: &commonpb.InstrumentationScope{
Name: "counting-lib",
Version: "v2",
},
@@ -628,7 +630,7 @@ func TestResourceInstLibMetricGroupingExport(t *testing.T) {
},
},
{
InstrumentationLibrary: &commonpb.InstrumentationLibrary{
Scope: &commonpb.InstrumentationScope{
Name: "summing-lib",
},
SchemaUrl: "schurl",
@@ -693,7 +695,7 @@ func TestStatelessAggregationTemporality(t *testing.T) {
[]*metricpb.ResourceMetrics{
{
Resource: testerAResourcePb,
InstrumentationLibraryMetrics: []*metricpb.InstrumentationLibraryMetrics{
ScopeMetrics: []*metricpb.ScopeMetrics{
{
Metrics: []*metricpb.Metric{
{
@@ -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)
}
}
}
+1 -1
View File
@@ -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
)
+2 -2
View File
@@ -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=
@@ -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 {
@@ -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
@@ -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(),
@@ -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()),
@@ -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...)
}
}
}
@@ -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
@@ -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=
@@ -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
)
@@ -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=
+1 -1
View File
@@ -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
)
+2 -2
View File
@@ -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=
@@ -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)
}
}
@@ -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
}
@@ -99,14 +99,14 @@ func RunEndToEndTest(ctx context.Context, t *testing.T, exp *otlptrace.Exporter,
// Now verify spans and attributes for each resource span.
for _, rs := range rss {
if len(rs.InstrumentationLibrarySpans) == 0 {
t.Fatalf("zero Instrumentation Library Spans")
if len(rs.ScopeSpans) == 0 {
t.Fatalf("zero ScopeSpans")
}
if got, want := len(rs.InstrumentationLibrarySpans[0].Spans), m; got != want {
if got, want := len(rs.ScopeSpans[0].Spans), m; got != want {
t.Fatalf("span counts: got %d, want %d", got, want)
}
attrMap := map[int64]bool{}
for _, s := range rs.InstrumentationLibrarySpans[0].Spans {
for _, s := range rs.ScopeSpans[0].Spans {
if gotName, want := s.Name, "AlwaysSample"; gotName != want {
t.Fatalf("span name: got %s, want %s", gotName, want)
}
@@ -19,11 +19,11 @@ import (
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
)
func InstrumentationLibrary(il instrumentation.Library) *commonpb.InstrumentationLibrary {
func InstrumentationScope(il instrumentation.Library) *commonpb.InstrumentationScope {
if il == (instrumentation.Library{}) {
return nil
}
return &commonpb.InstrumentationLibrary{
return &commonpb.InstrumentationScope{
Name: il.Name,
Version: il.Version,
}
@@ -32,11 +32,11 @@ func Spans(sdl []tracesdk.ReadOnlySpan) []*tracepb.ResourceSpans {
rsm := make(map[attribute.Distinct]*tracepb.ResourceSpans)
type ilsKey struct {
type key struct {
r attribute.Distinct
il instrumentation.Library
}
ilsm := make(map[ilsKey]*tracepb.InstrumentationLibrarySpans)
ssm := make(map[key]*tracepb.ScopeSpans)
var resources int
for _, sd := range sdl {
@@ -45,30 +45,30 @@ func Spans(sdl []tracesdk.ReadOnlySpan) []*tracepb.ResourceSpans {
}
rKey := sd.Resource().Equivalent()
iKey := ilsKey{
k := key{
r: rKey,
il: sd.InstrumentationLibrary(),
}
ils, iOk := ilsm[iKey]
scopeSpan, iOk := ssm[k]
if !iOk {
// Either the resource or instrumentation library were unknown.
ils = &tracepb.InstrumentationLibrarySpans{
InstrumentationLibrary: InstrumentationLibrary(sd.InstrumentationLibrary()),
Spans: []*tracepb.Span{},
SchemaUrl: sd.InstrumentationLibrary().SchemaURL,
scopeSpan = &tracepb.ScopeSpans{
Scope: InstrumentationScope(sd.InstrumentationLibrary()),
Spans: []*tracepb.Span{},
SchemaUrl: sd.InstrumentationLibrary().SchemaURL,
}
}
ils.Spans = append(ils.Spans, span(sd))
ilsm[iKey] = ils
scopeSpan.Spans = append(scopeSpan.Spans, span(sd))
ssm[k] = scopeSpan
rs, rOk := rsm[rKey]
if !rOk {
resources++
// The resource was unknown.
rs = &tracepb.ResourceSpans{
Resource: Resource(sd.Resource()),
InstrumentationLibrarySpans: []*tracepb.InstrumentationLibrarySpans{ils},
SchemaUrl: sd.Resource().SchemaURL(),
Resource: Resource(sd.Resource()),
ScopeSpans: []*tracepb.ScopeSpans{scopeSpan},
SchemaUrl: sd.Resource().SchemaURL(),
}
rsm[rKey] = rs
continue
@@ -78,9 +78,9 @@ func Spans(sdl []tracesdk.ReadOnlySpan) []*tracepb.ResourceSpans {
// library lookup was unknown because if so we need to add it to the
// ResourceSpans. Otherwise, the instrumentation library has already
// been seen and the append we did above will be included it in the
// InstrumentationLibrarySpans reference.
// ScopeSpans reference.
if !iOk {
rs.InstrumentationLibrarySpans = append(rs.InstrumentationLibrarySpans, ils)
rs.ScopeSpans = append(rs.ScopeSpans, scopeSpan)
}
}
@@ -298,12 +298,12 @@ func TestSpanData(t *testing.T) {
assert.Equal(t, got[0].GetResource(), Resource(spanData.Resource))
assert.Equal(t, got[0].SchemaUrl, spanData.Resource.SchemaURL())
ilSpans := got[0].GetInstrumentationLibrarySpans()
require.Len(t, ilSpans, 1)
assert.Equal(t, ilSpans[0].SchemaUrl, spanData.InstrumentationLibrary.SchemaURL)
assert.Equal(t, ilSpans[0].GetInstrumentationLibrary(), InstrumentationLibrary(spanData.InstrumentationLibrary))
require.Len(t, ilSpans[0].Spans, 1)
actualSpan := ilSpans[0].Spans[0]
scopeSpans := got[0].GetScopeSpans()
require.Len(t, scopeSpans, 1)
assert.Equal(t, scopeSpans[0].SchemaUrl, spanData.InstrumentationLibrary.SchemaURL)
assert.Equal(t, scopeSpans[0].GetScope(), InstrumentationScope(spanData.InstrumentationLibrary))
require.Len(t, scopeSpans[0].Spans, 1)
actualSpan := scopeSpans[0].Spans[0]
if diff := cmp.Diff(expectedSpan, actualSpan, cmp.Comparer(proto.Equal)); diff != "" {
t.Fatalf("transformed span differs %v\n", diff)
@@ -315,7 +315,9 @@ func TestRootSpanData(t *testing.T) {
sd := Spans(tracetest.SpanStubs{{}}.Snapshots())
require.Len(t, sd, 1)
rs := sd[0]
got := rs.GetInstrumentationLibrarySpans()[0].GetSpans()[0].GetParentSpanId()
scopeSpans := rs.GetScopeSpans()
require.Len(t, scopeSpans, 1)
got := scopeSpans[0].GetSpans()[0].GetParentSpanId()
// Empty means root span.
assert.Nil(t, got, "incorrect transform of root parent span ID")
@@ -8,7 +8,7 @@ require (
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.6.1
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.6.1
go.opentelemetry.io/otel/sdk v1.6.1
go.opentelemetry.io/proto/otlp v0.12.1
go.opentelemetry.io/proto/otlp v0.15.0
go.uber.org/goleak v1.1.12
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1
google.golang.org/grpc v1.45.0
@@ -162,8 +162,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=
@@ -9,7 +9,7 @@ require (
go.opentelemetry.io/otel/exporters/otlp/otlptrace 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/protobuf v1.28.0
)
@@ -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=