Skip to content

Commit

Permalink
Update core dependency and adopt to recent changes
Browse files Browse the repository at this point in the history
Changes to adopt pdata API renames:

- pdata.AttributeValue(\w*) -> pdata.Value$1
- pdata.NewAttributeValue(\w*) -> pdata.NewValue$1
  • Loading branch information
dmitryax committed Mar 17, 2022
1 parent b6a9b30 commit 14dcf5a
Show file tree
Hide file tree
Showing 525 changed files with 3,788 additions and 3,781 deletions.
4 changes: 2 additions & 2 deletions cmd/configschema/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib v0.47.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry v0.47.0
github.com/stretchr/testify v1.7.0
go.opentelemetry.io/collector v0.47.0
go.opentelemetry.io/collector/model v0.47.0
go.opentelemetry.io/collector v0.47.1-0.20220316214317-e6ea17cf27a8
go.opentelemetry.io/collector/model v0.47.1-0.20220316214317-e6ea17cf27a8
go.uber.org/multierr v1.8.0
golang.org/x/mod v0.5.1
)
Expand Down
7 changes: 4 additions & 3 deletions cmd/configschema/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cmd/mdatagen/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ require (
github.com/go-playground/universal-translator v0.18.0
github.com/go-playground/validator/v10 v10.10.1
github.com/stretchr/testify v1.7.0
go.opentelemetry.io/collector v0.47.0
go.opentelemetry.io/collector/model v0.47.0
go.opentelemetry.io/collector v0.47.1-0.20220316214317-e6ea17cf27a8
go.opentelemetry.io/collector/model v0.47.1-0.20220316214317-e6ea17cf27a8
)

