signalfx

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLogPathV1 is the default listener endpoint path
	DefaultLogPathV1 = "/v1/log"
	// JaegerV1 binary thrift protocol
	JaegerV1 = "jaeger_thrift_v1"
	// DefaultTracePathV1 is the default listen path
	DefaultTracePathV1 = "/v1/trace"
	// ZipkinTracePathV1 adds /api/v1/spans endpoint
	ZipkinTracePathV1 = "/api/v1/spans"
	// ZipkinTracePathV2 adds /api/vw/spans endpoint
	ZipkinTracePathV2 = "/api/v2/spans"
	// ZipkinV1 is a constant used for protocol naming
	ZipkinV1 = "zipkin_json_v1"
)
View Source
const TokenHeaderName = "X-SF-TOKEN"

TokenHeaderName is the header key for the auth token in the HTTP request

Variables

View Source
var (
	ClientKind   = "CLIENT"
	ServerKind   = "SERVER"
	ProducerKind = "PRODUCER"
	ConsumerKind = "CONSUMER"

	// ErrInvalidJaegerTraceFormat is an error returned when the payload cannot be parsed into jaeger thrift
	ErrInvalidJaegerTraceFormat = errors.New("invalid Jaeger format")
	// ErrUnableToReadRequest is an error returned when the request payload can't be read
	ErrUnableToReadRequest = errors.New("could not read request body")
)

Constants as variables so it is easy to get a pointer to them

View Source
var ErrInvalidJSONTraceFormat = errors.New("invalid JSON format; please see correct format at https://zipkin.io/zipkin-api/#/default/post_spans")

ErrInvalidJSONTraceFormat is returned when we are unable to decode the request payload into []signalfxformat.InputSpan

Functions

func NewDatumValue

func NewDatumValue(val sfxmodel.Datum) datapoint.Value

NewDatumValue creates new datapoint value referenced from a value of the datum protobuf

func NewProtobufDataPointWithType

func NewProtobufDataPointWithType(dp *sfxmodel.DataPoint, mType sfxmodel.MetricType) (*datapoint.Datapoint, error)

NewProtobufDataPointWithType creates a new datapoint from SignalFx's protobuf definition (backwards compatable with old API)

func NewProtobufEvent

func NewProtobufEvent(e *sfxmodel.Event) (*event.Event, error)

NewProtobufEvent creates a new event from SignalFx's protobuf definition

func ParseJaegerSpansFromRequest added in v0.0.10

func ParseJaegerSpansFromRequest(req *http.Request) ([]*jaegerpb.Span, error)

ParseJaegerSpansFromRequest parses a signalfx, zipkinV1, or zipkinV2 json request into an array of jaeger spans.

func PropertyAsRawType

func PropertyAsRawType(p *sfxmodel.PropertyValue) interface{}

PropertyAsRawType converts a protobuf property to a native Go type

func SetupChain

func SetupChain(ctx context.Context, sink Sink, chainType string, getReader func(Sink) ErrorReader, httpChain web.NextConstructor, logger log.Logger, counter *dpsink.Counter, moreConstructors ...web.Constructor) (http.Handler, sfxclient.Collector)

SetupChain wraps the reader returned by getReader in an http.Handler along with some middleware that calculates internal metrics about requests.

func SetupJSONByPaths

func SetupJSONByPaths(r *mux.Router, handler http.Handler, endpoint string)

SetupJSONByPaths tells the router which paths the given handler (which should handle the given endpoint) should see

func SetupJSONByPathsN

func SetupJSONByPathsN(r *mux.Router, handler http.Handler, endpoints ...string)

SetupJSONByPathsN tells the router which paths the given handler (which should handle the given endpoint) should see

func SetupJSONV1Paths

func SetupJSONV1Paths(r *mux.Router, handler http.Handler)

SetupJSONV1Paths routes to R paths that should handle V1 JSON datapoints

func SetupJSONV2DatapointPaths

func SetupJSONV2DatapointPaths(r *mux.Router, handler http.Handler)

SetupJSONV2DatapointPaths tells the router which paths the given handler (which should handle v2 protobufs)

func SetupJSONV2EventPaths

