Skip to content

Commit da006af

Browse files
bogdandrutudashpole
authored andcommitted
Remove OpenCensus conventions, should not be used (open-telemetry#3113)
* Remove OpenCensus conventions, should not be used Signed-off-by: Bogdan Drutu <[email protected]> * Update changelog Signed-off-by: Bogdan Drutu <[email protected]>
1 parent aa0d3a1 commit da006af

File tree

14 files changed

+44
-34
lines changed

14 files changed

+44
-34
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
## 🛑 Breaking changes 🛑
66

7+
- Remove OpenCensus conventions, should not be used (#3113)
78
- Remove tracetranslator.TagHTTPStatusCode, use conventions.AttributeHTTPStatusCode (#3111)
89
- Remove OpenCensus status constants and transformation (#3110)
910
- Remove `tracetranslator.AttributeArrayToSlice`, not used in core or contrib (#3109)

translator/conventions/opencensus.go renamed to internal/occonventions/opencensus.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package conventions
15+
package occonventions
1616

1717
// OTLP attributes to map certain OpenCensus proto fields. These fields don't have
1818
// corresponding fields in OTLP, nor are defined in OTLP semantic conventions.
1919
const (
20-
OCAttributeProcessStartTime = "opencensus.starttime"
21-
OCAttributeExporterVersion = "opencensus.exporterversion"
22-
OCAttributeResourceType = "opencensus.resourcetype"
23-
OCAttributeSameProcessAsParentSpan = "opencensus.same_process_as_parent_span"
20+
AttributeProcessStartTime = "opencensus.starttime"
21+
AttributeExporterVersion = "opencensus.exporterversion"
22+
AttributeResourceType = "opencensus.resourcetype"
23+
AttributeSameProcessAsParentSpan = "opencensus.same_process_as_parent_span"
2424
)

translator/internaldata/metrics_to_oc_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"google.golang.org/protobuf/types/known/timestamppb"
2626

2727
"go.opentelemetry.io/collector/consumer/pdata"
28+
"go.opentelemetry.io/collector/internal/occonventions"
2829
"go.opentelemetry.io/collector/internal/testdata"
2930
"go.opentelemetry.io/collector/translator/conventions"
3031
)
@@ -34,10 +35,10 @@ func TestMetricsToOC(t *testing.T) {
3435
attrs := sampleMetricData.ResourceMetrics().At(0).Resource().Attributes()
3536
attrs.Upsert(conventions.AttributeHostName, pdata.NewAttributeValueString("host1"))
3637
attrs.Upsert(conventions.AttributeProcessID, pdata.NewAttributeValueInt(123))
37-
attrs.Upsert(conventions.OCAttributeProcessStartTime, pdata.NewAttributeValueString("2020-02-11T20:26:00Z"))
38+
attrs.Upsert(occonventions.AttributeProcessStartTime, pdata.NewAttributeValueString("2020-02-11T20:26:00Z"))
3839
attrs.Upsert(conventions.AttributeTelemetrySDKLanguage, pdata.NewAttributeValueString("cpp"))
3940
attrs.Upsert(conventions.AttributeTelemetrySDKVersion, pdata.NewAttributeValueString("v2.0.1"))
40-
attrs.Upsert(conventions.OCAttributeExporterVersion, pdata.NewAttributeValueString("v1.2.0"))
41+
attrs.Upsert(occonventions.AttributeExporterVersion, pdata.NewAttributeValueString("v1.2.0"))
4142

4243
tests := []struct {
4344
name string

translator/internaldata/oc_testdata_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"google.golang.org/protobuf/types/known/wrapperspb"
2525

2626
"go.opentelemetry.io/collector/consumer/pdata"
27+
"go.opentelemetry.io/collector/internal/occonventions"
2728
"go.opentelemetry.io/collector/internal/testdata"
2829
"go.opentelemetry.io/collector/translator/conventions"
2930
)
@@ -496,13 +497,13 @@ func generateOCTestMetricDoubleSummary() *ocmetrics.Metric {
496497
func generateResourceWithOcNodeAndResource() pdata.Resource {
497498
resource := pdata.NewResource()
498499
resource.Attributes().InitFromMap(map[string]pdata.AttributeValue{
499-
conventions.OCAttributeProcessStartTime: pdata.NewAttributeValueString("2020-02-11T20:26:00Z"),
500+
occonventions.AttributeProcessStartTime: pdata.NewAttributeValueString("2020-02-11T20:26:00Z"),
500501
conventions.AttributeHostName: pdata.NewAttributeValueString("host1"),
501502
conventions.AttributeProcessID: pdata.NewAttributeValueInt(123),
502503
conventions.AttributeTelemetrySDKVersion: pdata.NewAttributeValueString("v2.0.1"),
503-
conventions.OCAttributeExporterVersion: pdata.NewAttributeValueString("v1.2.0"),
504+
occonventions.AttributeExporterVersion: pdata.NewAttributeValueString("v1.2.0"),
504505
conventions.AttributeTelemetrySDKLanguage: pdata.NewAttributeValueString("cpp"),
505-
conventions.OCAttributeResourceType: pdata.NewAttributeValueString("good-resource"),
506+
occonventions.AttributeResourceType: pdata.NewAttributeValueString("good-resource"),
506507
"node-str-attr": pdata.NewAttributeValueString("node-str-attr-val"),
507508
"resource-str-attr": pdata.NewAttributeValueString("resource-str-attr-val"),
508509
"resource-int-attr": pdata.NewAttributeValueInt(123),

translator/internaldata/oc_to_resource.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"go.opencensus.io/resource/resourcekeys"
2323

2424
"go.opentelemetry.io/collector/consumer/pdata"
25+
"go.opentelemetry.io/collector/internal/occonventions"
2526
"go.opentelemetry.io/collector/translator/conventions"
2627
)
2728

@@ -97,7 +98,7 @@ func ocNodeResourceToInternal(ocNode *occommon.Node, ocResource *ocresource.Reso
9798
}
9899
if ocNode.Identifier != nil {
99100
if ocNode.Identifier.StartTimestamp != nil {
100-
attrs.UpsertString(conventions.OCAttributeProcessStartTime, ocNode.Identifier.StartTimestamp.AsTime().Format(time.RFC3339Nano))
101+
attrs.UpsertString(occonventions.AttributeProcessStartTime, ocNode.Identifier.StartTimestamp.AsTime().Format(time.RFC3339Nano))
101102
}
102103
if ocNode.Identifier.HostName != "" {
103104
attrs.UpsertString(conventions.AttributeHostName, ocNode.Identifier.HostName)
@@ -111,7 +112,7 @@ func ocNodeResourceToInternal(ocNode *occommon.Node, ocResource *ocresource.Reso
111112
attrs.UpsertString(conventions.AttributeTelemetrySDKVersion, ocNode.LibraryInfo.CoreLibraryVersion)
112113
}
113114
if ocNode.LibraryInfo.ExporterVersion != "" {
114-
attrs.UpsertString(conventions.OCAttributeExporterVersion, ocNode.LibraryInfo.ExporterVersion)
115+
attrs.UpsertString(occonventions.AttributeExporterVersion, ocNode.LibraryInfo.ExporterVersion)
115116
}
116117
if ocNode.LibraryInfo.Language != occommon.LibraryInfo_LANGUAGE_UNSPECIFIED {
117118
if str, ok := ocLangCodeToLangMap[ocNode.LibraryInfo.Language]; ok {
@@ -133,7 +134,7 @@ func ocNodeResourceToInternal(ocNode *occommon.Node, ocResource *ocresource.Reso
133134
}
134135
// Add special fields.
135136
if ocResource.Type != "" {
136-
attrs.UpsertString(conventions.OCAttributeResourceType, ocResource.Type)
137+
attrs.UpsertString(occonventions.AttributeResourceType, ocResource.Type)
137138
}
138139
}
139140
}

translator/internaldata/oc_to_resource_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"google.golang.org/protobuf/proto"
2626

2727
"go.opentelemetry.io/collector/consumer/pdata"
28-
"go.opentelemetry.io/collector/translator/conventions"
28+
"go.opentelemetry.io/collector/internal/occonventions"
2929
)
3030

3131
func TestOcNodeResourceToInternal(t *testing.T) {
@@ -55,7 +55,7 @@ func TestOcNodeResourceToInternal(t *testing.T) {
5555
}
5656
return true
5757
})
58-
ocResource.Labels[conventions.OCAttributeResourceType] = "this will be overridden 2"
58+
ocResource.Labels[occonventions.AttributeResourceType] = "this will be overridden 2"
5959

6060
// Convert again.
6161
resource = pdata.NewResource()

translator/internaldata/oc_to_traces.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"google.golang.org/protobuf/types/known/wrapperspb"
2525

2626
"go.opentelemetry.io/collector/consumer/pdata"
27+
"go.opentelemetry.io/collector/internal/occonventions"
2728
"go.opentelemetry.io/collector/translator/conventions"
2829
tracetranslator "go.opentelemetry.io/collector/translator/trace"
2930
)
@@ -378,5 +379,5 @@ func ocSameProcessAsParentSpanToInternal(spaps *wrapperspb.BoolValue, dest pdata
378379
if spaps == nil {
379380
return
380381
}
381-
dest.Attributes().UpsertBool(conventions.OCAttributeSameProcessAsParentSpan, spaps.Value)
382+
dest.Attributes().UpsertBool(occonventions.AttributeSameProcessAsParentSpan, spaps.Value)
382383
}

translator/internaldata/oc_to_traces_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import (
2828

2929
"go.opentelemetry.io/collector/consumer/pdata"
3030
otlptrace "go.opentelemetry.io/collector/internal/data/protogen/trace/v1"
31+
"go.opentelemetry.io/collector/internal/occonventions"
3132
"go.opentelemetry.io/collector/internal/testdata"
32-
"go.opentelemetry.io/collector/translator/conventions"
3333
)
3434

3535
func TestOcTraceStateToInternal(t *testing.T) {
@@ -397,14 +397,14 @@ func TestOcSameProcessAsParentSpanToInternal(t *testing.T) {
397397

398398
ocSameProcessAsParentSpanToInternal(wrapperspb.Bool(false), span)
399399
assert.Equal(t, 1, span.Attributes().Len())
400-
v, ok := span.Attributes().Get(conventions.OCAttributeSameProcessAsParentSpan)
400+
v, ok := span.Attributes().Get(occonventions.AttributeSameProcessAsParentSpan)
401401
assert.True(t, ok)
402402
assert.EqualValues(t, pdata.AttributeValueBOOL, v.Type())
403403
assert.False(t, v.BoolVal())
404404

405405
ocSameProcessAsParentSpanToInternal(wrapperspb.Bool(true), span)
406406
assert.Equal(t, 1, span.Attributes().Len())
407-
v, ok = span.Attributes().Get(conventions.OCAttributeSameProcessAsParentSpan)
407+
v, ok = span.Attributes().Get(occonventions.AttributeSameProcessAsParentSpan)
408408
assert.True(t, ok)
409409
assert.EqualValues(t, pdata.AttributeValueBOOL, v.Type())
410410
assert.True(t, v.BoolVal())

translator/internaldata/resource_to_oc.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"google.golang.org/protobuf/types/known/timestamppb"
2525

2626
"go.opentelemetry.io/collector/consumer/pdata"
27+
"go.opentelemetry.io/collector/internal/occonventions"
2728
"go.opentelemetry.io/collector/translator/conventions"
2829
tracetranslator "go.opentelemetry.io/collector/translator/trace"
2930
)
@@ -93,11 +94,11 @@ func internalResourceToOC(resource pdata.Resource) (*occommon.Node, *ocresource.
9394
switch k {
9495
case conventions.AttributeCloudAvailabilityZone:
9596
labels[resourcekeys.CloudKeyZone] = val
96-
case conventions.OCAttributeResourceType:
97+
case occonventions.AttributeResourceType:
9798
ocResource.Type = val
9899
case conventions.AttributeServiceName:
99100
getServiceInfo(ocNode).Name = val
100-
case conventions.OCAttributeProcessStartTime:
101+
case occonventions.AttributeProcessStartTime:
101102
t, err := time.Parse(time.RFC3339Nano, val)
102103
if err != nil {
103104
return true
@@ -114,7 +115,7 @@ func internalResourceToOC(resource pdata.Resource) (*occommon.Node, *ocresource.
114115
getProcessIdentifier(ocNode).Pid = uint32(pid)
115116
case conventions.AttributeTelemetrySDKVersion:
116117
getLibraryInfo(ocNode).CoreLibraryVersion = val
117-
case conventions.OCAttributeExporterVersion:
118+
case occonventions.AttributeExporterVersion:
118119
getLibraryInfo(ocNode).ExporterVersion = val
119120
case conventions.AttributeTelemetrySDKLanguage:
120121
if code, ok := langToOCLangCodeMap[val]; ok {

translator/internaldata/resource_to_oc_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
otlpcollectortrace "go.opentelemetry.io/collector/internal/data/protogen/collector/trace/v1"
3333
otlptrace "go.opentelemetry.io/collector/internal/data/protogen/trace/v1"
3434
"go.opentelemetry.io/collector/internal/goldendataset"
35+
"go.opentelemetry.io/collector/internal/occonventions"
3536
"go.opentelemetry.io/collector/translator/conventions"
3637
tracetranslator "go.opentelemetry.io/collector/translator/trace"
3738
)
@@ -112,7 +113,7 @@ func TestContainerResourceToOC(t *testing.T) {
112113
}
113114

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

118119
_, ocResource = internalResourceToOC(resource)
@@ -237,7 +238,7 @@ func TestResourceToOCAndBack(t *testing.T) {
237238
actual := pdata.NewResource()
238239
ocNodeResourceToInternal(ocNode, ocResource, actual)
239240
// Remove opencensus resource type from actual. This will be added during translation.
240-
actual.Attributes().Delete(conventions.OCAttributeResourceType)
241+
actual.Attributes().Delete(occonventions.AttributeResourceType)
241242
assert.Equal(t, expected.Attributes().Len(), actual.Attributes().Len())
242243
expected.Attributes().Range(func(k string, v pdata.AttributeValue) bool {
243244
a, ok := actual.Attributes().Get(k)

0 commit comments

Comments
 (0)