Documentation
¶
Overview ¶
Package go2sky implements a native Apache SkyWalking agent library for Go.
See http://skywalking.apache.org/ for more information about Apache SkyWalking.
Index ¶
- type NoopSpan
- func (*NoopSpan) End()
- func (*NoopSpan) Error(time.Time, ...string)
- func (*NoopSpan) Log(time.Time, ...string)
- func (*NoopSpan) SetComponent(int32)
- func (*NoopSpan) SetOperationName(string)
- func (*NoopSpan) SetPeer(string)
- func (*NoopSpan) SetSpanLayer(common.SpanLayer)
- func (*NoopSpan) Tag(Tag, string)
- type ReportedSpan
- type Reporter
- type SegmentContext
- type Span
- type SpanOption
- type SpanType
- type Tag
- type Tracer
- func (t *Tracer) CreateEntrySpan(ctx context.Context, operationName string, extractor propagation.Extractor) (s Span, nCtx context.Context, err error)
- func (t *Tracer) CreateExitSpan(ctx context.Context, operationName string, peer string, ...) (Span, error)
- func (t *Tracer) CreateLocalSpan(ctx context.Context, opts ...SpanOption) (s Span, c context.Context, err error)
- func (t *Tracer) WaitUntilRegister()
- type TracerOption
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NoopSpan ¶
type NoopSpan struct {
}
func (*NoopSpan) SetComponent ¶
func (*NoopSpan) SetOperationName ¶
func (*NoopSpan) SetSpanLayer ¶
type ReportedSpan ¶
type ReportedSpan interface {
Context() *SegmentContext
Refs() []*propagation.SpanContext
StartTime() int64
EndTime() int64
OperationName() string
Peer() string
SpanType() common.SpanType
SpanLayer() common.SpanLayer
IsError() bool
Tags() []*common.KeyStringValuePair
Logs() []*v2.Log
ComponentID() int32
}
ReportedSpan is accessed by Reporter to load reported data
type Reporter ¶
type Reporter interface {
Register(service string, instance string) (int32, int32, error)
Send(spans []ReportedSpan)
Close()
}
Reporter is a data transit specification
type SegmentContext ¶
type SegmentContext struct {
TraceID []int64
SegmentID []int64
SpanID int32
ParentSpanID int32
ParentSegmentID []int64
// contains filtered or unexported fields
}
SegmentContext is the context in a segment
type Span ¶
type Span interface {
SetOperationName(string)
SetPeer(string)
SetSpanLayer(common.SpanLayer)
SetComponent(int32)
Tag(Tag, string)
Log(time.Time, ...string)
Error(time.Time, ...string)
End()
}
Span interface as common span specification
type SpanOption ¶
type SpanOption func(s *defaultSpan)
SpanOption allows for functional options to adjust behaviour of a Span to be created by CreateLocalSpan
func WithContext ¶
func WithContext(sc *propagation.SpanContext) SpanOption
WithContext setup trace sc from propagation
func WithSpanType ¶
func WithSpanType(spanType SpanType) SpanOption
WithSpanType setup span type of a span
type Tag ¶
type Tag string
Tag are supported by sky-walking engine. As default, all Tags will be stored, but these ones have particular meanings.
const ( TagURL Tag = "url" TagStatusCode Tag = "status_code" TagHTTPMethod Tag = "http.method" TagDBType Tag = "db.type" TagDBInstance Tag = "db.instance" TagDBStatement Tag = "db.statement" TagDBBindVariables Tag = "db.bind_vars" TagMQQueue Tag = "mq.queue" TagMQBroker Tag = "mq.broker" TagMQTopic Tag = "mq.topic" )
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
Tracer is go2sky tracer implementation.
func NewTracer ¶
func NewTracer(service string, opts ...TracerOption) (tracer *Tracer, err error)
NewTracer return a new go2sky Tracer
Example ¶
package main
import (
"context"
"log"
"time"
"github.com/SkyAPM/go2sky"
"github.com/SkyAPM/go2sky/reporter"
)
func main() {
// Use gRPC reporter for production
r, err := reporter.NewLogReporter()
if err != nil {
log.Fatalf("new reporter error %v \n", err)
}
defer r.Close()
tracer, err := go2sky.NewTracer("example", go2sky.WithReporter(r))
if err != nil {
log.Fatalf("create tracer error %v \n", err)
}
// This for test
tracer.WaitUntilRegister()
span, ctx, err := tracer.CreateLocalSpan(context.Background())
if err != nil {
log.Fatalf("create new local span error %v \n", err)
}
span.SetOperationName("invoke data")
span.Tag("kind", "outer")
time.Sleep(time.Second)
subSpan, _, err := tracer.CreateLocalSpan(ctx)
if err != nil {
log.Fatalf("create new sub local span error %v \n", err)
}
subSpan.SetOperationName("invoke inner")
subSpan.Log(time.Now(), "inner", "this is right")
time.Sleep(time.Second)
subSpan.End()
time.Sleep(500 * time.Millisecond)
span.End()
time.Sleep(time.Second)
}
func (*Tracer) CreateEntrySpan ¶
func (t *Tracer) CreateEntrySpan(ctx context.Context, operationName string, extractor propagation.Extractor) (s Span, nCtx context.Context, err error)
CreateEntrySpan creates and starts an entry span for incoming request
func (*Tracer) CreateExitSpan ¶
func (t *Tracer) CreateExitSpan(ctx context.Context, operationName string, peer string, injector propagation.Injector) (Span, error)
CreateExitSpan creates and starts an exit span for client
func (*Tracer) CreateLocalSpan ¶
func (t *Tracer) CreateLocalSpan(ctx context.Context, opts ...SpanOption) (s Span, c context.Context, err error)
CreateLocalSpan creates and starts a span for local usage
func (*Tracer) WaitUntilRegister ¶
func (t *Tracer) WaitUntilRegister()
WaitUntilRegister is a tool helps user to wait until register process has finished
type TracerOption ¶
type TracerOption func(t *Tracer)
TracerOption allows for functional options to adjust behaviour of a Tracer to be created by NewTracer
func WithInstance ¶
func WithInstance(instance string) TracerOption
WithInstance setup instance identify
func WithReporter ¶
func WithReporter(reporter Reporter) TracerOption
WithReporter setup report pipeline for tracer
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
plugins
|
|
|
gin
Package Gin is a HTTP web framework written in Go (Golang) plugin which can be used for integration with Gin http server.
|
Package Gin is a HTTP web framework written in Go (Golang) plugin which can be used for integration with Gin http server. |
|
http
Package http contains several client/server http plugin which can be used for integration with net/http.
|
Package http contains several client/server http plugin which can be used for integration with net/http. |
|
Package propagation holds the required function signatures for Injection and Extraction.
|
Package propagation holds the required function signatures for Injection and Extraction. |
|
Package reporter holds reporters contain official reporter implementations.
|
Package reporter holds reporters contain official reporter implementations. |
|
grpc/language-agent-v2/mock_trace
Package mock_language_agent_v2 is a generated GoMock package.
|
Package mock_language_agent_v2 is a generated GoMock package. |
|
grpc/register/mock_register
Package mock_register is a generated GoMock package.
|
Package mock_register is a generated GoMock package. |