func SetupJSONV2EventPaths(r *mux.Router, handler http.Handler)

SetupJSONV2EventPaths tells the router which paths the given handler (which should handle v2 protobufs)

func SetupProtobufV1Paths

func SetupProtobufV1Paths(r *mux.Router, handler http.Handler)

SetupProtobufV1Paths routes to R paths that should handle V1 Protobuf datapoints

func SetupProtobufV2ByPaths

func SetupProtobufV2ByPaths(r *mux.Router, handler http.Handler, path string)

SetupProtobufV2ByPaths tells the router which paths the given handler (which should handle v2 protobufs)

func SetupProtobufV2DatapointPaths

func SetupProtobufV2DatapointPaths(r *mux.Router, handler http.Handler)

SetupProtobufV2DatapointPaths tells the router which paths the given handler (which should handle v2 protobufs)

func SetupProtobufV2EventPaths

func SetupProtobufV2EventPaths(r *mux.Router, handler http.Handler)

SetupProtobufV2EventPaths tells the router which paths the given handler (which should handle v2 protobufs)

func SetupThriftByPaths

func SetupThriftByPaths(r *mux.Router, handler http.Handler, endpoint string)

SetupThriftByPaths tells the router which paths the given handler (which should handle the given endpoint) should see

func ValueToValue

func ValueToValue(v ValueToSend) (datapoint.Value, error)

ValueToValue converts the v2 JSON value to a core api Value

Types

type BodySendFormatV2

type BodySendFormatV2 signalfxformat.BodySendFormatV2

BodySendFormatV2 is an alias

type ErrorReader

type ErrorReader interface {
	Read(ctx context.Context, req *http.Request) error
}

ErrorReader are datapoint streamers that read from a HTTP request and return errors if the stream is invalid

type ErrorTrackerHandler

type ErrorTrackerHandler struct {
	TotalErrors int64

	Logger log.Logger
	// contains filtered or unexported fields
}

ErrorTrackerHandler behaves like a http handler, but tracks error returns from a ErrorReader

func (*ErrorTrackerHandler) Datapoints

func (e *ErrorTrackerHandler) Datapoints() []*datapoint.Datapoint

Datapoints gets TotalErrors stats

func (*ErrorTrackerHandler) ServeHTTPC

func (e *ErrorTrackerHandler) ServeHTTPC(ctx context.Context, rw http.ResponseWriter, req *http.Request)

ServeHTTPC will serve the wrapped ErrorReader and return the error (if any) to rw if ErrorReader fails

type Forwarder

type Forwarder struct {
	filtering.FilteredForwarder

	Logger log.Logger
	// contains filtered or unexported fields
}

Forwarder controls forwarding datapoints to SignalFx

func NewForwarder

func NewForwarder(conf *ForwarderConfig) (ret *Forwarder, err error)

NewForwarder creates a new JSON forwarder

func (*Forwarder) AddDatapoints

func (connector *Forwarder) AddDatapoints(ctx context.Context, datapoints []*datapoint.Datapoint) error

AddDatapoints forwards datapoints to SignalFx

func (*Forwarder) AddEvents

func (connector *Forwarder) AddEvents(ctx context.Context, events []*event.Event) error

AddEvents forwards events to SignalFx

func (*Forwarder) AddSpans

func (connector *Forwarder) AddSpans(ctx context.Context, spans []*trace.Span) error

AddSpans forwards traces to SignalFx

func (*Forwarder) Close

func (connector *Forwarder) Close() error

Close will terminate idle HTTP client connections

func (*Forwarder) Datapoints

func (connector *Forwarder) Datapoints() []*datapoint.Datapoint

Datapoints implements the sfxclient.Collector interface and returns all datapoints

func (*Forwarder) DebugDatapoints

func (connector *Forwarder) DebugDatapoints() []*datapoint.Datapoint

DebugDatapoints returns datapoints that are used for debugging

func (*Forwarder) DebugEndpoints

func (connector *Forwarder) DebugEndpoints() map[string]http.Handler

DebugEndpoints returns the httphandlers of the sampler

func (*Forwarder) DefaultDatapoints

