Skip to content

Commit

Permalink
Use the new protobuf library everywhere (#780)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu committed Aug 20, 2020
1 parent 4ce8e84 commit 3fd2453
Show file tree
Hide file tree
Showing 58 changed files with 201 additions and 243 deletions.
2 changes: 1 addition & 1 deletion exporter/alibabacloudlogserviceexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require (
github.com/aliyun/aliyun-log-go-sdk v0.1.12
github.com/census-instrumentation/opencensus-proto v0.3.0
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.4.2
github.com/stretchr/testify v1.6.1
go.opentelemetry.io/collector v0.8.1-0.20200820203435-961c48b75778
go.uber.org/zap v1.15.0
google.golang.org/protobuf v1.25.0
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ import (
"encoding/hex"
"encoding/json"
"strconv"
"time"

sls "github.com/aliyun/aliyun-log-go-sdk"
commonpb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1"
resourcepb "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1"
tracepb "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1"
"github.com/gogo/protobuf/proto"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/timestamp"
"go.opentelemetry.io/collector/consumer/consumerdata"
tracetranslator "go.opentelemetry.io/collector/translator/trace"
"google.golang.org/protobuf/types/known/timestamppb"
)

const (
Expand Down Expand Up @@ -90,7 +90,7 @@ func nodeAndResourceToLogContent(node *commonpb.Node, resource *resourcepb.Resou
})
}
if node.Identifier.StartTimestamp != nil && node.Identifier.StartTimestamp.Seconds != 0 {
startTimeStr := ptypes.TimestampString(node.Identifier.StartTimestamp)
startTimeStr := node.Identifier.StartTimestamp.AsTime().Format(time.RFC3339Nano)
contents = append(contents, &sls.LogContent{
Key: proto.String(processTagsPrefix + "start.time"),
Value: proto.String(startTimeStr),
Expand Down Expand Up @@ -399,7 +399,7 @@ func truncableStringToStr(ts *tracepb.TruncatableString) string {
return ts.Value
}

func timestampToEpochMicroseconds(ts *timestamp.Timestamp) int64 {
func timestampToEpochMicroseconds(ts *timestamppb.Timestamp) int64 {
if ts == nil {
return 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import (
commonpb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1"
resourcepb "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1"
tracepb "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/stretchr/testify/assert"
"go.opentelemetry.io/collector/consumer/consumerdata"
tracetranslator "go.opentelemetry.io/collector/translator/trace"
"google.golang.org/protobuf/types/known/timestamppb"
)

type logKeyValuePair struct {
Expand Down Expand Up @@ -332,7 +332,7 @@ var tds = []consumerdata.TraceData{
Identifier: &commonpb.ProcessIdentifier{
HostName: "api246-sjc1",
Pid: 13,
StartTimestamp: &timestamp.Timestamp{Seconds: 1485467190, Nanos: 639875000},
StartTimestamp: &timestamppb.Timestamp{Seconds: 1485467190, Nanos: 639875000},
},
LibraryInfo: &commonpb.LibraryInfo{ExporterVersion: "someVersion"},
ServiceInfo: &commonpb.ServiceInfo{Name: "api"},
Expand All @@ -355,8 +355,8 @@ var tds = []consumerdata.TraceData{
ParentSpanId: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0xC4, 0xE3},
Name: &tracepb.TruncatableString{Value: "get"},
Kind: tracepb.Span_CLIENT,
StartTime: &timestamp.Timestamp{Seconds: 1485467191, Nanos: 639875000},
EndTime: &timestamp.Timestamp{Seconds: 1485467191, Nanos: 662813000},
StartTime: &timestamppb.Timestamp{Seconds: 1485467191, Nanos: 639875000},
EndTime: &timestamppb.Timestamp{Seconds: 1485467191, Nanos: 662813000},
Attributes: &tracepb.Span_Attributes{
AttributeMap: map[string]*tracepb.AttributeValue{
"http.url": {
Expand Down Expand Up @@ -385,15 +385,15 @@ var tds = []consumerdata.TraceData{
TimeEvents: &tracepb.Span_TimeEvents{
TimeEvent: []*tracepb.Span_TimeEvent{
{
Time: &timestamp.Timestamp{Seconds: 1485467191, Nanos: 639874000},
Time: &timestamppb.Timestamp{Seconds: 1485467191, Nanos: 639874000},
Value: &tracepb.Span_TimeEvent_MessageEvent_{
MessageEvent: &tracepb.Span_TimeEvent_MessageEvent{
Type: tracepb.Span_TimeEvent_MessageEvent_SENT, UncompressedSize: 1024, CompressedSize: 512,
},
},
},
{
Time: &timestamp.Timestamp{Seconds: 1485467191, Nanos: 639875000},
Time: &timestamppb.Timestamp{Seconds: 1485467191, Nanos: 639875000},
Value: &tracepb.Span_TimeEvent_Annotation_{
Annotation: &tracepb.Span_TimeEvent_Annotation{
Attributes: &tracepb.Span_Attributes{
Expand All @@ -407,7 +407,7 @@ var tds = []consumerdata.TraceData{
},
},
{
Time: &timestamp.Timestamp{Seconds: 1485467191, Nanos: 639875000},
Time: &timestamppb.Timestamp{Seconds: 1485467191, Nanos: 639875000},
Value: &tracepb.Span_TimeEvent_Annotation_{
Annotation: &tracepb.Span_TimeEvent_Annotation{
Description: &tracepb.TruncatableString{Value: "annotation description"},
Expand Down Expand Up @@ -437,8 +437,8 @@ var tds = []consumerdata.TraceData{
ParentSpanId: nil,
Name: &tracepb.TruncatableString{Value: "get"},
Kind: tracepb.Span_SERVER,
StartTime: &timestamp.Timestamp{Seconds: 1485467191, Nanos: 639875000},
EndTime: &timestamp.Timestamp{Seconds: 1485467191, Nanos: 662813000},
StartTime: &timestamppb.Timestamp{Seconds: 1485467191, Nanos: 639875000},
EndTime: &timestamppb.Timestamp{Seconds: 1485467191, Nanos: 662813000},
Attributes: &tracepb.Span_Attributes{
AttributeMap: map[string]*tracepb.AttributeValue{
"peer.service": {
Expand All @@ -453,8 +453,8 @@ var tds = []consumerdata.TraceData{
ParentSpanId: []byte{},
Name: &tracepb.TruncatableString{Value: "get"},
Kind: tracepb.Span_SERVER,
StartTime: &timestamp.Timestamp{Seconds: 1485467191, Nanos: 639875000},
EndTime: &timestamp.Timestamp{Seconds: 1485467191, Nanos: 662813000},
StartTime: &timestamppb.Timestamp{Seconds: 1485467191, Nanos: 639875000},
EndTime: &timestamppb.Timestamp{Seconds: 1485467191, Nanos: 662813000},
Links: &tracepb.Span_Links{
Link: []*tracepb.Span_Link{
{
Expand All @@ -478,8 +478,8 @@ var tds = []consumerdata.TraceData{
SpanId: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x7D, 0x98},
ParentSpanId: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Name: &tracepb.TruncatableString{Value: "get2"},
StartTime: &timestamp.Timestamp{Seconds: 1485467192, Nanos: 639875000},
EndTime: &timestamp.Timestamp{Seconds: 1485467192, Nanos: 662813000},
StartTime: &timestamppb.Timestamp{Seconds: 1485467192, Nanos: 639875000},
EndTime: &timestamppb.Timestamp{Seconds: 1485467192, Nanos: 662813000},
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion exporter/honeycombexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.14

require (
github.com/census-instrumentation/opencensus-proto v0.3.0
github.com/golang/protobuf v1.4.2
github.com/google/go-cmp v0.5.1
github.com/honeycombio/libhoney-go v1.12.4
github.com/klauspost/compress v1.10.11
Expand All @@ -13,4 +12,5 @@ require (
go.uber.org/zap v1.15.0
google.golang.org/grpc v1.31.0
google.golang.org/grpc/examples v0.0.0-20200728194956-1c32b02682df // indirect
google.golang.org/protobuf v1.25.0
)
14 changes: 7 additions & 7 deletions exporter/honeycombexporter/honeycomb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import (
commonpb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1"
resourcepb "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1"
tracepb "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/golang/protobuf/ptypes/wrappers"
"github.com/google/go-cmp/cmp"
"github.com/klauspost/compress/zstd"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/consumer/consumerdata"
"go.uber.org/zap"
"google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/wrapperspb"
)

type honeycombData struct {
Expand Down Expand Up @@ -110,7 +110,7 @@ func TestExporter(t *testing.T) {
SpanId: []byte{0x02},
Name: &tracepb.TruncatableString{Value: "root"},
Kind: tracepb.Span_SERVER,
SameProcessAsParentSpan: &wrappers.BoolValue{Value: true},
SameProcessAsParentSpan: &wrapperspb.BoolValue{Value: true},
Attributes: &tracepb.Span_Attributes{
AttributeMap: map[string]*tracepb.AttributeValue{
"span_attr_name": {
Expand All @@ -129,7 +129,7 @@ func TestExporter(t *testing.T) {
TimeEvents: &tracepb.Span_TimeEvents{
TimeEvent: []*tracepb.Span_TimeEvent{
{
Time: &timestamp.Timestamp{
Time: &timestamppb.Timestamp{
Seconds: 0,
Nanos: 0,
},
Expand Down Expand Up @@ -157,7 +157,7 @@ func TestExporter(t *testing.T) {
ParentSpanId: []byte{0x02},
Name: &tracepb.TruncatableString{Value: "client"},
Kind: tracepb.Span_CLIENT,
SameProcessAsParentSpan: &wrappers.BoolValue{Value: true},
SameProcessAsParentSpan: &wrapperspb.BoolValue{Value: true},
Links: &tracepb.Span_Links{
Link: []*tracepb.Span_Link{
{
Expand All @@ -184,7 +184,7 @@ func TestExporter(t *testing.T) {
ParentSpanId: []byte{0x03},
Name: &tracepb.TruncatableString{Value: "server"},
Kind: tracepb.Span_SERVER,
SameProcessAsParentSpan: &wrappers.BoolValue{Value: false},
SameProcessAsParentSpan: &wrapperspb.BoolValue{Value: false},
},
},
}
Expand Down Expand Up @@ -280,7 +280,7 @@ func TestEmptyNode(t *testing.T) {
SpanId: []byte{0x02},
Name: &tracepb.TruncatableString{Value: "root"},
Kind: tracepb.Span_SERVER,
SameProcessAsParentSpan: &wrappers.BoolValue{Value: true},
SameProcessAsParentSpan: &wrapperspb.BoolValue{Value: true},
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions exporter/honeycombexporter/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
commonpb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1"
resourcepb "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1"
tracepb "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1"
"github.com/golang/protobuf/ptypes/timestamp"
"go.opentelemetry.io/collector/consumer/consumerdata"
"google.golang.org/grpc/codes"
"google.golang.org/protobuf/types/known/timestamppb"
)

// spanAttributesToMap converts an opencensus proto Span_Attributes object into a map
Expand Down Expand Up @@ -65,7 +65,7 @@ func hasRemoteParent(span *tracepb.Span) bool {
}

// timestampToTime converts a protobuf timestamp into a time.Time.
func timestampToTime(ts *timestamp.Timestamp) (t time.Time) {
func timestampToTime(ts *timestamppb.Timestamp) (t time.Time) {
if ts == nil {
return
}
Expand Down
4 changes: 2 additions & 2 deletions exporter/honeycombexporter/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"time"

tracepb "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1"
"github.com/golang/protobuf/ptypes/timestamp"
"google.golang.org/protobuf/types/known/timestamppb"
)

func TestSpanAttributesToMap(t *testing.T) {
Expand Down Expand Up @@ -91,7 +91,7 @@ func TestTimestampToTime(t *testing.T) {

t2 := time.Now()
seconds := t2.UnixNano() / 1000000000
nowTime := timestampToTime(&timestamp.Timestamp{
nowTime := timestampToTime(&timestamppb.Timestamp{
Seconds: seconds,
Nanos: int32(t2.UnixNano() - (seconds * 1000000000)),
})
Expand Down
2 changes: 1 addition & 1 deletion exporter/jaegerthrifthttpexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ go 1.14
require (
github.com/apache/thrift v0.13.0
github.com/census-instrumentation/opencensus-proto v0.3.0
github.com/golang/protobuf v1.4.2
github.com/google/go-cmp v0.5.1
github.com/jaegertracing/jaeger v1.18.2-0.20200707061226-97d2319ff2be
github.com/stretchr/testify v1.6.1
go.opentelemetry.io/collector v0.8.1-0.20200820203435-961c48b75778
go.uber.org/zap v1.15.0
google.golang.org/protobuf v1.25.0
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ package jaegerthrifthttpexporter

import (
"fmt"
"time"

commonpb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1"
resourcepb "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1"
tracepb "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/jaegertracing/jaeger/thrift-gen/jaeger"
"go.opentelemetry.io/collector/consumer/consumerdata"
tracetranslator "go.opentelemetry.io/collector/translator/trace"
"google.golang.org/protobuf/types/known/timestamppb"
)

var (
Expand Down Expand Up @@ -86,7 +86,7 @@ func ocNodeAndResourceToJaegerProcess(node *commonpb.Node, resource *resourcepb.
jTags = append(jTags, hostTag)
}
if node.Identifier.StartTimestamp != nil && node.Identifier.StartTimestamp.Seconds != 0 {
startTimeStr := ptypes.TimestampString(node.Identifier.StartTimestamp)
startTimeStr := node.Identifier.StartTimestamp.AsTime().Format(time.RFC3339Nano)
hostTag := &jaeger.Tag{
Key: "start.time",
VType: jaeger.TagType_STRING,
Expand Down Expand Up @@ -423,7 +423,7 @@ func truncableStringToStr(ts *tracepb.TruncatableString) string {
return ts.Value
}

func timestampToEpochMicroseconds(ts *timestamp.Timestamp) int64 {
func timestampToEpochMicroseconds(ts *timestamppb.Timestamp) int64 {
if ts == nil {
return 0
}
Expand Down
26 changes: 13 additions & 13 deletions exporter/jaegerthrifthttpexporter/protospan_to_jaegerthrift_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import (
commonpb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1"
resourcepb "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1"
tracepb "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/google/go-cmp/cmp"
"github.com/jaegertracing/jaeger/thrift-gen/jaeger"
"go.opentelemetry.io/collector/consumer/consumerdata"
tracetranslator "go.opentelemetry.io/collector/translator/trace"
"google.golang.org/protobuf/types/known/timestamppb"
)

func TestThriftInvalidOCProtoIDs(t *testing.T) {
Expand Down Expand Up @@ -395,7 +395,7 @@ var tds = []consumerdata.TraceData{
Identifier: &commonpb.ProcessIdentifier{
HostName: "api246-sjc1",
Pid: 13,
StartTimestamp: &timestamp.Timestamp{Seconds: 1485467190, Nanos: 639875000},
StartTimestamp: &timestamppb.Timestamp{Seconds: 1485467190, Nanos: 639875000},
},
LibraryInfo: &commonpb.LibraryInfo{ExporterVersion: "someVersion"},
ServiceInfo: &commonpb.ServiceInfo{Name: "api"},
Expand All @@ -418,8 +418,8 @@ var tds = []consumerdata.TraceData{
ParentSpanId: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0xC4, 0xE3},
Name: &tracepb.TruncatableString{Value: "get"},
Kind: tracepb.Span_CLIENT,
StartTime: &timestamp.Timestamp{Seconds: 1485467191, Nanos: 639875000},
EndTime: &timestamp.Timestamp{Seconds: 1485467191, Nanos: 662813000},
StartTime: &timestamppb.Timestamp{Seconds: 1485467191, Nanos: 639875000},
EndTime: &timestamppb.Timestamp{Seconds: 1485467191, Nanos: 662813000},
Attributes: &tracepb.Span_Attributes{
AttributeMap: map[string]*tracepb.AttributeValue{
"http.url": {
Expand Down Expand Up @@ -448,15 +448,15 @@ var tds = []consumerdata.TraceData{
TimeEvents: &tracepb.Span_TimeEvents{
TimeEvent: []*tracepb.Span_TimeEvent{
{
Time: &timestamp.Timestamp{Seconds: 1485467191, Nanos: 639874000},
Time: &timestamppb.Timestamp{Seconds: 1485467191, Nanos: 639874000},
Value: &tracepb.Span_TimeEvent_MessageEvent_{
MessageEvent: &tracepb.Span_TimeEvent_MessageEvent{
Type: tracepb.Span_TimeEvent_MessageEvent_SENT, UncompressedSize: 1024, CompressedSize: 512,
},
},
},
{
Time: &timestamp.Timestamp{Seconds: 1485467191, Nanos: 639875000},
Time: &timestamppb.Timestamp{Seconds: 1485467191, Nanos: 639875000},
Value: &tracepb.Span_TimeEvent_Annotation_{
Annotation: &tracepb.Span_TimeEvent_Annotation{
Attributes: &tracepb.Span_Attributes{
Expand All @@ -470,7 +470,7 @@ var tds = []consumerdata.TraceData{
},
},
{
Time: &timestamp.Timestamp{Seconds: 1485467191, Nanos: 639875000},
Time: &timestamppb.Timestamp{Seconds: 1485467191, Nanos: 639875000},
Value: &tracepb.Span_TimeEvent_Annotation_{
Annotation: &tracepb.Span_TimeEvent_Annotation{
Description: &tracepb.TruncatableString{Value: "annotation description"},
Expand Down Expand Up @@ -500,8 +500,8 @@ var tds = []consumerdata.TraceData{
ParentSpanId: nil,
Name: &tracepb.TruncatableString{Value: "get"},
Kind: tracepb.Span_SERVER,
StartTime: &timestamp.Timestamp{Seconds: 1485467191, Nanos: 639875000},
EndTime: &timestamp.Timestamp{Seconds: 1485467191, Nanos: 662813000},
StartTime: &timestamppb.Timestamp{Seconds: 1485467191, Nanos: 639875000},
EndTime: &timestamppb.Timestamp{Seconds: 1485467191, Nanos: 662813000},
Attributes: &tracepb.Span_Attributes{
AttributeMap: map[string]*tracepb.AttributeValue{
"peer.service": {
Expand All @@ -516,8 +516,8 @@ var tds = []consumerdata.TraceData{
ParentSpanId: []byte{},
Name: &tracepb.TruncatableString{Value: "get"},
Kind: tracepb.Span_SERVER,
StartTime: &timestamp.Timestamp{Seconds: 1485467191, Nanos: 639875000},
EndTime: &timestamp.Timestamp{Seconds: 1485467191, Nanos: 662813000},
StartTime: &timestamppb.Timestamp{Seconds: 1485467191, Nanos: 639875000},
EndTime: &timestamppb.Timestamp{Seconds: 1485467191, Nanos: 662813000},
Links: &tracepb.Span_Links{
Link: []*tracepb.Span_Link{
{
Expand All @@ -541,8 +541,8 @@ var tds = []consumerdata.TraceData{
SpanId: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x7D, 0x98},
ParentSpanId: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
Name: &tracepb.TruncatableString{Value: "get2"},
StartTime: &timestamp.Timestamp{Seconds: 1485467192, Nanos: 639875000},
EndTime: &timestamp.Timestamp{Seconds: 1485467192, Nanos: 662813000},
StartTime: &timestamppb.Timestamp{Seconds: 1485467192, Nanos: 639875000},
EndTime: &timestamppb.Timestamp{Seconds: 1485467192, Nanos: 662813000},
},
},
},
Expand Down
Loading

0 comments on commit 3fd2453

Please sign in to comment.