Skip to content

Commit e0e410e

Browse files
committed
Replace custom opencensus sematic conventions with otel semantic conventions
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
1 parent e6319ac commit e0e410e

File tree

10 files changed

+24
-24
lines changed

10 files changed

+24
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
## 🛑 Breaking changes 🛑
66

77
- Remove `consumerdata.TraceData` (#2551)
8+
- Remove custom OpenCensus sematic conventions that have equivalent in otel (#2552)
89

910
## v0.21.0 Beta
1011

translator/conventions/opencensus.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,9 @@ package conventions
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.
19-
// TODO: decide if any of these must be in OTLP semantic conventions.
2019
const (
2120
OCAttributeProcessStartTime = "opencensus.starttime"
22-
OCAttributeProcessID = "opencensus.pid"
2321
OCAttributeExporterVersion = "opencensus.exporterversion"
2422
OCAttributeResourceType = "opencensus.resourcetype"
2523
OCAttributeSameProcessAsParentSpan = "opencensus.same_process_as_parent_span"
26-
OCTimeEventMessageEventType = "opencensus.timeevent.messageevent.type"
27-
OCTimeEventMessageEventID = "opencensus.timeevent.messageevent.id"
28-
OCTimeEventMessageEventUSize = "opencensus.timeevent.messageevent.usize"
29-
OCTimeEventMessageEventCSize = "opencensus.timeevent.messageevent.csize"
3024
)

translator/internaldata/metrics_to_oc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestMetricsToOC(t *testing.T) {
3434
sampleMetricData := testdata.GeneratMetricsAllTypesWithSampleDatapoints()
3535
attrs := sampleMetricData.ResourceMetrics().At(0).Resource().Attributes()
3636
attrs.Upsert(conventions.AttributeHostName, pdata.NewAttributeValueString("host1"))
37-
attrs.Upsert(conventions.OCAttributeProcessID, pdata.NewAttributeValueInt(123))
37+
attrs.Upsert(conventions.AttributeProcessID, pdata.NewAttributeValueInt(123))
3838
attrs.Upsert(conventions.OCAttributeProcessStartTime, pdata.NewAttributeValueString("2020-02-11T20:26:00Z"))
3939
attrs.Upsert(conventions.AttributeTelemetrySDKLanguage, pdata.NewAttributeValueString("cpp"))
4040
attrs.Upsert(conventions.AttributeTelemetrySDKVersion, pdata.NewAttributeValueString("v2.0.1"))

translator/internaldata/oc_testdata_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ func generateResourceWithOcNodeAndResource() pdata.Resource {
499499
resource.Attributes().InitFromMap(map[string]pdata.AttributeValue{
500500
conventions.OCAttributeProcessStartTime: pdata.NewAttributeValueString("2020-02-11T20:26:00Z"),
501501
conventions.AttributeHostName: pdata.NewAttributeValueString("host1"),
502-
conventions.OCAttributeProcessID: pdata.NewAttributeValueInt(123),
502+
conventions.AttributeProcessID: pdata.NewAttributeValueInt(123),
503503
conventions.AttributeTelemetrySDKVersion: pdata.NewAttributeValueString("v2.0.1"),
504504
conventions.OCAttributeExporterVersion: pdata.NewAttributeValueString("v1.2.0"),
505505
conventions.AttributeTelemetrySDKLanguage: pdata.NewAttributeValueString("cpp"),

translator/internaldata/oc_to_resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func ocNodeResourceToInternal(ocNode *occommon.Node, ocResource *ocresource.Reso
101101
attrs.UpsertString(conventions.AttributeHostName, ocNode.Identifier.HostName)
102102
}
103103
if ocNode.Identifier.Pid != 0 {
104-
attrs.UpsertInt(conventions.OCAttributeProcessID, int64(ocNode.Identifier.Pid))
104+
attrs.UpsertInt(conventions.AttributeProcessID, int64(ocNode.Identifier.Pid))
105105
}
106106
}
107107
if ocNode.LibraryInfo != nil {

translator/internaldata/oc_to_traces.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,10 @@ func ocMessageEventToInternalAttrs(msgEvent *octrace.Span_TimeEvent_MessageEvent
380380
return
381381
}
382382

383-
dest.UpsertString(conventions.OCTimeEventMessageEventType, msgEvent.Type.String())
384-
dest.UpsertInt(conventions.OCTimeEventMessageEventID, int64(msgEvent.Id))
385-
dest.UpsertInt(conventions.OCTimeEventMessageEventUSize, int64(msgEvent.UncompressedSize))
386-
dest.UpsertInt(conventions.OCTimeEventMessageEventCSize, int64(msgEvent.CompressedSize))
383+
dest.UpsertString(conventions.AttributeMessageType, msgEvent.Type.String())
384+
dest.UpsertInt(conventions.AttributeMessageID, int64(msgEvent.Id))
385+
dest.UpsertInt(conventions.AttributeMessageUncompressedSize, int64(msgEvent.UncompressedSize))
386+
dest.UpsertInt(conventions.AttributeMessageCompressedSize, int64(msgEvent.CompressedSize))
387387
}
388388

389389
func ocSameProcessAsParentSpanToInternal(spaps *wrapperspb.BoolValue, dest pdata.Span) {

translator/internaldata/resource_to_oc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func internalResourceToOC(resource pdata.Resource) (*occommon.Node, *ocresource.
104104
getProcessIdentifier(ocNode).StartTimestamp = ts
105105
case conventions.AttributeHostName:
106106
getProcessIdentifier(ocNode).HostName = val
107-
case conventions.OCAttributeProcessID:
107+
case conventions.AttributeProcessID:
108108
pid, err := strconv.Atoi(val)
109109
if err != nil {
110110
pid = defaultProcessID

translator/internaldata/resource_to_oc_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,12 @@ func TestResourceToOCAndBack(t *testing.T) {
249249
assert.True(t, ok)
250250
switch v.Type() {
251251
case pdata.AttributeValueINT:
252-
assert.Equal(t, strconv.FormatInt(v.IntVal(), 10), a.StringVal())
252+
// conventions.AttributeProcessID is special because we preserve the type for this.
253+
if k == conventions.AttributeProcessID {
254+
assert.Equal(t, v.IntVal(), a.IntVal())
255+
} else {
256+
assert.Equal(t, strconv.FormatInt(v.IntVal(), 10), a.StringVal())
257+
}
253258
case pdata.AttributeValueMAP, pdata.AttributeValueARRAY:
254259
assert.Equal(t, a, a)
255260
default:

translator/internaldata/traces_to_oc.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,10 @@ func eventToOC(event pdata.SpanEvent) *octrace.Span_TimeEvent {
275275

276276
// Consider TimeEvent to be of MessageEvent type if all and only relevant attributes are set
277277
ocMessageEventAttrs := []string{
278-
conventions.OCTimeEventMessageEventType,
279-
conventions.OCTimeEventMessageEventID,
280-
conventions.OCTimeEventMessageEventUSize,
281-
conventions.OCTimeEventMessageEventCSize,
278+
conventions.AttributeMessageType,
279+
conventions.AttributeMessageID,
280+
conventions.AttributeMessageUncompressedSize,
281+
conventions.AttributeMessageCompressedSize,
282282
}
283283
// TODO: Find a better way to check for message_event. Maybe use the event.Name.
284284
if attrs.Len() == len(ocMessageEventAttrs) {
@@ -292,16 +292,16 @@ func eventToOC(event pdata.SpanEvent) *octrace.Span_TimeEvent {
292292
ocMessageEventAttrValues[attr] = akv
293293
}
294294
if ocMessageEventAttrFound {
295-
ocMessageEventType := ocMessageEventAttrValues[conventions.OCTimeEventMessageEventType]
295+
ocMessageEventType := ocMessageEventAttrValues[conventions.AttributeMessageType]
296296
ocMessageEventTypeVal := octrace.Span_TimeEvent_MessageEvent_Type_value[ocMessageEventType.StringVal()]
297297
return &octrace.Span_TimeEvent{
298298
Time: timestampAsTimestampPb(event.Timestamp()),
299299
Value: &octrace.Span_TimeEvent_MessageEvent_{
300300
MessageEvent: &octrace.Span_TimeEvent_MessageEvent{
301301
Type: octrace.Span_TimeEvent_MessageEvent_Type(ocMessageEventTypeVal),
302-
Id: uint64(ocMessageEventAttrValues[conventions.OCTimeEventMessageEventID].IntVal()),
303-
UncompressedSize: uint64(ocMessageEventAttrValues[conventions.OCTimeEventMessageEventUSize].IntVal()),
304-
CompressedSize: uint64(ocMessageEventAttrValues[conventions.OCTimeEventMessageEventCSize].IntVal()),
302+
Id: uint64(ocMessageEventAttrValues[conventions.AttributeMessageID].IntVal()),
303+
UncompressedSize: uint64(ocMessageEventAttrValues[conventions.AttributeMessageUncompressedSize].IntVal()),
304+
CompressedSize: uint64(ocMessageEventAttrValues[conventions.AttributeMessageCompressedSize].IntVal()),
305305
},
306306
},
307307
}

translator/trace/zipkin/zipkinv2_to_traces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func getNonSpanAttributes() map[string]struct{} {
4343
attrs[tracetranslator.TagInstrumentationVersion] = struct{}{}
4444
attrs[conventions.OCAttributeProcessStartTime] = struct{}{}
4545
attrs[conventions.OCAttributeExporterVersion] = struct{}{}
46-
attrs[conventions.OCAttributeProcessID] = struct{}{}
46+
attrs[conventions.AttributeProcessID] = struct{}{}
4747
attrs[conventions.OCAttributeResourceType] = struct{}{}
4848
return attrs
4949
}

0 commit comments

Comments
 (0)