func (connector *Forwarder) DefaultDatapoints() []*datapoint.Datapoint

DefaultDatapoints returns a set of default datapoints about the forwarder

func (*Forwarder) Pipeline

func (connector *Forwarder) Pipeline() int64

Pipeline returns the total of all things forwarded

func (*Forwarder) StartupFinished

func (connector *Forwarder) StartupFinished() error

StartupFinished calls nothing

type ForwarderConfig

type ForwarderConfig struct {
	Filters            *filtering.FilterObj
	DatapointURL       *string
	EventURL           *string
	TraceURL           *string
	Timeout            *time.Duration
	SourceDimensions   *string
	GatewayVersion     *string
	MaxIdleConns       *int64
	AuthToken          *string
	ProtoMarshal       func(pb proto.Message) ([]byte, error)
	JSONMarshal        func(v interface{}) ([]byte, error)
	Logger             log.Logger
	DisableCompression *bool
}

ForwarderConfig controls optional parameters for a signalfx forwarder

type InputSpan

type InputSpan signalfxformat.InputSpan

InputSpan is an alias

func (*InputSpan) JaegerFromZipkinV2

func (is *InputSpan) JaegerFromZipkinV2(sm *spanfilter.Map) *jaegerpb.Span

JaegerFromZipkinV2 shortcuts the span conversion process and treats the InputSpan as ZipkinV2 and returns that span directly as SAPM.

type JSONDatapointV1

type JSONDatapointV1 signalfxformat.JSONDatapointV1

JSONDatapointV1 is an alias

type JSONDatapointV2

type JSONDatapointV2 signalfxformat.JSONDatapointV2

JSONDatapointV2 is an alias

type JSONDecoderV1

type JSONDecoderV1 struct {
	TypeGetter MericTypeGetter
	Sink       dpsink.DSink
	Logger     log.Logger
}

JSONDecoderV1 creates datapoints out of the v1 JSON definition

func (*JSONDecoderV1) Read

func (decoder *JSONDecoderV1) Read(ctx context.Context, req *http.Request) error

type JSONDecoderV2

type JSONDecoderV2 struct {
	Sink   dpsink.Sink
	Logger log.Logger
	// contains filtered or unexported fields
}

JSONDecoderV2 decodes v2 json data for signalfx and sends it to Sink

func (*JSONDecoderV2) Datapoints

func (decoder *JSONDecoderV2) Datapoints() []*datapoint.Datapoint

Datapoints returns datapoints for json decoder v2

func (*JSONDecoderV2) Read

func (decoder *JSONDecoderV2) Read(ctx context.Context, req *http.Request) error

type JSONEventDecoderV2

type JSONEventDecoderV2 struct {
	Sink   dpsink.ESink
	Logger log.Logger
}

JSONEventDecoderV2 decodes v2 json data for signalfx events and sends it to Sink

func (*JSONEventDecoderV2) Read

func (decoder *JSONEventDecoderV2) Read(ctx context.Context, req *http.Request) error

type JSONTraceDecoderV1

type JSONTraceDecoderV1 struct {
	Logger log.Logger
	Sink   trace.Sink
}

JSONTraceDecoderV1 decodes json to structs

func (*JSONTraceDecoderV1) Read

func (decoder *JSONTraceDecoderV1) Read(ctx context.Context, req *http.Request) error

Read the data off the wire in json format

type JaegerThriftDecoderBase added in v0.0.3

type JaegerThriftDecoderBase struct {
	// contains filtered or unexported fields
}

JaegerThriftDecoderBase is the base of other JaegerThriftDecoders. It decodes an http request into jaeger thrift

func NewJaegerThriftDecoderBase added in v0.0.3

func NewJaegerThriftDecoderBase() *JaegerThriftDecoderBase

NewJaegerThriftDecoderBase returns a new JaegerThriftDecoderBase

func (*JaegerThriftDecoderBase) Read added in v0.0.3

Read reads an http request, decodes the jaeger thrift payload and returns it Code inspired by https://github.com/jaegertracing/jaeger/blob/89f3ccaef21d256728f02ec9d73b31f9c3bde71a/cmd/collector/app/http_handler.go#L61

