Skip to content

Commit

Permalink
fix oc conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
jrcamp committed Mar 25, 2021
1 parent 0e48800 commit 7a1e77a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion translator/internaldata/oc_to_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

occommon "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1"
ocresource "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1"
"go.opencensus.io/resource/resourcekeys"

"go.opentelemetry.io/collector/consumer/pdata"
"go.opentelemetry.io/collector/translator/conventions"
Expand Down Expand Up @@ -122,7 +123,12 @@ func ocNodeResourceToInternal(ocNode *occommon.Node, ocResource *ocresource.Reso
if ocResource != nil {
// Copy resource Labels.
for k, v := range ocResource.Labels {
attrs.InsertString(k, v)
switch k {
case resourcekeys.CloudKeyZone:
attrs.InsertString(conventions.AttributeCloudAvailabilityZone, v)
default:
attrs.InsertString(k, v)
}
}
// Add special fields.
if ocResource.Type != "" {
Expand Down
2 changes: 2 additions & 0 deletions translator/internaldata/resource_to_oc.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ func internalResourceToOC(resource pdata.Resource) (*occommon.Node, *ocresource.
val := tracetranslator.AttributeValueToString(v, false)

switch k {
case conventions.AttributeCloudAvailabilityZone:
labels[resourcekeys.CloudKeyZone] = val
case conventions.OCAttributeResourceType:
ocResource.Type = val
case conventions.AttributeServiceName:
Expand Down

0 comments on commit 7a1e77a

Please sign in to comment.