mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-24 10:07:04 +02:00
add tracing
This commit is contained in:
parent
21e0932339
commit
0be22c98c6
@ -217,7 +217,6 @@ var (
|
||||
Name: "tracer",
|
||||
EnvVars: []string{"MICRO_TRACER"},
|
||||
Usage: "Tracer for distributed tracing, e.g. memory, jaeger",
|
||||
Value: "memory",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "tracer_address",
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/micro/go-micro/v2/client"
|
||||
|
||||
"github.com/micro/go-micro/v2/debug/log"
|
||||
pb "github.com/micro/go-micro/v2/debug/service/proto"
|
||||
)
|
||||
@ -16,6 +15,14 @@ type debugClient struct {
|
||||
Client pb.DebugService
|
||||
}
|
||||
|
||||
func (d *debugClient) Trace() ([]*pb.Span, error) {
|
||||
rsp, err := d.Client.Trace(context.Background(), &pb.TraceRequest{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp.Spans, nil
|
||||
}
|
||||
|
||||
// Logs queries the services logs and returns a channel to read the logs from
|
||||
func (d *debugClient) Log(since time.Time, count int, stream bool) (log.Stream, error) {
|
||||
req := &pb.LogRequest{}
|
||||
|
@ -564,40 +564,40 @@ func init() {
|
||||
}
|
||||
|
||||
var fileDescriptor_dea322649cde1ef2 = []byte{
|
||||
// 554 bytes of a gzipped FileDescriptorProto
|
||||
// 553 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xcd, 0x6e, 0xd4, 0x30,
|
||||
0x10, 0xde, 0x24, 0x9b, 0xdd, 0xcd, 0xb4, 0x09, 0xc8, 0xfc, 0x28, 0x0a, 0x08, 0x2a, 0x9f, 0x16,
|
||||
0x01, 0x5e, 0x28, 0x17, 0x04, 0x57, 0x90, 0x38, 0x94, 0x8b, 0xcb, 0x0b, 0xb8, 0x89, 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c0, 0x3c, 0xb2, 0x17,
|
||||
0x1e, 0x19, 0xbe, 0xe5, 0xad, 0x90, 0xfb, 0x7c, 0xe9, 0x78, 0x87, 0x8c, 0x92, 0xbe, 0x94, 0x9c,
|
||||
0x55, 0x2a, 0x8f, 0x9d, 0x92, 0x87, 0x28, 0x83, 0xb0, 0x2e, 0xf3, 0x95, 0x25, 0xc3, 0xba, 0x44,
|
||||
0x05, 0x6c, 0xa4, 0x6b, 0x44, 0xe5, 0x6b, 0xcb, 0x1e, 0xb0, 0x51, 0xe7, 0x52, 0x0a, 0xa9, 0xf2,
|
||||
0x8d, 0x53, 0x77, 0x08, 0x7f, 0x05, 0x38, 0x13, 0xf5, 0xad, 0xfd, 0x3b, 0x07, 0x25, 0x67, 0xad,
|
||||
0x6d, 0x67, 0x43, 0x3d, 0x42, 0xf7, 0x21, 0x2e, 0xc5, 0xd0, 0x69, 0xdb, 0x4c, 0x44, 0x1d, 0x30,
|
||||
0xac, 0x6a, 0xba, 0x92, 0xdb, 0x56, 0x22, 0xea, 0x00, 0xfe, 0x19, 0xc0, 0x8a, 0xf2, 0x52, 0xc8,
|
||||
0x05, 0x6c, 0xa4, 0x2b, 0x44, 0xe5, 0x6b, 0xcb, 0x1e, 0xb0, 0x51, 0xe7, 0x52, 0x0a, 0xa9, 0xf2,
|
||||
0x8d, 0x53, 0x77, 0x08, 0x7f, 0x05, 0x38, 0x13, 0xf5, 0xad, 0xf5, 0x3b, 0x07, 0x25, 0x67, 0xad,
|
||||
0x2d, 0x67, 0x43, 0x3d, 0x42, 0xf7, 0x21, 0x2e, 0xc5, 0xd0, 0x69, 0x5b, 0x4c, 0x44, 0x1d, 0x30,
|
||||
0xac, 0x6a, 0xba, 0x92, 0xdb, 0x52, 0x22, 0xea, 0x00, 0xfe, 0x19, 0xc0, 0x8a, 0xf2, 0x52, 0xc8,
|
||||
0xea, 0x6f, 0xf3, 0xa2, 0xa9, 0x79, 0xaf, 0x61, 0xd3, 0x72, 0xcd, 0x2a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, 0xff,
|
||||
0x0e, 0x60, 0x69, 0xb0, 0xf9, 0xa0, 0x36, 0xcf, 0xbc, 0x92, 0x03, 0x5e, 0x3c, 0x1c, 0xc5, 0x8d,
|
||||
0xe7, 0x3d, 0x93, 0xdc, 0x9b, 0x9b, 0x50, 0x8f, 0x10, 0x82, 0x65, 0xc7, 0x5a, 0x67, 0x6e, 0x42,
|
||||
0xed, 0x79, 0x3a, 0x6f, 0xf1, 0x7c, 0xde, 0x0a, 0xd8, 0x54, 0x83, 0x64, 0xba, 0x11, 0x9d, 0x9f,
|
||||
0x95, 0x03, 0x46, 0xbb, 0x89, 0xd1, 0x6b, 0x9b, 0xf0, 0x3d, 0x9b, 0xf0, 0xbf, 0x6c, 0xfe, 0x2f,
|
||||
0x33, 0x4f, 0x7f, 0x04, 0x10, 0x7f, 0x30, 0x2b, 0x8d, 0x9e, 0x42, 0x74, 0x26, 0x6a, 0x74, 0x44,
|
||||
0x6e, 0x66, 0xaf, 0x58, 0xfb, 0x16, 0xe3, 0xc5, 0xab, 0x00, 0x3d, 0x87, 0x95, 0x5b, 0x61, 0x94,
|
||||
0x91, 0xd9, 0xda, 0x17, 0x77, 0xc8, 0x7c, 0xb7, 0xf1, 0x02, 0x6d, 0x21, 0xb6, 0xab, 0x89, 0x52,
|
||||
0x32, 0xdd, 0xe6, 0x22, 0x23, 0xb3, 0x8d, 0x75, 0x91, 0xb6, 0x5d, 0x28, 0x25, 0xd3, 0xb6, 0x16,
|
||||
0x19, 0x99, 0x75, 0x11, 0x2f, 0x2e, 0x56, 0xf6, 0xaf, 0xf3, 0xe6, 0x4f, 0x00, 0x00, 0x00, 0xff,
|
||||
0xff, 0xc7, 0x3f, 0xbe, 0xe3, 0xa7, 0x04, 0x00, 0x00,
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ var _ server.Option
|
||||
// Client API for Debug service
|
||||
|
||||
type DebugService interface {
|
||||
Log(ctx context.Context, in *LogRequest, opts ...client.CallOption) (Debug_LogService, error)
|
||||
Health(ctx context.Context, in *HealthRequest, opts ...client.CallOption) (*HealthResponse, error)
|
||||
Stats(ctx context.Context, in *StatsRequest, opts ...client.CallOption) (*StatsResponse, error)
|
||||
Log(ctx context.Context, in *LogRequest, opts ...client.CallOption) (Debug_LogService, error)
|
||||
Trace(ctx context.Context, in *TraceRequest, opts ...client.CallOption) (*TraceResponse, error)
|
||||
}
|
||||
|
||||
@ -46,18 +46,61 @@ type debugService struct {
|
||||
}
|
||||
|
||||
func NewDebugService(name string, c client.Client) DebugService {
|
||||
if c == nil {
|
||||
c = client.NewClient()
|
||||
}
|
||||
if len(name) == 0 {
|
||||
name = "debug"
|
||||
}
|
||||
return &debugService{
|
||||
c: c,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *debugService) Log(ctx context.Context, in *LogRequest, opts ...client.CallOption) (Debug_LogService, error) {
|
||||
req := c.c.NewRequest(c.name, "Debug.Log", &LogRequest{})
|
||||
stream, err := c.c.Stream(ctx, req, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := stream.Send(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &debugServiceLog{stream}, nil
|
||||
}
|
||||
|
||||
type Debug_LogService interface {
|
||||
Context() context.Context
|
||||
SendMsg(interface{}) error
|
||||
RecvMsg(interface{}) error
|
||||
Close() error
|
||||
Recv() (*Record, error)
|
||||
}
|
||||
|
||||
type debugServiceLog struct {
|
||||
stream client.Stream
|
||||
}
|
||||
|
||||
func (x *debugServiceLog) Close() error {
|
||||
return x.stream.Close()
|
||||
}
|
||||
|
||||
func (x *debugServiceLog) Context() context.Context {
|
||||
return x.stream.Context()
|
||||
}
|
||||
|
||||
func (x *debugServiceLog) SendMsg(m interface{}) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (x *debugServiceLog) RecvMsg(m interface{}) error {
|
||||
return x.stream.Recv(m)
|
||||
}
|
||||
|
||||
func (x *debugServiceLog) Recv() (*Record, error) {
|
||||
m := new(Record)
|
||||
err := x.stream.Recv(m)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (c *debugService) Health(ctx context.Context, in *HealthRequest, opts ...client.CallOption) (*HealthResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Debug.Health", in)
|
||||
out := new(HealthResponse)
|
||||
@ -78,50 +121,6 @@ func (c *debugService) Stats(ctx context.Context, in *StatsRequest, opts ...clie
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *debugService) Log(ctx context.Context, in *LogRequest, opts ...client.CallOption) (Debug_LogService, error) {
|
||||
req := c.c.NewRequest(c.name, "Debug.Log", &LogRequest{})
|
||||
stream, err := c.c.Stream(ctx, req, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := stream.Send(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &debugServiceLog{stream}, nil
|
||||
}
|
||||
|
||||
type Debug_LogService interface {
|
||||
SendMsg(interface{}) error
|
||||
RecvMsg(interface{}) error
|
||||
Close() error
|
||||
Recv() (*Record, error)
|
||||
}
|
||||
|
||||
type debugServiceLog struct {
|
||||
stream client.Stream
|
||||
}
|
||||
|
||||
func (x *debugServiceLog) Close() error {
|
||||
return x.stream.Close()
|
||||
}
|
||||
|
||||
func (x *debugServiceLog) SendMsg(m interface{}) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (x *debugServiceLog) RecvMsg(m interface{}) error {
|
||||
return x.stream.Recv(m)
|
||||
}
|
||||
|
||||
func (x *debugServiceLog) Recv() (*Record, error) {
|
||||
m := new(Record)
|
||||
err := x.stream.Recv(m)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (c *debugService) Trace(ctx context.Context, in *TraceRequest, opts ...client.CallOption) (*TraceResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Debug.Trace", in)
|
||||
out := new(TraceResponse)
|
||||
@ -135,17 +134,17 @@ func (c *debugService) Trace(ctx context.Context, in *TraceRequest, opts ...clie
|
||||
// Server API for Debug service
|
||||
|
||||
type DebugHandler interface {
|
||||
Log(context.Context, *LogRequest, Debug_LogStream) error
|
||||
Health(context.Context, *HealthRequest, *HealthResponse) error
|
||||
Stats(context.Context, *StatsRequest, *StatsResponse) error
|
||||
Log(context.Context, *LogRequest, Debug_LogStream) error
|
||||
Trace(context.Context, *TraceRequest, *TraceResponse) error
|
||||
}
|
||||
|
||||
func RegisterDebugHandler(s server.Server, hdlr DebugHandler, opts ...server.HandlerOption) error {
|
||||
type debug interface {
|
||||
Log(ctx context.Context, stream server.Stream) error
|
||||
Health(ctx context.Context, in *HealthRequest, out *HealthResponse) error
|
||||
Stats(ctx context.Context, in *StatsRequest, out *StatsResponse) error
|
||||
Log(ctx context.Context, stream server.Stream) error
|
||||
Trace(ctx context.Context, in *TraceRequest, out *TraceResponse) error
|
||||
}
|
||||
type Debug struct {
|
||||
@ -159,14 +158,6 @@ type debugHandler struct {
|
||||
DebugHandler
|
||||
}
|
||||
|
||||
func (h *debugHandler) Health(ctx context.Context, in *HealthRequest, out *HealthResponse) error {
|
||||
return h.DebugHandler.Health(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *debugHandler) Stats(ctx context.Context, in *StatsRequest, out *StatsResponse) error {
|
||||
return h.DebugHandler.Stats(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *debugHandler) Log(ctx context.Context, stream server.Stream) error {
|
||||
m := new(LogRequest)
|
||||
if err := stream.Recv(m); err != nil {
|
||||
@ -176,6 +167,7 @@ func (h *debugHandler) Log(ctx context.Context, stream server.Stream) error {
|
||||
}
|
||||
|
||||
type Debug_LogStream interface {
|
||||
Context() context.Context
|
||||
SendMsg(interface{}) error
|
||||
RecvMsg(interface{}) error
|
||||
Close() error
|
||||
@ -190,6 +182,10 @@ func (x *debugLogStream) Close() error {
|
||||
return x.stream.Close()
|
||||
}
|
||||
|
||||
func (x *debugLogStream) Context() context.Context {
|
||||
return x.stream.Context()
|
||||
}
|
||||
|
||||
func (x *debugLogStream) SendMsg(m interface{}) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
@ -202,6 +198,14 @@ func (x *debugLogStream) Send(m *Record) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (h *debugHandler) Health(ctx context.Context, in *HealthRequest, out *HealthResponse) error {
|
||||
return h.DebugHandler.Health(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *debugHandler) Stats(ctx context.Context, in *StatsRequest, out *StatsResponse) error {
|
||||
return h.DebugHandler.Stats(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *debugHandler) Trace(ctx context.Context, in *TraceRequest, out *TraceResponse) error {
|
||||
return h.DebugHandler.Trace(ctx, in, out)
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
syntax = "proto3";
|
||||
|
||||
service Debug {
|
||||
rpc Log(LogRequest) returns (stream Record) {};
|
||||
rpc Health(HealthRequest) returns (HealthResponse) {};
|
||||
rpc Stats(StatsRequest) returns (StatsResponse) {};
|
||||
rpc Log(LogRequest) returns (stream Record) {};
|
||||
rpc Trace(TraceRequest) returns (TraceResponse) {};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user