tracer

package
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

README

DM tracer server

Introduction

DM tracer server is used for tracing events collect, query and manage.

HTTP API doc

TracerIP is the ip of the DM tracer server. 8263 is the default status port, and you can edit it in dm-tracer.toml when starting the DM tracer server.

  1. Get the current status of tracer server, including the version and git_hash

    curl http://{TracerIP}:8263/status
    
    $curl http://127.0.0.1:8263/status
    {
        "version":"v1.0.0-alpha-46-g12b9422",
        "git_hash":"12b94225f45f69a58efd441ba0876f8f08e354f1"
    }
    
  2. Query tracing event bundle by traceID

    curl http://{TracerIP}:8263/events/query?trace_id={trace_id}
    
    curl http://127.0.0.1:8263/events/query?trace_id=mysql-replica-01.syncer.test.1
    [
        {
            "type": 1,
            "event": {
                "base": {
                    "filename": "/root/code/gopath/src/github.com/pingcap/dm/syncer/syncer.go",
                    "line": 1130,
                    "tso": 1552371525597270410,
                    "traceID": "mysql-replica-01.syncer.test.1",
                    "type": 1
                },
                "state": {
                    "safeMode": true,
                    "tryReSync": true,
                    "lastPos": {
                    "name": "bin|000001.000004",
                    "pos": 68073
                    }
                },
                "eventType": 4,
                "opType": 8,
                "currentPos": {
                    "name": "bin|000001.000004",
                    "pos": 68073
                }
            }
        },
        {
            ...
        },
        {
            ...
        }
    ]
    
  3. Delete tracing event bundle by traceID

    curl http://{TracerIP}:8263/events/delete?trace_id={trace_id}
    
    curl http://127.0.0.1:8263/events/delete?trace_id=mysql-replica-01.syncer.test.1
    
    {
        "trace_id": "mysql-replica-01.syncer.test.1",
        "result": true
    }
    
  4. Scan tracing event based on offset and limit

    curl http://{TracerIP}:8263/events/scan?offset=1&limit=3
    [
      [
        {...},
        {...}
      ],
      [
        {...}
      ],
      [
        {...},
        {...},
        {...}
      ]
    ]
    

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	LogLevel   string `toml:"log-level" json:"log-level"`
	LogFile    string `toml:"log-file" json:"log-file"`
	TracerAddr string `toml:"tracer-addr" json:"tracer-addr"`
	Enable     bool   `toml:"enable" json:"enable"`
	Checksum   bool   `toml:"checksum" json:"checksum"`

	ConfigFile string `json:"config-file"`
	// contains filtered or unexported fields
}

Config is the configuration.

func NewConfig

func NewConfig() *Config

NewConfig creates a new base config for tracer.

func (*Config) Parse

func (c *Config) Parse(arguments []string) error

Parse parses flag definitions from the argument list.

func (*Config) String

func (c *Config) String() string

String returns format string of Config

type EventStore

type EventStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

EventStore stores all tracing events, mapping from TraceID -> a list of TraceEvent TraceEvents with the same TraceID can have different TraceType NOTE: this is a quick and dirty implement, we will refactor it later

func NewEventStore

func NewEventStore() *EventStore

NewEventStore creates a new EventStore

type Server

type Server struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Server accepts tracing RPC requests and sends RPC responses back

func NewServer

func NewServer(cfg *Config) *Server

NewServer creates a new Server

func (*Server) Close

func (s *Server) Close()

Close close the RPC server

func (*Server) GetTSO

func (s *Server) GetTSO(ctx context.Context, req *pb.GetTSORequest) (*pb.GetTSOResponse, error)

GetTSO implements TracerServer.GetTSO

func (*Server) Start

func (s *Server) Start() error

Start starts to serving

func (*Server) UploadSyncerBinlogEvent

func (s *Server) UploadSyncerBinlogEvent(ctx context.Context, req *pb.UploadSyncerBinlogEventRequest) (*pb.CommonUploadResponse, error)

UploadSyncerBinlogEvent implements TracerServer.UploadSyncerBinlogEvent

func (*Server) UploadSyncerJobEvent

func (s *Server) UploadSyncerJobEvent(ctx context.Context, req *pb.UploadSyncerJobEventRequest) (*pb.CommonUploadResponse, error)

UploadSyncerJobEvent implements TracerServer.UploadSyncerJobEvent

type TraceEvent

type TraceEvent struct {
	Type  pb.TraceType `json:"type"`
	Event interface{}  `json:"event"`
}

TraceEvent represents a sigle tracing event

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL