Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove OpenCensus conventions, should not be used #3113

Merged
merged 3 commits into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## 🛑 Breaking changes 🛑

- Remove OpenCensus conventions, should not be used (#3113)
- Remove tracetranslator.TagHTTPStatusCode, use conventions.AttributeHTTPStatusCode (#3111)
- Remove OpenCensus status constants and transformation (#3110)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package conventions
package occonventions

// OTLP attributes to map certain OpenCensus proto fields. These fields don't have
// corresponding fields in OTLP, nor are defined in OTLP semantic conventions.
const (
OCAttributeProcessStartTime = "opencensus.starttime"
OCAttributeExporterVersion = "opencensus.exporterversion"
OCAttributeResourceType = "opencensus.resourcetype"
OCAttributeSameProcessAsParentSpan = "opencensus.same_process_as_parent_span"
AttributeProcessStartTime = "opencensus.starttime"
AttributeExporterVersion = "opencensus.exporterversion"
AttributeResourceType = "opencensus.resourcetype"
AttributeSameProcessAsParentSpan = "opencensus.same_process_as_parent_span"
)
5 changes: 3 additions & 2 deletions translator/internaldata/metrics_to_oc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"

"go.opentelemetry.io/collector/consumer/pdata"
"go.opentelemetry.io/collector/internal/occonventions"
"go.opentelemetry.io/collector/internal/testdata"
"go.opentelemetry.io/collector/translator/conventions"
)
Expand All @@ -34,10 +35,10 @@ func TestMetricsToOC(t *testing.T) {
attrs := sampleMetricData.ResourceMetrics().At(0).Resource().Attributes()
attrs.Upsert(conventions.AttributeHostName, pdata.NewAttributeValueString("host1"))
attrs.Upsert(conventions.AttributeProcessID, pdata.NewAttributeValueInt(123))
attrs.Upsert(conventions.OCAttributeProcessStartTime, pdata.NewAttributeValueString("2020-02-11T20:26:00Z"))
attrs.Upsert(occonventions.AttributeProcessStartTime, pdata.NewAttributeValueString("2020-02-11T20:26:00Z"))
attrs.Upsert(conventions.AttributeTelemetrySDKLanguage, pdata.NewAttributeValueString("cpp"))
attrs.Upsert(conventions.AttributeTelemetrySDKVersion, pdata.NewAttributeValueString("v2.0.1"))
attrs.Upsert(conventions.OCAttributeExporterVersion, pdata.NewAttributeValueString("v1.2.0"))
attrs.Upsert(occonventions.AttributeExporterVersion, pdata.NewAttributeValueString("v1.2.0"))

tests := []struct {
name string
Expand Down
7 changes: 4 additions & 3 deletions translator/internaldata/oc_testdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"google.golang.org/protobuf/types/known/wrapperspb"

"go.opentelemetry.io/collector/consumer/pdata"
"go.opentelemetry.io/collector/internal/occonventions"
"go.opentelemetry.io/collector/internal/testdata"
"go.opentelemetry.io/collector/translator/conventions"
)
Expand Down Expand Up @@ -496,13 +497,13 @@ func generateOCTestMetricDoubleSummary() *ocmetrics.Metric {
func generateResourceWithOcNodeAndResource() pdata.Resource {
resource := pdata.NewResource()
resource.Attributes().InitFromMap(map[string]pdata.AttributeValue{
conventions.OCAttributeProcessStartTime: pdata.NewAttributeValueString("2020-02-11T20:26:00Z"),
occonventions.AttributeProcessStartTime: pdata.NewAttributeValueString("2020-02-11T20:26:00Z"),
conventions.AttributeHostName: pdata.NewAttributeValueString("host1"),
conventions.AttributeProcessID: pdata.NewAttributeValueInt(123),
conventions.AttributeTelemetrySDKVersion: pdata.NewAttributeValueString("v2.0.1"),
conventions.OCAttributeExporterVersion: pdata.NewAttributeValueString("v1.2.0"),
occonventions.AttributeExporterVersion: pdata.NewAttributeValueString("v1.2.0"),
conventions.AttributeTelemetrySDKLanguage: pdata.NewAttributeValueString("cpp"),
conventions.OCAttributeResourceType: pdata.NewAttributeValueString("good-resource"),
occonventions.AttributeResourceType: pdata.NewAttributeValueString("good-resource"),
"node-str-attr": pdata.NewAttributeValueString("node-str-attr-val"),
"resource-str-attr": pdata.NewAttributeValueString("resource-str-attr-val"),
"resource-int-attr": pdata.NewAttributeValueInt(123),
Expand Down
7 changes: 4 additions & 3 deletions translator/internaldata/oc_to_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"go.opencensus.io/resource/resourcekeys"

"go.opentelemetry.io/collector/consumer/pdata"
"go.opentelemetry.io/collector/internal/occonventions"
"go.opentelemetry.io/collector/translator/conventions"
)

Expand Down Expand Up @@ -97,7 +98,7 @@ func ocNodeResourceToInternal(ocNode *occommon.Node, ocResource *ocresource.Reso
}
if ocNode.Identifier != nil {
if ocNode.Identifier.StartTimestamp != nil {
attrs.UpsertString(conventions.OCAttributeProcessStartTime, ocNode.Identifier.StartTimestamp.AsTime().Format(time.RFC3339Nano))
attrs.UpsertString(occonventions.AttributeProcessStartTime, ocNode.Identifier.StartTimestamp.AsTime().Format(time.RFC3339Nano))
}
if ocNode.Identifier.HostName != "" {
attrs.UpsertString(conventions.AttributeHostName, ocNode.Identifier.HostName)
Expand All @@ -111,7 +112,7 @@ func ocNodeResourceToInternal(ocNode *occommon.Node, ocResource *ocresource.Reso
attrs.UpsertString(conventions.AttributeTelemetrySDKVersion, ocNode.LibraryInfo.CoreLibraryVersion)
}
if ocNode.LibraryInfo.ExporterVersion != "" {
attrs.UpsertString(conventions.OCAttributeExporterVersion, ocNode.LibraryInfo.ExporterVersion)
attrs.UpsertString(occonventions.AttributeExporterVersion, ocNode.LibraryInfo.ExporterVersion)
}
if ocNode.LibraryInfo.Language != occommon.LibraryInfo_LANGUAGE_UNSPECIFIED {
if str, ok := ocLangCodeToLangMap[ocNode.LibraryInfo.Language]; ok {
Expand All @@ -133,7 +134,7 @@ func ocNodeResourceToInternal(ocNode *occommon.Node, ocResource *ocresource.Reso
}
// Add special fields.
if ocResource.Type != "" {
attrs.UpsertString(conventions.OCAttributeResourceType, ocResource.Type)
attrs.UpsertString(occonventions.AttributeResourceType, ocResource.Type)
}
}
}
4 changes: 2 additions & 2 deletions translator/internaldata/oc_to_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"google.golang.org/protobuf/proto"

"go.opentelemetry.io/collector/consumer/pdata"
"go.opentelemetry.io/collector/translator/conventions"
"go.opentelemetry.io/collector/internal/occonventions"
)

func TestOcNodeResourceToInternal(t *testing.T) {
Expand Down Expand Up @@ -55,7 +55,7 @@ func TestOcNodeResourceToInternal(t *testing.T) {
}
return true
})
ocResource.Labels[conventions.OCAttributeResourceType] = "this will be overridden 2"
ocResource.Labels[occonventions.AttributeResourceType] = "this will be overridden 2"

// Convert again.
resource = pdata.NewResource()
Expand Down
3 changes: 2 additions & 1 deletion translator/internaldata/oc_to_traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"google.golang.org/protobuf/types/known/wrapperspb"

"go.opentelemetry.io/collector/consumer/pdata"
"go.opentelemetry.io/collector/internal/occonventions"
"go.opentelemetry.io/collector/translator/conventions"
tracetranslator "go.opentelemetry.io/collector/translator/trace"
)
Expand Down Expand Up @@ -378,5 +379,5 @@ func ocSameProcessAsParentSpanToInternal(spaps *wrapperspb.BoolValue, dest pdata
if spaps == nil {
return
}
dest.Attributes().UpsertBool(conventions.OCAttributeSameProcessAsParentSpan, spaps.Value)
dest.Attributes().UpsertBool(occonventions.AttributeSameProcessAsParentSpan, spaps.Value)
}
6 changes: 3 additions & 3 deletions translator/internaldata/oc_to_traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (

"go.opentelemetry.io/collector/consumer/pdata"
otlptrace "go.opentelemetry.io/collector/internal/data/protogen/trace/v1"
"go.opentelemetry.io/collector/internal/occonventions"
"go.opentelemetry.io/collector/internal/testdata"
"go.opentelemetry.io/collector/translator/conventions"
)

func TestOcTraceStateToInternal(t *testing.T) {
Expand Down Expand Up @@ -397,14 +397,14 @@ func TestOcSameProcessAsParentSpanToInternal(t *testing.T) {

ocSameProcessAsParentSpanToInternal(wrapperspb.Bool(false), span)
assert.Equal(t, 1, span.Attributes().Len())
v, ok := span.Attributes().Get(conventions.OCAttributeSameProcessAsParentSpan)
v, ok := span.Attributes().Get(occonventions.AttributeSameProcessAsParentSpan)
assert.True(t, ok)
assert.EqualValues(t, pdata.AttributeValueBOOL, v.Type())
assert.False(t, v.BoolVal())

ocSameProcessAsParentSpanToInternal(wrapperspb.Bool(true), span)
assert.Equal(t, 1, span.Attributes().Len())
v, ok = span.Attributes().Get(conventions.OCAttributeSameProcessAsParentSpan)
v, ok = span.Attributes().Get(occonventions.AttributeSameProcessAsParentSpan)
assert.True(t, ok)
assert.EqualValues(t, pdata.AttributeValueBOOL, v.Type())
assert.True(t, v.BoolVal())
Expand Down
7 changes: 4 additions & 3 deletions translator/internaldata/resource_to_oc.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"

"go.opentelemetry.io/collector/consumer/pdata"
"go.opentelemetry.io/collector/internal/occonventions"
"go.opentelemetry.io/collector/translator/conventions"
tracetranslator "go.opentelemetry.io/collector/translator/trace"
)
Expand Down Expand Up @@ -93,11 +94,11 @@ func internalResourceToOC(resource pdata.Resource) (*occommon.Node, *ocresource.
switch k {
case conventions.AttributeCloudAvailabilityZone:
labels[resourcekeys.CloudKeyZone] = val
case conventions.OCAttributeResourceType:
case occonventions.AttributeResourceType:
ocResource.Type = val
case conventions.AttributeServiceName:
getServiceInfo(ocNode).Name = val
case conventions.OCAttributeProcessStartTime:
case occonventions.AttributeProcessStartTime:
t, err := time.Parse(time.RFC3339Nano, val)
if err != nil {
return true
Expand All @@ -114,7 +115,7 @@ func internalResourceToOC(resource pdata.Resource) (*occommon.Node, *ocresource.
getProcessIdentifier(ocNode).Pid = uint32(pid)
case conventions.AttributeTelemetrySDKVersion:
getLibraryInfo(ocNode).CoreLibraryVersion = val
case conventions.OCAttributeExporterVersion:
case occonventions.AttributeExporterVersion:
getLibraryInfo(ocNode).ExporterVersion = val
case conventions.AttributeTelemetrySDKLanguage:
if code, ok := langToOCLangCodeMap[val]; ok {
Expand Down
5 changes: 3 additions & 2 deletions translator/internaldata/resource_to_oc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
otlpcollectortrace "go.opentelemetry.io/collector/internal/data/protogen/collector/trace/v1"
otlptrace "go.opentelemetry.io/collector/internal/data/protogen/trace/v1"
"go.opentelemetry.io/collector/internal/goldendataset"
"go.opentelemetry.io/collector/internal/occonventions"
"go.opentelemetry.io/collector/translator/conventions"
tracetranslator "go.opentelemetry.io/collector/translator/trace"
)
Expand Down Expand Up @@ -112,7 +113,7 @@ func TestContainerResourceToOC(t *testing.T) {
}

// Also test that the explicit resource type is preserved if present
resource.Attributes().InsertString(conventions.OCAttributeResourceType, "other-type")
resource.Attributes().InsertString(occonventions.AttributeResourceType, "other-type")
want.Type = "other-type"

_, ocResource = internalResourceToOC(resource)
Expand Down Expand Up @@ -237,7 +238,7 @@ func TestResourceToOCAndBack(t *testing.T) {
actual := pdata.NewResource()
ocNodeResourceToInternal(ocNode, ocResource, actual)
// Remove opencensus resource type from actual. This will be added during translation.
actual.Attributes().Delete(conventions.OCAttributeResourceType)
actual.Attributes().Delete(occonventions.AttributeResourceType)
assert.Equal(t, expected.Attributes().Len(), actual.Attributes().Len())
expected.Attributes().Range(func(k string, v pdata.AttributeValue) bool {
a, ok := actual.Attributes().Get(k)
Expand Down
3 changes: 2 additions & 1 deletion translator/internaldata/traces_to_oc.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"google.golang.org/protobuf/types/known/wrapperspb"

"go.opentelemetry.io/collector/consumer/pdata"
"go.opentelemetry.io/collector/internal/occonventions"
"go.opentelemetry.io/collector/translator/conventions"
tracetranslator "go.opentelemetry.io/collector/translator/trace"
)
Expand Down Expand Up @@ -192,7 +193,7 @@ func stringAttributeValue(val string) *octrace.AttributeValue {
}

func attributesMapToOCSameProcessAsParentSpan(attr pdata.AttributeMap) *wrapperspb.BoolValue {
val, ok := attr.Get(conventions.OCAttributeSameProcessAsParentSpan)
val, ok := attr.Get(occonventions.AttributeSameProcessAsParentSpan)
if !ok || val.Type() != pdata.AttributeValueBOOL {
return nil
}
Expand Down
8 changes: 4 additions & 4 deletions translator/internaldata/traces_to_oc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (

"go.opentelemetry.io/collector/consumer/pdata"
"go.opentelemetry.io/collector/internal/goldendataset"
"go.opentelemetry.io/collector/internal/occonventions"
"go.opentelemetry.io/collector/internal/testdata"
"go.opentelemetry.io/collector/translator/conventions"
tracetranslator "go.opentelemetry.io/collector/translator/trace"
)

Expand Down Expand Up @@ -139,13 +139,13 @@ func TestAttributesMapTOOcSameProcessAsParentSpan(t *testing.T) {
attr := pdata.NewAttributeMap()
assert.Nil(t, attributesMapToOCSameProcessAsParentSpan(attr))

attr.UpsertBool(conventions.OCAttributeSameProcessAsParentSpan, true)
attr.UpsertBool(occonventions.AttributeSameProcessAsParentSpan, true)
assert.True(t, proto.Equal(wrapperspb.Bool(true), attributesMapToOCSameProcessAsParentSpan(attr)))

attr.UpsertBool(conventions.OCAttributeSameProcessAsParentSpan, false)
attr.UpsertBool(occonventions.AttributeSameProcessAsParentSpan, false)
assert.True(t, proto.Equal(wrapperspb.Bool(false), attributesMapToOCSameProcessAsParentSpan(attr)))

attr.UpdateInt(conventions.OCAttributeSameProcessAsParentSpan, 13)
attr.UpdateInt(occonventions.AttributeSameProcessAsParentSpan, 13)
assert.Nil(t, attributesMapToOCSameProcessAsParentSpan(attr))
}

Expand Down
5 changes: 3 additions & 2 deletions translator/trace/jaeger/jaegerproto_to_traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/jaegertracing/jaeger/thrift-gen/jaeger"

"go.opentelemetry.io/collector/consumer/pdata"
"go.opentelemetry.io/collector/internal/occonventions"
"go.opentelemetry.io/collector/translator/conventions"
tracetranslator "go.opentelemetry.io/collector/translator/trace"
)
Expand Down Expand Up @@ -132,9 +133,9 @@ func translateHostnameAttr(attrs pdata.AttributeMap) {
// translateHostnameAttr translates "jaeger.version" atttribute
func translateJaegerVersionAttr(attrs pdata.AttributeMap) {
jaegerVersion, jaegerVersionFound := attrs.Get("jaeger.version")
_, exporterVersionFound := attrs.Get(conventions.OCAttributeExporterVersion)
_, exporterVersionFound := attrs.Get(occonventions.AttributeExporterVersion)
if jaegerVersionFound && !exporterVersionFound {
attrs.InsertString(conventions.OCAttributeExporterVersion, "Jaeger-"+jaegerVersion.StringVal())
attrs.InsertString(occonventions.AttributeExporterVersion, "Jaeger-"+jaegerVersion.StringVal())
attrs.Delete("jaeger.version")
}
}
Expand Down
7 changes: 4 additions & 3 deletions translator/trace/zipkin/zipkinv2_to_traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"go.opentelemetry.io/collector/consumer/pdata"
"go.opentelemetry.io/collector/internal/data"
otlptrace "go.opentelemetry.io/collector/internal/data/protogen/trace/v1"
"go.opentelemetry.io/collector/internal/occonventions"
"go.opentelemetry.io/collector/translator/conventions"
tracetranslator "go.opentelemetry.io/collector/translator/trace"
)
Expand All @@ -40,10 +41,10 @@ var nonSpanAttributes = func() map[string]struct{} {
attrs[tracetranslator.TagServiceNameSource] = struct{}{}
attrs[conventions.InstrumentationLibraryName] = struct{}{}
attrs[conventions.InstrumentationLibraryVersion] = struct{}{}
attrs[conventions.OCAttributeProcessStartTime] = struct{}{}
attrs[conventions.OCAttributeExporterVersion] = struct{}{}
attrs[occonventions.AttributeProcessStartTime] = struct{}{}
attrs[occonventions.AttributeExporterVersion] = struct{}{}
attrs[conventions.AttributeProcessID] = struct{}{}
attrs[conventions.OCAttributeResourceType] = struct{}{}
attrs[occonventions.AttributeResourceType] = struct{}{}
return attrs
}()

Expand Down