require (
Expand Down
8 changes: 4 additions & 4 deletions cmd/mdatagen/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/mdatagen/metrics_v2.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (m *metric{{ $name.Render }}) recordDataPoint(start pdata.Timestamp, ts pda
dp.Set{{ $metric.Data.MetricValueType }}Val(val)
{{- end }}
{{- range $metric.Attributes }}
dp.Attributes().Insert(A.{{ .Render }}, pdata.NewAttributeValueString({{ .RenderUnexported }}AttributeValue))
dp.Attributes().Insert(A.{{ .Render }}, pdata.NewValueString({{ .RenderUnexported }}AttributeValue))
{{- end }}
}

Expand Down
4 changes: 2 additions & 2 deletions exporter/alibabacloudlogserviceexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ require (
github.com/gogo/protobuf v1.3.2
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.47.0
github.com/stretchr/testify v1.7.0
go.opentelemetry.io/collector v0.47.0
go.opentelemetry.io/collector/model v0.47.0
go.opentelemetry.io/collector v0.47.1-0.20220316214317-e6ea17cf27a8
go.opentelemetry.io/collector/model v0.47.1-0.20220316214317-e6ea17cf27a8
go.uber.org/zap v1.21.0
)

Expand Down
8 changes: 4 additions & 4 deletions exporter/alibabacloudlogserviceexporter/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func resourceToLogContents(resource pdata.Resource) []*sls.LogContent {
}

fields := map[string]interface{}{}
attrs.Range(func(k string, v pdata.AttributeValue) bool {
attrs.Range(func(k string, v pdata.Value) bool {
if k == conventions.AttributeServiceName || k == conventions.AttributeHostName {
return true
}
Expand Down Expand Up @@ -124,7 +124,7 @@ func instrumentationLibraryToLogContents(instrumentationLibrary pdata.Instrument
func mapLogRecordToLogService(lr pdata.LogRecord,
resourceContents,
instrumentationLibraryContents []*sls.LogContent) *sls.Log {
if lr.Body().Type() == pdata.AttributeValueTypeEmpty {
if lr.Body().Type() == pdata.ValueTypeEmpty {
return nil
}
var slsLog sls.Log
Expand Down Expand Up @@ -153,7 +153,7 @@ func mapLogRecordToLogService(lr pdata.LogRecord,
})

fields := map[string]interface{}{}
lr.Attributes().Range(func(k string, v pdata.AttributeValue) bool {
lr.Attributes().Range(func(k string, v pdata.Value) bool {
fields[k] = v.AsString()
return true
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ import (
conventions "go.opentelemetry.io/collector/model/semconv/v1.6.1"
)

func getComplexAttributeValueMap() pdata.AttributeValue {
mapVal := pdata.NewAttributeValueMap()
func getComplexAttributeValueMap() pdata.Value {
mapVal := pdata.NewValueMap()
mapValReal := mapVal.MapVal()
mapValReal.InsertBool("result", true)
mapValReal.InsertString("status", "ok")
mapValReal.InsertDouble("value", 1.3)
mapValReal.InsertInt("code", 200)
mapValReal.InsertNull("null")
arrayVal := pdata.NewAttributeValueArray()
arrayVal := pdata.NewValueArray()
arrayVal.SliceVal().AppendEmpty().SetStringVal("array")
mapValReal.Insert("array", arrayVal)

subMapVal := pdata.NewAttributeValueMap()
subMapVal := pdata.NewValueMap()
subMapVal.MapVal().InsertString("data", "hello world")
mapValReal.Insert("map", subMapVal)

Expand Down Expand Up @@ -75,7 +75,7 @@ func createLogData(numberOfLogs int) pdata.Logs {
logRecord.Attributes().Insert("map-value", getComplexAttributeValueMap())
logRecord.Body().SetStringVal("log contents")
case 6:
arrayVal := pdata.NewAttributeValueArray()
arrayVal := pdata.NewValueArray()
arrayVal.SliceVal().AppendEmpty().SetStringVal("array")
logRecord.Attributes().Insert("array-value", arrayVal)
logRecord.Body().SetStringVal("log contents")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func min(l, r int) int {

func resourceToMetricLabels(labels *KeyValues, resource pdata.Resource) {
attrs := resource.Attributes()
attrs.Range(func(k string, v pdata.AttributeValue) bool {
attrs.Range(func(k string, v pdata.Value) bool {
labels.keyValues = append(labels.keyValues, KeyValue{
Key: k,
Value: v.AsString(),
Expand All @@ -172,7 +172,7 @@ func numberMetricsToLogs(name string, data pdata.NumberDataPointSlice, defaultLa
dataPoint := data.At(i)
attributeMap := dataPoint.Attributes()
labels := defaultLabels.Clone()
attributeMap.Range(func(k string, v pdata.AttributeValue) bool {
attributeMap.Range(func(k string, v pdata.Value) bool {
labels.Append(k, v.AsString())
return true
})
Expand Down Expand Up @@ -203,7 +203,7 @@ func doubleHistogramMetricsToLogs(name string, data pdata.HistogramDataPointSlic
dataPoint := data.At(i)
attributeMap := dataPoint.Attributes()
labels := defaultLabels.Clone()
attributeMap.Range(func(k string, v pdata.AttributeValue) bool {
attributeMap.Range(func(k string, v pdata.Value) bool {
labels.Append(k, v.AsString())
return true
})
Expand Down Expand Up @@ -251,7 +251,7 @@ func doubleSummaryMetricsToLogs(name string, data pdata.SummaryDataPointSlice, d
dataPoint := data.At(i)
attributeMap := dataPoint.Attributes()
labels := defaultLabels.Clone()
attributeMap.Range(func(k string, v pdata.AttributeValue) bool {
attributeMap.Range(func(k string, v pdata.Value) bool {
labels.Append(k, v.AsString())
return true
})
Expand Down
20 changes: 10 additions & 10 deletions exporter/awscloudwatchlogsexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,38 +216,38 @@ func attrsValue(attrs pdata.AttributeMap) map[string]interface{} {
return nil
}
out := make(map[string]interface{}, attrs.Len())
attrs.Range(func(k string, v pdata.AttributeValue) bool {
attrs.Range(func(k string, v pdata.Value) bool {
out[k] = attrValue(v)
return true
})
return out
}

func attrValue(value pdata.AttributeValue) interface{} {
func attrValue(value pdata.Value) interface{} {
switch value.Type() {
case pdata.AttributeValueTypeInt:
case pdata.ValueTypeInt:
return value.IntVal()
case pdata.AttributeValueTypeBool:
case pdata.ValueTypeBool:
return value.BoolVal()
case pdata.AttributeValueTypeDouble:
case pdata.ValueTypeDouble:
return value.DoubleVal()
case pdata.AttributeValueTypeString:
case pdata.ValueTypeString:
return value.StringVal()
case pdata.AttributeValueTypeMap:
case pdata.ValueTypeMap:
values := map[string]interface{}{}
value.MapVal().Range(func(k string, v pdata.AttributeValue) bool {
value.MapVal().Range(func(k string, v pdata.Value) bool {
values[k] = attrValue(v)
return true
})
return values
case pdata.AttributeValueTypeArray:
case pdata.ValueTypeArray:
arrayVal := value.SliceVal()
values := make([]interface{}, arrayVal.Len())
for i := 0; i < arrayVal.Len(); i++ {
values[i] = attrValue(arrayVal.At(i))
}
return values
case pdata.AttributeValueTypeEmpty:
case pdata.ValueTypeEmpty:
return nil
default:
return nil
Expand Down
38 changes: 19 additions & 19 deletions exporter/awscloudwatchlogsexporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,41 +149,41 @@ func testLogRecordWithoutTrace() pdata.LogRecord {
func TestAttrValue(t *testing.T) {
tests := []struct {
name string
builder func() pdata.AttributeValue
builder func() pdata.Value
want interface{}
}{
{
name: "null",
builder: func() pdata.AttributeValue {
return pdata.NewAttributeValueEmpty()
builder: func() pdata.Value {
return pdata.NewValueEmpty()
},
want: nil,
},
{
name: "bool",
builder: func() pdata.AttributeValue {
return pdata.NewAttributeValueBool(true)
builder: func() pdata.Value {
return pdata.NewValueBool(true)
},
want: true,
},
{
name: "int",
builder: func() pdata.AttributeValue {
return pdata.NewAttributeValueInt(5)
builder: func() pdata.Value {
return pdata.NewValueInt(5)
},
want: int64(5),
},
{
name: "double",
builder: func() pdata.AttributeValue {
return pdata.NewAttributeValueDouble(6.7)
builder: func() pdata.Value {
return pdata.NewValueDouble(6.7)
},
want: float64(6.7),
},
{
name: "map",
builder: func() pdata.AttributeValue {
mAttr := pdata.NewAttributeValueMap()
builder: func() pdata.Value {
mAttr := pdata.NewValueMap()
m := mAttr.MapVal()
m.InsertString("key1", "value1")
m.InsertNull("key2")
Expand All @@ -202,15 +202,15 @@ func TestAttrValue(t *testing.T) {
},
{
name: "array",
builder: func() pdata.AttributeValue {
arrAttr := pdata.NewAttributeValueArray()
builder: func() pdata.Value {
arrAttr := pdata.NewValueArray()
arr := arrAttr.SliceVal()
for _, av := range []pdata.AttributeValue{
pdata.NewAttributeValueDouble(1.2),
pdata.NewAttributeValueDouble(1.6),
pdata.NewAttributeValueBool(true),
pdata.NewAttributeValueString("hello"),
pdata.NewAttributeValueEmpty(),
for _, av := range []pdata.Value{
pdata.NewValueDouble(1.2),
pdata.NewValueDouble(1.6),
pdata.NewValueBool(true),
pdata.NewValueString("hello"),
pdata.NewValueEmpty(),
} {
tgt := arr.AppendEmpty()
av.CopyTo(tgt)
Expand Down
4 changes: 2 additions & 2 deletions exporter/awscloudwatchlogsexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil v0.47.0
github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/cwlogs v0.47.0
github.com/stretchr/testify v1.7.0
go.opentelemetry.io/collector v0.47.0
go.opentelemetry.io/collector/model v0.47.0
go.opentelemetry.io/collector v0.47.1-0.20220316214317-e6ea17cf27a8
go.opentelemetry.io/collector/model v0.47.1-0.20220316214317-e6ea17cf27a8
go.uber.org/zap v1.21.0
)

Expand Down
8 changes: 4 additions & 4 deletions exporter/awscloudwatchlogsexporter/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion exporter/awsemfexporter/datapoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (dps summaryDataPointSlice) At(i int) (dataPoint, bool) {
// and optionally adds in the OTel instrumentation library name
func createLabels(attributes pdata.AttributeMap, instrLibName string) map[string]string {
labels := make(map[string]string, attributes.Len()+1)
attributes.Range(func(k string, v pdata.AttributeValue) bool {
attributes.Range(func(k string, v pdata.Value) bool {
labels[k] = v.AsString()
return true
})
Expand Down
Loading

0 comments on commit 14dcf5a

Please sign in to comment.