type JaegerThriftToSAPMDecoder added in v0.0.3

type JaegerThriftToSAPMDecoder struct {
	*JaegerThriftDecoderBase
}

JaegerThriftToSAPMDecoder reads an jaeger thrift http.Request and parses it's body into a splunksapm.PostSpansRequest

func NewJaegerThriftToSAPMDecoder added in v0.0.3

func NewJaegerThriftToSAPMDecoder() *JaegerThriftToSAPMDecoder

NewJaegerThriftToSAPMDecoder returns a new JaegerThriftToSAPMDecoder

func (*JaegerThriftToSAPMDecoder) Read added in v0.0.3

Read reads an http request with a jaeger thrift payload and decodes it into SAPM

type JaegerThriftTraceDecoderV1

type JaegerThriftTraceDecoderV1 struct {
	*JaegerThriftDecoderBase
	Logger log.Logger
	Sink   trace.Sink
}

JaegerThriftTraceDecoderV1 decodes Jaeger thrift spans to structs

func NewJaegerThriftTraceDecoderV1

func NewJaegerThriftTraceDecoderV1(logger log.Logger, sink trace.Sink) *JaegerThriftTraceDecoderV1

NewJaegerThriftTraceDecoderV1 creates a new decoder for Jaeger Thrift spans

func (*JaegerThriftTraceDecoderV1) Read

func (decoder *JaegerThriftTraceDecoderV1) Read(ctx context.Context, req *http.Request) error

Read reads an http request, decodes the jaeger thrift payload, and pushes the payload into the Sink Code inspired by https://github.com/jaegertracing/jaeger/blob/89f3ccaef21d256728f02ec9d73b31f9c3bde71a/cmd/collector/app/http_handler.go#L61

type ListenerConfig

type ListenerConfig struct {
	ListenAddr                         *string
	HealthCheck                        *string
	Timeout                            *time.Duration
	Logger                             log.Logger
	RootContext                        context.Context
	JSONMarshal                        func(v interface{}) ([]byte, error)
	DebugContext                       *web.HeaderCtxFlag
	HTTPChain                          web.NextConstructor
	SpanNameReplacementRules           []string
	SpanNameReplacementBreakAfterMatch *bool
	AdditionalSpanTags                 map[string]string
	RemoveSpanTags                     []*spanobfuscation.TagMatchRuleConfig
	ObfuscateSpanTags                  []*spanobfuscation.TagMatchRuleConfig
	Counter                            *dpsink.Counter
}

ListenerConfig controls optional parameters for the listener

type ListenerServer

type ListenerServer struct {
	protocol.CloseableHealthCheck
	// contains filtered or unexported fields
}

ListenerServer controls listening on a socket for SignalFx connections

func NewListener

func NewListener(sink Sink, conf *ListenerConfig) (*ListenerServer, error)

NewListener servers http requests for Signalfx datapoints

func (*ListenerServer) Addr

func (streamer *ListenerServer) Addr() net.Addr

Addr returns the currently listening address

func (*ListenerServer) Close

func (streamer *ListenerServer) Close() error

Close the exposed socket listening for new connections

func (*ListenerServer) Datapoints

func (streamer *ListenerServer) Datapoints() []*datapoint.Datapoint

Datapoints returns the datapoints about various internal endpoints

func (*ListenerServer) DebugDatapoints

func (streamer *ListenerServer) DebugDatapoints() []*datapoint.Datapoint

DebugDatapoints returns datapoints that are used for debugging the listener

func (*ListenerServer) DefaultDatapoints

func (streamer *ListenerServer) DefaultDatapoints() []*datapoint.Datapoint

DefaultDatapoints returns datapoints that should always be reported from the listener

type LogProtocol added in v0.0.5

type LogProtocol string

LogProtocol is the context type used to set what is the log protocol

const (
	// HECV1Protocol is used to set LogProtocol value when the incoming data is hecv1
	HECV1Protocol LogProtocol = "hecv1"
	// LogProtocolType is used to set log protocol type
	LogProtocolType LogProtocol = "protocol"
)

type MericTypeGetter

type MericTypeGetter interface {
	GetMetricTypeFromMap(metricName string) sfxmodel.MetricType
}

