Skip to content

Commit

Permalink
removing deprecated call to InitFromMap (#6309)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Boten authored Nov 17, 2021
1 parent b8d10cc commit 4262443
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
15 changes: 5 additions & 10 deletions exporter/azuremonitorexporter/conventions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ func TestHTTPAttributeMapping(t *testing.T) {
conventions.AttributeHTTPClientIP: pdata.NewAttributeValueString(conventions.AttributeHTTPClientIP),
}

attributeMap := pdata.NewAttributeMap()
attributeMap.InitFromMap(httpAttributeValues)
attributeMap := pdata.NewAttributeMapFromMap(httpAttributeValues)

// Add all the network attributes
appendToAttributeMap(attributeMap, getNetworkAttributes())
Expand Down Expand Up @@ -81,8 +80,7 @@ func TestRPCPAttributeMapping(t *testing.T) {
conventions.AttributeRPCMethod: pdata.NewAttributeValueString(conventions.AttributeRPCMethod),
}

attributeMap := pdata.NewAttributeMap()
attributeMap.InitFromMap(rpcAttributeValues)
attributeMap := pdata.NewAttributeMapFromMap(rpcAttributeValues)

// Add all the network attributes
appendToAttributeMap(attributeMap, getNetworkAttributes())
Expand Down Expand Up @@ -112,8 +110,7 @@ func TestDatabaseAttributeMapping(t *testing.T) {
conventions.AttributeDBMongoDBCollection: pdata.NewAttributeValueString(conventions.AttributeDBMongoDBCollection),
}

attributeMap := pdata.NewAttributeMap()
attributeMap.InitFromMap(databaseAttributeValues)
attributeMap := pdata.NewAttributeMapFromMap(databaseAttributeValues)

// Add all the network attributes
appendToAttributeMap(attributeMap, getNetworkAttributes())
Expand Down Expand Up @@ -150,8 +147,7 @@ func TestMessagingAttributeMapping(t *testing.T) {
conventions.AttributeMessagingOperation: pdata.NewAttributeValueString(conventions.AttributeMessagingOperation),
}

attributeMap := pdata.NewAttributeMap()
attributeMap.InitFromMap(messagingAttributeValues)
attributeMap := pdata.NewAttributeMapFromMap(messagingAttributeValues)

// Add all the network attributes
appendToAttributeMap(attributeMap, getNetworkAttributes())
Expand Down Expand Up @@ -181,8 +177,7 @@ func TestAttributeMappingWithSomeBadValues(t *testing.T) {
conventions.AttributeNetPeerPort: pdata.NewAttributeValueString("xx"),
}

attributeMap := pdata.NewAttributeMap()
attributeMap.InitFromMap(values)
attributeMap := pdata.NewAttributeMapFromMap(values)

attrs := &NetworkAttributes{}
attributeMap.Range(attrs.MapAttribute)
Expand Down
14 changes: 9 additions & 5 deletions internal/coreinternal/testdata/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,25 @@ func initSpanLinkAttributes(dest pdata.AttributeMap) {
}

func initMetricAttachment(dest pdata.AttributeMap) {
dest.InitFromMap(map[string]pdata.AttributeValue{TestAttachmentKey: pdata.NewAttributeValueString(TestAttachmentValue)})
dest.UpsertString(TestAttachmentKey, TestAttachmentValue)
}

func initMetricAttributes1(dest pdata.AttributeMap) {
dest.InitFromMap(map[string]pdata.AttributeValue{TestLabelKey1: pdata.NewAttributeValueString(TestLabelValue1)})
dest.UpsertString(TestLabelKey1, TestLabelValue1)
}

func initMetricAttributes12(dest pdata.AttributeMap) {
dest.InitFromMap(map[string]pdata.AttributeValue{TestLabelKey1: pdata.NewAttributeValueString(TestLabelValue1), TestLabelKey2: pdata.NewAttributeValueString(TestLabelValue2)}).Sort()
dest.UpsertString(TestLabelKey1, TestLabelValue1)
dest.UpsertString(TestLabelKey2, TestLabelValue2)
dest.Sort()
}

func initMetricAttributes13(dest pdata.AttributeMap) {
dest.InitFromMap(map[string]pdata.AttributeValue{TestLabelKey1: pdata.NewAttributeValueString(TestLabelValue1), TestLabelKey3: pdata.NewAttributeValueString(TestLabelValue3)}).Sort()
dest.UpsertString(TestLabelKey1, TestLabelValue1)
dest.UpsertString(TestLabelKey3, TestLabelValue3)
dest.Sort()
}

func initMetricAttributes2(dest pdata.AttributeMap) {
dest.InitFromMap(map[string]pdata.AttributeValue{TestLabelKey2: pdata.NewAttributeValueString(TestLabelValue2)})
dest.UpsertString(TestLabelKey2, TestLabelValue2)
}

0 comments on commit 4262443

Please sign in to comment.