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 ¶
- Constants
- func GetCorrelation(ctx context.Context, key string) string
- func PutCorrelation(ctx context.Context, key, value string) bool
- func ServiceInstanceName(ctx context.Context) string
- func ServiceName(ctx context.Context) string
- func SetGlobalTracer(tracer *Tracer)
- func SpanID(ctx context.Context) int32
- func TraceID(ctx context.Context) string
- func TraceSegmentID(ctx context.Context) string
- func WithSpan(ctx context.Context, span Span) context.Context
- type AgentConfigChangeWatcher
- type AgentConfigEventType
- type ConfigDiscoveryService
- type ConstSampler
- type CorrelationConfig
- type DynamicSampler
- type NoopSpan
- func (*NoopSpan) End()
- func (*NoopSpan) Error(time.Time, ...string)
- func (*NoopSpan) GetOperationName() string
- func (*NoopSpan) IsEntry() bool
- func (*NoopSpan) IsExit() bool
- func (*NoopSpan) IsValid() bool
- func (*NoopSpan) Log(time.Time, ...string)
- func (*NoopSpan) SetComponent(int32)
- func (*NoopSpan) SetOperationName(string)
- func (*NoopSpan) SetPeer(string)
- func (*NoopSpan) SetSpanLayer(agentv3.SpanLayer)
- func (*NoopSpan) Tag(Tag, string)
- type RandomSampler
- type ReportedSpan
- type Reporter
- type Sampler
- 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, ...) (s Span, err error)
- func (t *Tracer) CreateExitSpanWithContext(ctx context.Context, operationName string, peer string, ...) (s Span, nCtx context.Context, err error)
- func (t *Tracer) CreateLocalSpan(ctx context.Context, opts ...SpanOption) (s Span, c context.Context, err error)
- type TracerOption
Examples ¶
Constants ¶
const ( EmptyServiceName = "" EmptyServiceInstanceName = "" EmptyTraceID = "N/A" EmptyTraceSegmentID = "N/A" EmptySpanID = -1 )
const (
ComponentIDHttpServer int32 = 49
)
Variables ¶
This section is empty.
Functions ¶
func PutCorrelation ¶ added in v1.0.0
func ServiceInstanceName ¶ added in v1.1.0
func ServiceName ¶ added in v1.1.0
func SetGlobalTracer ¶ added in v1.4.0
func SetGlobalTracer(tracer *Tracer)
SetGlobalTracer registers `tracer` as the global Tracer.
func TraceSegmentID ¶ added in v1.1.0
Types ¶
type AgentConfigChangeWatcher ¶ added in v1.1.0
type AgentConfigChangeWatcher interface {
Key() string
Notify(eventType AgentConfigEventType, newValue string)
Value() string
}
type AgentConfigEventType ¶ added in v1.1.0
type AgentConfigEventType int32
const ( MODIFY AgentConfigEventType = iota DELETED )
type ConfigDiscoveryService ¶ added in v1.1.0
type ConfigDiscoveryService struct {
UUID string
// contains filtered or unexported fields
}
func NewConfigDiscoveryService ¶ added in v1.1.0
func NewConfigDiscoveryService() *ConfigDiscoveryService
func (*ConfigDiscoveryService) BindWatchers ¶ added in v1.1.0
func (s *ConfigDiscoveryService) BindWatchers(watchers []AgentConfigChangeWatcher)
func (*ConfigDiscoveryService) HandleCommand ¶ added in v1.1.0
func (s *ConfigDiscoveryService) HandleCommand(command *common.Command)
type ConstSampler ¶ added in v0.6.0
type ConstSampler struct {
// contains filtered or unexported fields
}
func NewConstSampler ¶ added in v0.6.0
func NewConstSampler(sample bool) *ConstSampler
NewConstSampler creates a ConstSampler.
func (*ConstSampler) IsSampled ¶ added in v0.6.0
func (s *ConstSampler) IsSampled(operation string) bool
IsSampled implements IsSampled() of Sampler.
type CorrelationConfig ¶ added in v1.0.0
type DynamicSampler ¶ added in v1.1.0
type DynamicSampler struct {
// contains filtered or unexported fields
}
func NewDynamicSampler ¶ added in v1.1.0
func NewDynamicSampler(samplingRate float64, tracer *Tracer) *DynamicSampler
func (*DynamicSampler) IsSampled ¶ added in v1.1.0
func (s *DynamicSampler) IsSampled(operation string) bool
IsSampled implements IsSampled() of Sampler.
func (*DynamicSampler) Key ¶ added in v1.1.0
func (s *DynamicSampler) Key() string
func (*DynamicSampler) Notify ¶ added in v1.1.0
func (s *DynamicSampler) Notify(eventType AgentConfigEventType, newValue string)
func (*DynamicSampler) Value ¶ added in v1.1.0
func (s *DynamicSampler) Value() string
type NoopSpan ¶
type NoopSpan struct {
}
func (*NoopSpan) GetOperationName ¶ added in v0.3.0
func (*NoopSpan) SetComponent ¶
func (*NoopSpan) SetOperationName ¶
func (*NoopSpan) SetSpanLayer ¶
type RandomSampler ¶ added in v0.6.0
type RandomSampler struct {
// contains filtered or unexported fields
}
RandomSampler Use sync.Pool to implement concurrent-safe for randomizer.
func NewRandomSampler ¶ added in v0.6.0
func NewRandomSampler(samplingRate float64) *RandomSampler
func (*RandomSampler) IsSampled ¶ added in v0.6.0
func (s *RandomSampler) IsSampled(operation string) bool
IsSampled implements IsSampled() of Sampler.
type ReportedSpan ¶
type ReportedSpan interface {
Context() *SegmentContext
Refs() []*propagation.SpanContext
StartTime() int64
EndTime() int64
OperationName() string
Peer() string
SpanType() agentv3.SpanType
SpanLayer() agentv3.SpanLayer
IsError() bool
Tags() []*commonv3.KeyStringValuePair
Logs() []*agentv3.Log
ComponentID() int32
}
ReportedSpan is accessed by Reporter to load reported data
type Reporter ¶
type Reporter interface {
Boot(service string, serviceInstance string, cdsWatchers []AgentConfigChangeWatcher)
Send(spans []ReportedSpan)
Close()
}
Reporter is a data transit specification
type SegmentContext ¶
type SegmentContext struct {
TraceID string
SegmentID string
SpanID int32
ParentSpanID int32
ParentSegmentID string
FirstSpan Span `json:"-"`
CorrelationContext map[string]string
// contains filtered or unexported fields
}
SegmentContext is the context in a segment
type Span ¶
type Span interface {
SetOperationName(string)
GetOperationName() string
SetPeer(string)
SetSpanLayer(agentv3.SpanLayer)
SetComponent(int32)
Tag(Tag, string)
Log(time.Time, ...string)
Error(time.Time, ...string)
End()
IsEntry() bool
IsExit() bool
IsValid() bool
}
Span interface as commonv3 span specification
func ActiveSpan ¶ added in v1.4.0
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 WithOperationName ¶ added in v0.6.0
func WithOperationName(operationName string) SpanOption
WithOperationName setup span OperationName of a span
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" TagDBSqlParameters Tag = "db.sql.parameters" 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 GetGlobalTracer ¶ added in v1.4.0
func GetGlobalTracer() *Tracer
GetGlobalTracer returns the registered global Tracer. If none is registered then an instance of `nil` is returned.
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
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) (s Span, err error)
CreateExitSpan creates and starts an exit span for client
func (*Tracer) CreateExitSpanWithContext ¶ added in v1.2.0
func (t *Tracer) CreateExitSpanWithContext(ctx context.Context, operationName string, peer string, injector propagation.Injector) (s Span, nCtx context.Context, err error)
CreateExitSpanWithContext creates and starts an exit span for client with context
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
type TracerOption ¶
type TracerOption func(t *Tracer)
TracerOption allows for functional options to adjust behaviour of a Tracer to be created by NewTracer
func WithCorrelation ¶ added in v1.0.0
func WithCorrelation(keyCount, valueSize int) TracerOption
func WithCustomSampler ¶ added in v1.0.0
func WithCustomSampler(sampler Sampler) TracerOption
WithCustomSampler setup custom sampler
func WithInstance ¶
func WithInstance(instance string) TracerOption
WithInstance setup instance identify
func WithReporter ¶
func WithReporter(reporter Reporter) TracerOption
WithReporter setup report pipeline for tracer
func WithSampler ¶ added in v0.6.0
func WithSampler(samplingRate float64) TracerOption
WithSampler setup sampler
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
Package log help to build trace context data into log plugins.
|
Package log help to build trace context data into log plugins. |
|
plugins
|
|
|
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. |
|
http/test/client
command
|
|
|
http/test/server
command
|
|
|
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/mock_trace
Package mock_v3 is a generated GoMock package.
|
Package mock_v3 is a generated GoMock package. |
|
grpc/management/mock_management
Package mock_v3 is a generated GoMock package.
|
Package mock_v3 is a generated GoMock package. |
|
test
|
|
|
e2e/example-server
command
|