diff --git a/CHANGELOG.md b/CHANGELOG.md index 472811db587..ab0d59bf922 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/translator/conventions/opencensus.go b/internal/occonventions/opencensus.go similarity index 72% rename from translator/conventions/opencensus.go rename to internal/occonventions/opencensus.go index 244bb230060..2a1b8898db6 100644 --- a/translator/conventions/opencensus.go +++ b/internal/occonventions/opencensus.go @@ -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" ) diff --git a/translator/internaldata/metrics_to_oc_test.go b/translator/internaldata/metrics_to_oc_test.go index f14b5ee79f0..5e34e9fbfbe 100644 --- a/translator/internaldata/metrics_to_oc_test.go +++ b/translator/internaldata/metrics_to_oc_test.go @@ -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" ) @@ -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 diff --git a/translator/internaldata/oc_testdata_test.go b/translator/internaldata/oc_testdata_test.go index 447287bd43b..739d0f403fc 100644 --- a/translator/internaldata/oc_testdata_test.go +++ b/translator/internaldata/oc_testdata_test.go @@ -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" ) @@ -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), diff --git a/translator/internaldata/oc_to_resource.go b/translator/internaldata/oc_to_resource.go index 2e15a428d21..d98d508d784 100644 --- a/translator/internaldata/oc_to_resource.go +++ b/translator/internaldata/oc_to_resource.go @@ -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" ) @@ -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) @@ -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 { @@ -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) } } } diff --git a/translator/internaldata/oc_to_resource_test.go b/translator/internaldata/oc_to_resource_test.go index 29826d279fe..e4fcd948e10 100644 --- a/translator/internaldata/oc_to_resource_test.go +++ b/translator/internaldata/oc_to_resource_test.go @@ -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) { @@ -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() diff --git a/translator/internaldata/oc_to_traces.go b/translator/internaldata/oc_to_traces.go index 108a15e6bc2..2f6552d6b79 100644 --- a/translator/internaldata/oc_to_traces.go +++ b/translator/internaldata/oc_to_traces.go @@ -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" ) @@ -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) } diff --git a/translator/internaldata/oc_to_traces_test.go b/translator/internaldata/oc_to_traces_test.go index aefbd63b6a1..0c4c20e1ae2 100644 --- a/translator/internaldata/oc_to_traces_test.go +++ b/translator/internaldata/oc_to_traces_test.go @@ -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) { @@ -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()) diff --git a/translator/internaldata/resource_to_oc.go b/translator/internaldata/resource_to_oc.go index 20eb3e20ae6..418510596de 100644 --- a/translator/internaldata/resource_to_oc.go +++ b/translator/internaldata/resource_to_oc.go @@ -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" ) @@ -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 @@ -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 { diff --git a/translator/internaldata/resource_to_oc_test.go b/translator/internaldata/resource_to_oc_test.go index 639f24872db..2b0f67f91d8 100644 --- a/translator/internaldata/resource_to_oc_test.go +++ b/translator/internaldata/resource_to_oc_test.go @@ -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" ) @@ -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) @@ -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) diff --git a/translator/internaldata/traces_to_oc.go b/translator/internaldata/traces_to_oc.go index 2af50b921c6..ae1360d2ce0 100644 --- a/translator/internaldata/traces_to_oc.go +++ b/translator/internaldata/traces_to_oc.go @@ -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" ) @@ -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 } diff --git a/translator/internaldata/traces_to_oc_test.go b/translator/internaldata/traces_to_oc_test.go index 23ed5019d86..0a3f170f6c1 100644 --- a/translator/internaldata/traces_to_oc_test.go +++ b/translator/internaldata/traces_to_oc_test.go @@ -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" ) @@ -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)) } diff --git a/translator/trace/jaeger/jaegerproto_to_traces.go b/translator/trace/jaeger/jaegerproto_to_traces.go index c3342a6ee1c..8c8a5ca62e7 100644 --- a/translator/trace/jaeger/jaegerproto_to_traces.go +++ b/translator/trace/jaeger/jaegerproto_to_traces.go @@ -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" ) @@ -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") } } diff --git a/translator/trace/zipkin/zipkinv2_to_traces.go b/translator/trace/zipkin/zipkinv2_to_traces.go index ea5e7b90eaa..79bd78f40a0 100644 --- a/translator/trace/zipkin/zipkinv2_to_traces.go +++ b/translator/trace/zipkin/zipkinv2_to_traces.go @@ -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" ) @@ -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 }()