From 57ea27eef7f309982f815a3ddb64eded6897bc7f Mon Sep 17 00:00:00 2001 From: vyzo Date: Thu, 14 Nov 2019 12:23:32 +0200 Subject: [PATCH] remote tracer --- pb/trace.pb.go | 531 +++++++++++++++++++++++++++++++++++++++++-------- pb/trace.proto | 8 + tracer.go | 163 ++++++++++++++- 3 files changed, 613 insertions(+), 89 deletions(-) diff --git a/pb/trace.pb.go b/pb/trace.pb.go index 00d4f45..b9b829d 100644 --- a/pb/trace.pb.go +++ b/pb/trace.pb.go @@ -86,7 +86,7 @@ func (x *TraceEvent_Type) UnmarshalJSON(data []byte) error { return nil } func (TraceEvent_Type) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 0} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 0} } type TraceEvent struct { @@ -115,7 +115,7 @@ func (m *TraceEvent) Reset() { *m = TraceEvent{} } func (m *TraceEvent) String() string { return proto.CompactTextString(m) } func (*TraceEvent) ProtoMessage() {} func (*TraceEvent) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0} + return fileDescriptor_trace_a154d83c271edb68, []int{0} } func (m *TraceEvent) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -268,7 +268,7 @@ func (m *TraceEvent_PublishMessage) Reset() { *m = TraceEvent_PublishMes func (m *TraceEvent_PublishMessage) String() string { return proto.CompactTextString(m) } func (*TraceEvent_PublishMessage) ProtoMessage() {} func (*TraceEvent_PublishMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 0} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 0} } func (m *TraceEvent_PublishMessage) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -324,7 +324,7 @@ func (m *TraceEvent_RejectMessage) Reset() { *m = TraceEvent_RejectMessa func (m *TraceEvent_RejectMessage) String() string { return proto.CompactTextString(m) } func (*TraceEvent_RejectMessage) ProtoMessage() {} func (*TraceEvent_RejectMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 1} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 1} } func (m *TraceEvent_RejectMessage) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -386,7 +386,7 @@ func (m *TraceEvent_DuplicateMessage) Reset() { *m = TraceEvent_Duplicat func (m *TraceEvent_DuplicateMessage) String() string { return proto.CompactTextString(m) } func (*TraceEvent_DuplicateMessage) ProtoMessage() {} func (*TraceEvent_DuplicateMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 2} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 2} } func (m *TraceEvent_DuplicateMessage) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -440,7 +440,7 @@ func (m *TraceEvent_DeliverMessage) Reset() { *m = TraceEvent_DeliverMes func (m *TraceEvent_DeliverMessage) String() string { return proto.CompactTextString(m) } func (*TraceEvent_DeliverMessage) ProtoMessage() {} func (*TraceEvent_DeliverMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 3} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 3} } func (m *TraceEvent_DeliverMessage) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -488,7 +488,7 @@ func (m *TraceEvent_AddPeer) Reset() { *m = TraceEvent_AddPeer{} } func (m *TraceEvent_AddPeer) String() string { return proto.CompactTextString(m) } func (*TraceEvent_AddPeer) ProtoMessage() {} func (*TraceEvent_AddPeer) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 4} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 4} } func (m *TraceEvent_AddPeer) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -542,7 +542,7 @@ func (m *TraceEvent_RemovePeer) Reset() { *m = TraceEvent_RemovePeer{} } func (m *TraceEvent_RemovePeer) String() string { return proto.CompactTextString(m) } func (*TraceEvent_RemovePeer) ProtoMessage() {} func (*TraceEvent_RemovePeer) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 5} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 5} } func (m *TraceEvent_RemovePeer) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -590,7 +590,7 @@ func (m *TraceEvent_RecvRPC) Reset() { *m = TraceEvent_RecvRPC{} } func (m *TraceEvent_RecvRPC) String() string { return proto.CompactTextString(m) } func (*TraceEvent_RecvRPC) ProtoMessage() {} func (*TraceEvent_RecvRPC) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 6} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 6} } func (m *TraceEvent_RecvRPC) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -645,7 +645,7 @@ func (m *TraceEvent_SendRPC) Reset() { *m = TraceEvent_SendRPC{} } func (m *TraceEvent_SendRPC) String() string { return proto.CompactTextString(m) } func (*TraceEvent_SendRPC) ProtoMessage() {} func (*TraceEvent_SendRPC) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 7} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 7} } func (m *TraceEvent_SendRPC) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -700,7 +700,7 @@ func (m *TraceEvent_DropRPC) Reset() { *m = TraceEvent_DropRPC{} } func (m *TraceEvent_DropRPC) String() string { return proto.CompactTextString(m) } func (*TraceEvent_DropRPC) ProtoMessage() {} func (*TraceEvent_DropRPC) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 8} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 8} } func (m *TraceEvent_DropRPC) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -754,7 +754,7 @@ func (m *TraceEvent_Join) Reset() { *m = TraceEvent_Join{} } func (m *TraceEvent_Join) String() string { return proto.CompactTextString(m) } func (*TraceEvent_Join) ProtoMessage() {} func (*TraceEvent_Join) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 9} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 9} } func (m *TraceEvent_Join) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -801,7 +801,7 @@ func (m *TraceEvent_Leave) Reset() { *m = TraceEvent_Leave{} } func (m *TraceEvent_Leave) String() string { return proto.CompactTextString(m) } func (*TraceEvent_Leave) ProtoMessage() {} func (*TraceEvent_Leave) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 10} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 10} } func (m *TraceEvent_Leave) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -849,7 +849,7 @@ func (m *TraceEvent_Graft) Reset() { *m = TraceEvent_Graft{} } func (m *TraceEvent_Graft) String() string { return proto.CompactTextString(m) } func (*TraceEvent_Graft) ProtoMessage() {} func (*TraceEvent_Graft) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 11} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 11} } func (m *TraceEvent_Graft) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -904,7 +904,7 @@ func (m *TraceEvent_Prune) Reset() { *m = TraceEvent_Prune{} } func (m *TraceEvent_Prune) String() string { return proto.CompactTextString(m) } func (*TraceEvent_Prune) ProtoMessage() {} func (*TraceEvent_Prune) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 12} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 12} } func (m *TraceEvent_Prune) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -960,7 +960,7 @@ func (m *TraceEvent_RPCMeta) Reset() { *m = TraceEvent_RPCMeta{} } func (m *TraceEvent_RPCMeta) String() string { return proto.CompactTextString(m) } func (*TraceEvent_RPCMeta) ProtoMessage() {} func (*TraceEvent_RPCMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 13} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 13} } func (m *TraceEvent_RPCMeta) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1022,7 +1022,7 @@ func (m *TraceEvent_MessageMeta) Reset() { *m = TraceEvent_MessageMeta{} func (m *TraceEvent_MessageMeta) String() string { return proto.CompactTextString(m) } func (*TraceEvent_MessageMeta) ProtoMessage() {} func (*TraceEvent_MessageMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 14} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 14} } func (m *TraceEvent_MessageMeta) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1077,7 +1077,7 @@ func (m *TraceEvent_SubMeta) Reset() { *m = TraceEvent_SubMeta{} } func (m *TraceEvent_SubMeta) String() string { return proto.CompactTextString(m) } func (*TraceEvent_SubMeta) ProtoMessage() {} func (*TraceEvent_SubMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 15} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 15} } func (m *TraceEvent_SubMeta) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1134,7 +1134,7 @@ func (m *TraceEvent_ControlMeta) Reset() { *m = TraceEvent_ControlMeta{} func (m *TraceEvent_ControlMeta) String() string { return proto.CompactTextString(m) } func (*TraceEvent_ControlMeta) ProtoMessage() {} func (*TraceEvent_ControlMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 16} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 16} } func (m *TraceEvent_ControlMeta) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1203,7 +1203,7 @@ func (m *TraceEvent_ControlIHaveMeta) Reset() { *m = TraceEvent_ControlI func (m *TraceEvent_ControlIHaveMeta) String() string { return proto.CompactTextString(m) } func (*TraceEvent_ControlIHaveMeta) ProtoMessage() {} func (*TraceEvent_ControlIHaveMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 17} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 17} } func (m *TraceEvent_ControlIHaveMeta) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1257,7 +1257,7 @@ func (m *TraceEvent_ControlIWantMeta) Reset() { *m = TraceEvent_ControlI func (m *TraceEvent_ControlIWantMeta) String() string { return proto.CompactTextString(m) } func (*TraceEvent_ControlIWantMeta) ProtoMessage() {} func (*TraceEvent_ControlIWantMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 18} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 18} } func (m *TraceEvent_ControlIWantMeta) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1304,7 +1304,7 @@ func (m *TraceEvent_ControlGraftMeta) Reset() { *m = TraceEvent_ControlG func (m *TraceEvent_ControlGraftMeta) String() string { return proto.CompactTextString(m) } func (*TraceEvent_ControlGraftMeta) ProtoMessage() {} func (*TraceEvent_ControlGraftMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 19} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 19} } func (m *TraceEvent_ControlGraftMeta) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1351,7 +1351,7 @@ func (m *TraceEvent_ControlPruneMeta) Reset() { *m = TraceEvent_ControlP func (m *TraceEvent_ControlPruneMeta) String() string { return proto.CompactTextString(m) } func (*TraceEvent_ControlPruneMeta) ProtoMessage() {} func (*TraceEvent_ControlPruneMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_trace_f5041bb48e7a4810, []int{0, 20} + return fileDescriptor_trace_a154d83c271edb68, []int{0, 20} } func (m *TraceEvent_ControlPruneMeta) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1387,6 +1387,100 @@ func (m *TraceEvent_ControlPruneMeta) GetTopic() string { return "" } +type TraceEventBatch struct { + Batch []*TraceEvent `protobuf:"bytes,1,rep,name=batch" json:"batch,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *TraceEventBatch) Reset() { *m = TraceEventBatch{} } +func (m *TraceEventBatch) String() string { return proto.CompactTextString(m) } +func (*TraceEventBatch) ProtoMessage() {} +func (*TraceEventBatch) Descriptor() ([]byte, []int) { + return fileDescriptor_trace_a154d83c271edb68, []int{1} +} +func (m *TraceEventBatch) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TraceEventBatch) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TraceEventBatch.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *TraceEventBatch) XXX_Merge(src proto.Message) { + xxx_messageInfo_TraceEventBatch.Merge(dst, src) +} +func (m *TraceEventBatch) XXX_Size() int { + return m.Size() +} +func (m *TraceEventBatch) XXX_DiscardUnknown() { + xxx_messageInfo_TraceEventBatch.DiscardUnknown(m) +} + +var xxx_messageInfo_TraceEventBatch proto.InternalMessageInfo + +func (m *TraceEventBatch) GetBatch() []*TraceEvent { + if m != nil { + return m.Batch + } + return nil +} + +type CompressedTraceEventBatch struct { + Data []byte `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CompressedTraceEventBatch) Reset() { *m = CompressedTraceEventBatch{} } +func (m *CompressedTraceEventBatch) String() string { return proto.CompactTextString(m) } +func (*CompressedTraceEventBatch) ProtoMessage() {} +func (*CompressedTraceEventBatch) Descriptor() ([]byte, []int) { + return fileDescriptor_trace_a154d83c271edb68, []int{2} +} +func (m *CompressedTraceEventBatch) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CompressedTraceEventBatch) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CompressedTraceEventBatch.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *CompressedTraceEventBatch) XXX_Merge(src proto.Message) { + xxx_messageInfo_CompressedTraceEventBatch.Merge(dst, src) +} +func (m *CompressedTraceEventBatch) XXX_Size() int { + return m.Size() +} +func (m *CompressedTraceEventBatch) XXX_DiscardUnknown() { + xxx_messageInfo_CompressedTraceEventBatch.DiscardUnknown(m) +} + +var xxx_messageInfo_CompressedTraceEventBatch proto.InternalMessageInfo + +func (m *CompressedTraceEventBatch) GetData() []byte { + if m != nil { + return m.Data + } + return nil +} + func init() { proto.RegisterType((*TraceEvent)(nil), "pubsub.pb.TraceEvent") proto.RegisterType((*TraceEvent_PublishMessage)(nil), "pubsub.pb.TraceEvent.PublishMessage") @@ -1410,6 +1504,8 @@ func init() { proto.RegisterType((*TraceEvent_ControlIWantMeta)(nil), "pubsub.pb.TraceEvent.ControlIWantMeta") proto.RegisterType((*TraceEvent_ControlGraftMeta)(nil), "pubsub.pb.TraceEvent.ControlGraftMeta") proto.RegisterType((*TraceEvent_ControlPruneMeta)(nil), "pubsub.pb.TraceEvent.ControlPruneMeta") + proto.RegisterType((*TraceEventBatch)(nil), "pubsub.pb.TraceEventBatch") + proto.RegisterType((*CompressedTraceEventBatch)(nil), "pubsub.pb.CompressedTraceEventBatch") proto.RegisterEnum("pubsub.pb.TraceEvent_Type", TraceEvent_Type_name, TraceEvent_Type_value) } func (m *TraceEvent) Marshal() (dAtA []byte, err error) { @@ -2334,6 +2430,66 @@ func (m *TraceEvent_ControlPruneMeta) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *TraceEventBatch) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TraceEventBatch) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Batch) > 0 { + for _, msg := range m.Batch { + dAtA[i] = 0xa + i++ + i = encodeVarintTrace(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *CompressedTraceEventBatch) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CompressedTraceEventBatch) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Data != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintTrace(dAtA, i, uint64(len(m.Data))) + i += copy(dAtA[i:], m.Data) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + func encodeVarintTrace(dAtA []byte, offset int, v uint64) int { for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -2844,6 +3000,40 @@ func (m *TraceEvent_ControlPruneMeta) Size() (n int) { return n } +func (m *TraceEventBatch) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Batch) > 0 { + for _, e := range m.Batch { + l = e.Size() + n += 1 + l + sovTrace(uint64(l)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *CompressedTraceEventBatch) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Data != nil { + l = len(m.Data) + n += 1 + l + sovTrace(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + func sovTrace(x uint64) (n int) { for { n++ @@ -5668,6 +5858,170 @@ func (m *TraceEvent_ControlPruneMeta) Unmarshal(dAtA []byte) error { } return nil } +func (m *TraceEventBatch) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTrace + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TraceEventBatch: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TraceEventBatch: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Batch", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTrace + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTrace + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Batch = append(m.Batch, &TraceEvent{}) + if err := m.Batch[len(m.Batch)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTrace(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTrace + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CompressedTraceEventBatch) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTrace + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CompressedTraceEventBatch: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CompressedTraceEventBatch: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTrace + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTrace + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTrace(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTrace + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTrace(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 @@ -5773,68 +6127,71 @@ var ( ErrIntOverflowTrace = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("trace.proto", fileDescriptor_trace_f5041bb48e7a4810) } - -var fileDescriptor_trace_f5041bb48e7a4810 = []byte{ - // 958 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xcf, 0x6e, 0xdb, 0x46, - 0x10, 0xc6, 0x4b, 0xfd, 0x31, 0xc5, 0x11, 0x2d, 0xb3, 0xdb, 0xa6, 0x20, 0xd8, 0xc4, 0x50, 0xdd, - 0x20, 0xd0, 0x49, 0x40, 0x0c, 0x14, 0x39, 0x34, 0x01, 0xaa, 0x88, 0xb4, 0x2d, 0x43, 0xb6, 0x89, - 0x91, 0xac, 0x1e, 0x5d, 0x4a, 0xda, 0x26, 0x0c, 0x24, 0x92, 0x20, 0x29, 0x15, 0x79, 0x80, 0xbe, - 0x5b, 0x6e, 0xed, 0x23, 0x14, 0x3e, 0xf5, 0x31, 0x8a, 0xdd, 0x25, 0x29, 0x51, 0xa6, 0x98, 0x34, - 0xed, 0x8d, 0xb3, 0xfc, 0x7e, 0xb3, 0x3b, 0xcb, 0xf9, 0x06, 0x84, 0x66, 0x1c, 0x3a, 0x33, 0xda, - 0x0d, 0x42, 0x3f, 0xf6, 0x89, 0x12, 0xac, 0xa6, 0xd1, 0x6a, 0xda, 0x0d, 0xa6, 0x27, 0x7f, 0x3f, - 0x02, 0x18, 0xb3, 0x57, 0xd6, 0x9a, 0x7a, 0x31, 0xe9, 0x42, 0x2d, 0x7e, 0x1f, 0x50, 0x5d, 0x6a, - 0x4b, 0x9d, 0xd6, 0xa9, 0xd1, 0xcd, 0x84, 0xdd, 0x8d, 0xa8, 0x3b, 0x7e, 0x1f, 0x50, 0xe4, 0x3a, - 0xf2, 0x0d, 0x1c, 0x04, 0x94, 0x86, 0x03, 0x53, 0xaf, 0xb4, 0xa5, 0x8e, 0x8a, 0x49, 0x44, 0x1e, - 0x83, 0x12, 0xbb, 0x4b, 0x1a, 0xc5, 0xce, 0x32, 0xd0, 0xab, 0x6d, 0xa9, 0x53, 0xc5, 0xcd, 0x02, - 0x19, 0x42, 0x2b, 0x58, 0x4d, 0x17, 0x6e, 0xf4, 0xf6, 0x8a, 0x46, 0x91, 0xf3, 0x86, 0xea, 0xb5, - 0xb6, 0xd4, 0x69, 0x9e, 0x3e, 0x2d, 0xde, 0xcf, 0xce, 0x69, 0x71, 0x87, 0x25, 0x03, 0x38, 0x0c, - 0xe9, 0x3b, 0x3a, 0x8b, 0xd3, 0x64, 0x75, 0x9e, 0xec, 0xfb, 0xe2, 0x64, 0xb8, 0x2d, 0xc5, 0x3c, - 0x49, 0x10, 0xb4, 0xf9, 0x2a, 0x58, 0xb8, 0x33, 0x27, 0xa6, 0x69, 0xb6, 0x03, 0x9e, 0xed, 0x59, - 0x71, 0x36, 0x73, 0x47, 0x8d, 0x0f, 0x78, 0x56, 0xec, 0x9c, 0x2e, 0xdc, 0x35, 0x0d, 0xd3, 0x8c, - 0x72, 0x59, 0xb1, 0x66, 0x4e, 0x8b, 0x3b, 0x2c, 0x79, 0x01, 0xb2, 0x33, 0x9f, 0xdb, 0x94, 0x86, - 0x7a, 0x83, 0xa7, 0x79, 0x52, 0x9c, 0xa6, 0x27, 0x44, 0x98, 0xaa, 0xc9, 0x4f, 0x00, 0x21, 0x5d, - 0xfa, 0x6b, 0xca, 0x59, 0x85, 0xb3, 0xed, 0x7d, 0x57, 0x94, 0xea, 0x70, 0x8b, 0x61, 0x5b, 0x87, - 0x74, 0xb6, 0x46, 0xbb, 0xaf, 0x43, 0xd9, 0xd6, 0x28, 0x44, 0x98, 0xaa, 0x19, 0x18, 0x51, 0x6f, - 0xce, 0xc0, 0x66, 0x19, 0x38, 0x12, 0x22, 0x4c, 0xd5, 0x0c, 0x9c, 0x87, 0x7e, 0xc0, 0x40, 0xb5, - 0x0c, 0x34, 0x85, 0x08, 0x53, 0x35, 0x6b, 0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0x1e, 0xc9, 0x2c, 0x32, 0xf1, - 0xc6, 0xe6, 0x51, 0x83, 0x34, 0xa0, 0x76, 0x79, 0x33, 0xb8, 0xd6, 0x14, 0xa2, 0x40, 0x7d, 0x68, - 0xf5, 0x26, 0x96, 0x06, 0xec, 0xf1, 0x1c, 0x7b, 0x67, 0x63, 0xad, 0xc9, 0x1e, 0x6d, 0xbc, 0xbd, - 0xb6, 0x34, 0xf5, 0xb5, 0xfa, 0xe1, 0xfe, 0x58, 0xfa, 0xf3, 0xfe, 0x58, 0xfa, 0xeb, 0xfe, 0x58, - 0xfa, 0x27, 0x00, 0x00, 0xff, 0xff, 0xfe, 0x5e, 0x59, 0x8a, 0x11, 0x0b, 0x00, 0x00, +func init() { proto.RegisterFile("trace.proto", fileDescriptor_trace_a154d83c271edb68) } + +var fileDescriptor_trace_a154d83c271edb68 = []byte{ + // 1006 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xdd, 0x6e, 0xe3, 0x44, + 0x14, 0xc7, 0x71, 0x3e, 0x36, 0xc9, 0x49, 0x9a, 0x9a, 0x81, 0x22, 0x63, 0x76, 0xab, 0x10, 0x56, + 0xab, 0x48, 0x48, 0x41, 0x5b, 0x09, 0xed, 0x05, 0xbb, 0x88, 0x34, 0x76, 0xdb, 0x54, 0x69, 0x6b, + 0x9d, 0xa4, 0xe5, 0xb2, 0x38, 0xc9, 0xb0, 0xf5, 0x2a, 0xb1, 0x2d, 0x7b, 0x12, 0xb4, 0x0f, 0xc0, + 0xbb, 0xed, 0x1d, 0x3c, 0x02, 0xea, 0x15, 0x8f, 0x81, 0x66, 0xc6, 0x8e, 0xe3, 0xd4, 0xf1, 0x2e, + 0x0b, 0x77, 0x73, 0xc6, 0xff, 0xdf, 0x99, 0xaf, 0xf3, 0x3f, 0x32, 0xd4, 0x59, 0x60, 0x4f, 0x69, + 0xd7, 0x0f, 0x3c, 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, 0x18, 0xab, 0xc9, 0x4f, 0x00, 0x01, 0x5d, + 0x78, 0x2b, 0x2a, 0xd8, 0x9a, 0x60, 0x5b, 0xbb, 0xae, 0x28, 0xd6, 0xe1, 0x06, 0xc3, 0x97, 0x0e, + 0xe8, 0x74, 0x85, 0x56, 0x5f, 0x83, 0xbc, 0xa5, 0x51, 0x8a, 0x30, 0x56, 0x73, 0x30, 0xa4, 0xee, + 0x8c, 0x83, 0xf5, 0x3c, 0x70, 0x24, 0x45, 0x18, 0xab, 0x39, 0x38, 0x0b, 0x3c, 0x9f, 0x83, 0x8d, + 0x3c, 0xd0, 0x90, 0x22, 0x8c, 0xd5, 0xbc, 0x8c, 0xdf, 0x78, 0x8e, 0xab, 0xed, 0x09, 0x6a, 0x47, + 0x19, 0x9f, 0x7b, 0x8e, 0x8b, 0x42, 0x47, 0x9e, 0x43, 0x79, 0x4e, 0xed, 0x15, 0xd5, 0x9a, 0x02, + 0xf8, 0x2a, 0x1b, 0x18, 0x72, 0x09, 0x4a, 0x25, 0x47, 0x5e, 0x07, 0xf6, 0xaf, 0x4c, 0xdb, 0xcf, + 0x43, 0x4e, 0xb9, 0x04, 0xa5, 0x92, 0x23, 0x7e, 0xb0, 0x74, 0xa9, 0xa6, 0xe6, 0x21, 0x16, 0x97, + 0xa0, 0x54, 0xea, 0x27, 0xd0, 0x4c, 0x57, 0x3f, 0x77, 0xd6, 0x42, 0x0e, 0x07, 0x86, 0xb0, 0x69, + 0x03, 0x93, 0x09, 0xee, 0x47, 0xe6, 0xf9, 0xce, 0x34, 0xd4, 0x0a, 0xad, 0x62, 0xa7, 0x86, 0x51, + 0xa4, 0x3b, 0xb0, 0x97, 0x2a, 0xfc, 0xf7, 0xa4, 0x69, 0x43, 0x23, 0xa0, 0x53, 0xea, 0xac, 0xe8, + 0xec, 0x24, 0xf0, 0x16, 0x91, 0xb9, 0x53, 0x73, 0x7c, 0xa9, 0x80, 0xda, 0xa1, 0xe7, 0x0a, 0x7f, + 0xd7,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x9e, + 0x53, 0xc8, 0x01, 0x7c, 0x6a, 0x5c, 0x5b, 0xc3, 0x41, 0xbf, 0x37, 0x36, 0xd7, 0xd3, 0x05, 0xce, + 0x1b, 0xe6, 0x70, 0x70, 0x63, 0xe2, 0x7a, 0xb2, 0x48, 0x1a, 0x50, 0xed, 0x19, 0xc6, 0xad, 0x65, + 0x9a, 0xa8, 0x96, 0xc8, 0x3e, 0xd4, 0xd1, 0xbc, 0xb8, 0xba, 0x31, 0xe5, 0x44, 0x99, 0x7f, 0x46, + 0xb3, 0x7f, 0x73, 0x8b, 0x56, 0x5f, 0x7d, 0xc4, 0xa3, 0x91, 0x79, 0x69, 0x88, 0xa8, 0xc2, 0x23, + 0x03, 0xaf, 0x2c, 0x11, 0x55, 0x49, 0x15, 0x4a, 0xe7, 0x57, 0x83, 0x4b, 0xb5, 0x46, 0x6a, 0x50, + 0x1e, 0x9a, 0xbd, 0x1b, 0x53, 0x05, 0x3e, 0x3c, 0xc5, 0xde, 0xc9, 0x58, 0xad, 0xf3, 0xa1, 0x85, + 0xd7, 0x97, 0xa6, 0xda, 0x68, 0xff, 0x08, 0xfb, 0xc9, 0x4b, 0x1e, 0xdb, 0x6c, 0x7a, 0x47, 0xbe, + 0x85, 0xf2, 0x84, 0x0f, 0xa2, 0x72, 0x3d, 0xc8, 0x7c, 0x74, 0x94, 0x9a, 0xf6, 0x77, 0xf0, 0x65, + 0xdf, 0x5b, 0xf8, 0x01, 0x0d, 0x43, 0x3a, 0xdb, 0xce, 0x44, 0xa0, 0x34, 0xb3, 0x99, 0x1d, 0x19, + 0x4f, 0x8c, 0x8f, 0x1b, 0xef, 0xee, 0x0f, 0x95, 0x3f, 0xef, 0x0f, 0x95, 0xbf, 0xee, 0x0f, 0x95, + 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xe4, 0x80, 0x70, 0x3c, 0x82, 0x0b, 0x00, 0x00, } diff --git a/pb/trace.proto b/pb/trace.proto index e6369ed..7599d33 100644 --- a/pb/trace.proto +++ b/pb/trace.proto @@ -139,3 +139,11 @@ message TraceEvent { optional string topic = 1; } } + +message TraceEventBatch { + repeated TraceEvent batch = 1; +} + +message CompressedTraceEventBatch { + optional bytes data = 1; +} diff --git a/tracer.go b/tracer.go index 01b1ec6..6e52c28 100644 --- a/tracer.go +++ b/tracer.go @@ -1,14 +1,24 @@ package pubsub import ( + "bytes" + "compress/gzip" + "context" "encoding/json" "io" "os" "sync" - - ggio "github.com/gogo/protobuf/io" + "time" pb "github.com/libp2p/go-libp2p-pubsub/pb" + + "github.com/libp2p/go-libp2p-core/helpers" + "github.com/libp2p/go-libp2p-core/host" + "github.com/libp2p/go-libp2p-core/network" + "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p-core/protocol" + + ggio "github.com/gogo/protobuf/io" ) type basicTracer struct { @@ -136,3 +146,152 @@ func (t *PBTracer) doWrite() { } var _ EventTracer = (*PBTracer)(nil) + +const RemoteTracerProtoID = protocol.ID("/libp2p/pubsub/tracer/1.0.0") + +// RemoteTracer is a tracer that sends trace events to a remote peer +type RemoteTracer struct { + basicTracer + ctx context.Context + host host.Host + pi peer.AddrInfo +} + +// NewRemoteTracer constructs a RemoteTracer, tracing to the peer identified by pi +func NewRemoteTracer(ctx context.Context, host host.Host, pi peer.AddrInfo) (*RemoteTracer, error) { + tr := &RemoteTracer{ctx: ctx, host: host, pi: pi, basicTracer: basicTracer{ch: make(chan struct{}, 1)}} + go tr.doWrite() + return tr, nil +} + +func (t *RemoteTracer) doWrite() { + var buf []*pb.TraceEvent + + s, err := t.openStream() + if err != nil { + log.Errorf("error opening remote tracer stream: %s", err.Error()) + return + } + + w := ggio.NewDelimitedWriter(s) + + for { + _, ok := <-t.ch + + // nil out the buffer to gc events + for i := range buf { + buf[i] = nil + } + + t.mx.Lock() + tmp := t.buf + t.buf = buf[:0] + buf = tmp + t.mx.Unlock() + + if len(buf) == 0 { + goto end + } + + { + batch := &pb.TraceEventBatch{Batch: buf} + blob, err := batch.Marshal() + if err != nil { + log.Errorf("error marshalling trace event batch: %s", err.Error()) + goto end + } + + // compress batch + var cbuf bytes.Buffer + gzipW := gzip.NewWriter(&cbuf) + _, err = gzipW.Write(blob) + if err != nil { + log.Errorf("error compressing trace event batch: %s", err.Error()) + goto end + } + err = gzipW.Close() + if err != nil { + log.Errorf("error compressing trace event batch: %s", err.Error()) + goto end + } + + cblob := cbuf.Bytes() + cbatch := &pb.CompressedTraceEventBatch{Data: cblob} + err = w.WriteMsg(cbatch) + if err != nil { + log.Errorf("error writing trace event data: %s", err.Error()) + if !ok { + goto end + } + + // reset output + s.Reset() + s, err = t.openStream() + if err != nil { + log.Errorf("error opening remote tracer stream: %s", err.Error()) + return + } + w = ggio.NewDelimitedWriter(s) + } + } + + end: + if !ok { + helpers.FullClose(s) + return + } + } +} + +func (t *RemoteTracer) connect() error { + for { + ctx, cancel := context.WithTimeout(t.ctx, time.Minute) + err := t.host.Connect(ctx, t.pi) + cancel() + if err != nil { + if t.ctx.Err() != nil { + return err + } + + // wait a minute and try again, to account for transient server downtime + select { + case <-time.After(time.Minute): + continue + case <-t.ctx.Done(): + return t.ctx.Err() + } + } + + return nil + } +} + +func (t *RemoteTracer) openStream() (network.Stream, error) { + for { + err := t.connect() + if err != nil { + return nil, err + } + + ctx, cancel := context.WithTimeout(t.ctx, time.Minute) + s, err := t.host.NewStream(ctx, t.pi.ID, RemoteTracerProtoID) + cancel() + if err != nil { + if t.ctx.Err() != nil { + return nil, err + } + + // wait a minute and try again, to account for transient server downtime + select { + case <-time.After(time.Minute): + continue + case <-t.ctx.Done(): + return nil, t.ctx.Err() + } + } + + return s, nil + } +} + +var _ EventTracer = (*RemoteTracer)(nil) -- GitLab