MericTypeGetter is an old metric interface that returns the type of a metric name

type MetricCreationResponse

type MetricCreationResponse struct {
	Code    int    `json:"code,omitempty"`
	Error   bool   `json:"error,omitempty"`
	Message string `json:"message,omitempty"`
}

MetricCreationResponse is the API response for /v1/metric POST

type MetricCreationStruct

type MetricCreationStruct struct {
	MetricName string `json:"sf_metric"`
	MetricType string `json:"sf_metricType"`
}

MetricCreationStruct is the API format for /v1/metric POST

type MiddlewareConstructor

type MiddlewareConstructor func(sendTo Sink) Sink

A MiddlewareConstructor is used by FromChain to chain together a bunch of sinks that forward to each other

func NextWrap

func NextWrap(wrapping NextSink) MiddlewareConstructor

NextWrap wraps a NextSink to make it usable by MiddlewareConstructor

type NextSink

type NextSink interface {
	AddDatapoints(ctx context.Context, points []*datapoint.Datapoint, next Sink) error
	AddEvents(ctx context.Context, events []*event.Event, next Sink) error
	AddSpans(ctx context.Context, spans []*trace.Span, next Sink) error
}

NextSink is a special case of a sink that forwards to another sink

func UnifyNextSinkWrap

func UnifyNextSinkWrap(s almostNextSink) NextSink

UnifyNextSinkWrap converts the combination of a dpsink.NextSink and a trace.NextSink into a signalfx.NextSink

type ProtobufDecoderV1

type ProtobufDecoderV1 struct {
	Sink       dpsink.DSink
	TypeGetter MericTypeGetter
	Logger     log.Logger
}

ProtobufDecoderV1 creates datapoints out of the V1 protobuf definition

func (*ProtobufDecoderV1) Read

func (decoder *ProtobufDecoderV1) Read(ctx context.Context, req *http.Request) error

type ProtobufDecoderV2

type ProtobufDecoderV2 struct {
	Sink   dpsink.Sink
	Logger log.Logger
}

ProtobufDecoderV2 decodes protocol buffers in signalfx's v2 format and sends them to Sink

func (*ProtobufDecoderV2) Read

func (decoder *ProtobufDecoderV2) Read(ctx context.Context, req *http.Request) (err error)

type ProtobufEventDecoderV2

type ProtobufEventDecoderV2 struct {
	Sink   dpsink.ESink
	Logger log.Logger
}

ProtobufEventDecoderV2 decodes protocol buffers in signalfx's v2 format and sends them to Sink

func (*ProtobufEventDecoderV2) Read

func (decoder *ProtobufEventDecoderV2) Read(ctx context.Context, req *http.Request) (err error)

type Sink

type Sink interface {
	dpsink.Sink
	trace.Sink
}

Sink is a dpsink and trace.sink

func FromChain

func FromChain(endSink Sink, sinks ...MiddlewareConstructor) Sink

FromChain creates an endpoint Sink that sends calls between multiple middlewares for things like counting points in between.

func IncludingDimensions

func IncludingDimensions(dims map[string]string, sink Sink) Sink

IncludingDimensions returns a sink that wraps another sink adding dims to each datapoint and event

type ValueToSend

type ValueToSend signalfxformat.ValueToSend

ValueToSend is an alias

type WithDimensions

type WithDimensions struct {
	Dimensions map[string]string
}

WithDimensions adds dimensions on top of the datapoints of a collector

func (*WithDimensions) AddDatapoints

func (w *WithDimensions) AddDatapoints(ctx context.Context, points []*datapoint.Datapoint, next Sink) error

AddDatapoints calls next() including the wrapped dimensions on each point

func (*WithDimensions) AddEvents

func (w *WithDimensions) AddEvents(ctx context.Context, events []*event.Event, next Sink) error

AddEvents calls next() including the wrapped dimensions on each event

func (*WithDimensions) AddSpans

func (w *WithDimensions) AddSpans(ctx context.Context, spans []*trace.Span, next Sink) error

AddSpans calls next() is a pass-through

Directories

Path Synopsis
log

Jump to

Keyboard shortcuts

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