Documentation ¶
Overview ¶
© 2023 SolarWinds Worldwide, LLC. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
© 2023 SolarWinds Worldwide, LLC. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func DefaultBackoff(retries int, wait func(d time.Duration)) error
- func ParseInt32(args map[string][]byte, key string, fb int32) int32
- func SQLSanitize(dbType string, sql string) string
- type Backoff
- type BucketOption
- type BytesBucket
- type DefaultDialer
- type DialParams
- type Dialer
- type Event
- func CreateEntryEvent(ctx trace.SpanContext, t time.Time, parent trace.SpanContext) Event
- func CreateExceptionEvent(ctx trace.SpanContext, t time.Time) Event
- func CreateExitEvent(ctx trace.SpanContext, t time.Time) Event
- func CreateInfoEvent(ctx trace.SpanContext, t time.Time) Event
- func CreateInitMessage(tid trace.TraceID, r *resource.Resource) Event
- func EventFromOtelEvent(ctx trace.SpanContext, evt sdktrace.Event) Event
- func NewEvent(tid trace.TraceID, oid opID, t time.Time) Event
- func NewEventWithRandomOpID(tid trace.TraceID, t time.Time) Event
- type FSMState
- type FlushWriter
- type GetSettingsMethod
- func (gs *GetSettingsMethod) Arg() string
- func (gs *GetSettingsMethod) Call(ctx context.Context, c collector.TraceCollectorClient) error
- func (gs *GetSettingsMethod) CallSummary() string
- func (gs *GetSettingsMethod) Message() [][]byte
- func (gs *GetSettingsMethod) MessageLen() int64
- func (gs *GetSettingsMethod) RequestSize() int64
- func (gs *GetSettingsMethod) ResultCode() (collector.ResultCode, error)
- func (gs *GetSettingsMethod) RetryOnErr(err error) bool
- func (gs *GetSettingsMethod) ServiceKey() string
- func (gs *GetSettingsMethod) String() string
- type GrpcConnOpt
- type Label
- type LogData
- type Method
- type PingMethod
- func (p *PingMethod) Arg() string
- func (p *PingMethod) Call(ctx context.Context, c collector.TraceCollectorClient) error
- func (p *PingMethod) CallSummary() string
- func (p *PingMethod) Message() [][]byte
- func (p *PingMethod) MessageLen() int64
- func (p *PingMethod) RequestSize() int64
- func (p *PingMethod) ResultCode() (collector.ResultCode, error)
- func (p *PingMethod) RetryOnErr(err error) bool
- func (p *PingMethod) ServiceKey() string
- func (p *PingMethod) String() string
- type PostEventsMethod
- func (pe *PostEventsMethod) Arg() string
- func (pe *PostEventsMethod) Call(ctx context.Context, c collector.TraceCollectorClient) error
- func (pe *PostEventsMethod) CallSummary() string
- func (pe *PostEventsMethod) Message() [][]byte
- func (pe *PostEventsMethod) MessageLen() int64
- func (pe *PostEventsMethod) RequestSize() int64
- func (pe *PostEventsMethod) ResultCode() (collector.ResultCode, error)
- func (pe *PostEventsMethod) RetryOnErr(err error) bool
- func (pe *PostEventsMethod) ServiceKey() string
- func (pe *PostEventsMethod) String() string
- type PostMetricsMethod
- func (pm *PostMetricsMethod) Arg() string
- func (pm *PostMetricsMethod) Call(ctx context.Context, c collector.TraceCollectorClient) error
- func (pm *PostMetricsMethod) CallSummary() string
- func (pm *PostMetricsMethod) Message() [][]byte
- func (pm *PostMetricsMethod) MessageLen() int64
- func (pm *PostMetricsMethod) RequestSize() int64
- func (pm *PostMetricsMethod) ResultCode() (collector.ResultCode, error)
- func (pm *PostMetricsMethod) RetryOnErr(err error) bool
- func (pm *PostMetricsMethod) ServiceKey() string
- func (pm *PostMetricsMethod) String() string
- type PostStatusMethod
- func (ps *PostStatusMethod) Arg() string
- func (ps *PostStatusMethod) Call(ctx context.Context, c collector.TraceCollectorClient) error
- func (ps *PostStatusMethod) CallSummary() string
- func (ps *PostStatusMethod) Message() [][]byte
- func (ps *PostStatusMethod) MessageLen() int64
- func (ps *PostStatusMethod) RequestSize() int64
- func (ps *PostStatusMethod) ResultCode() (collector.ResultCode, error)
- func (ps *PostStatusMethod) RetryOnErr(err error) bool
- func (ps *PostStatusMethod) ServiceKey() string
- func (ps *PostStatusMethod) String() string
- type Reporter
- type SQLSanitizer
- type ServerlessMessage
- type WriteType
Constants ¶
const ( EventWT = iota MetricWT )
const ( // Disabled - disable SQL sanitizing (the default). Disabled = iota // EnabledAuto - enable SQL sanitizing and attempt to automatically determine // which quoting form to use. EnabledAuto // EnabledDropDoubleQuoted - enable SQL sanitizing and force dropping double- // quoted runes. EnabledDropDoubleQuoted // EnabledKeepDoubleQuoted enable SQL sanitizing and force retaining double- // quoted runes. EnabledKeepDoubleQuoted )
The SQL sanitization mode
const ( PostgreSQL = "postgresql" Oracle = "oracle" MySQL = "mysql" Sybase = "sybase" SQLServer = "sqlserver" DefaultDB = "default" )
The database types
const ( // ReplacementRune is the rune to replace the removed literals ReplacementRune = '?' // EscapeRune is the SQL escape rune EscapeRune = '\\' // MaxSQLLen defines the maximum number of runes after truncation. MaxSQLLen = 2048 // Ellipsis is appended to the truncated SQL statement Ellipsis = '…' )
Variables ¶
var ( ErrShutdownClosedReporter = errors.New("trying to shutdown a closed reporter") ErrShutdownTimeout = errors.New("Shutdown timeout") ErrReporterIsClosed = errors.New("the reporter is closed") )
gRPC reporter errors
var SQLOperatorRunes = map[rune]bool{ '.': true, ';': true, '(': true, ')': true, ',': true, '+': true, '-': true, '*': true, '/': true, '|': true, '=': true, '!': true, '^': true, '>': true, '<': true, '[': true, ']': true, }
SQLOperatorRunes defines the list of SQL operators
Functions ¶
func DefaultBackoff ¶
DefaultBackoff calls the wait function to sleep for a certain time based on the retries value. It returns immediately if the retries exceeds a threshold.
func ParseInt32 ¶ added in v1.1.0
func SQLSanitize ¶
SQLSanitize checks the sanitizer of the database type and does the sanitization accordingly. It uses the default sanitizer if the type is not found.
Types ¶
type BucketOption ¶
type BucketOption func(b *BytesBucket)
BucketOption defines the function type of option setters
func WithClosingIndicator ¶
func WithClosingIndicator(closing chan struct{}) BucketOption
WithClosingIndicator assigns the closing indicator to the bucket
func WithGracefulShutdown ¶
func WithGracefulShutdown(graceful bool) BucketOption
WithGracefulShutdown sets the flag which determined if the bucket will be closed gracefully.
func WithHWM ¶
func WithHWM(HWM int) BucketOption
WithHWM provides a high watermark (in bytes) for the bucket
func WithIntervalGetter ¶
func WithIntervalGetter(fn func() time.Duration) BucketOption
WithIntervalGetter provides a ticker to the bucket to drain it periodically.
type BytesBucket ¶
type BytesBucket struct { // the high watermark of the bucket, we try to keep the current watermark // lower than HWM, but just in best-effort. HWM int // contains filtered or unexported fields }
BytesBucket is a struct to simulate a bucket. It has two actions: pour some water into it from the water source, and drain it when it's drainable. This struct is **not** intended for concurrent-safe.
func NewBytesBucket ¶
func NewBytesBucket(source chan []byte, opts ...BucketOption) *BytesBucket
NewBytesBucket returns a new BytesBucket object with the options provided
func (*BytesBucket) Count ¶
func (b *BytesBucket) Count() int
Count returns the water count during a drain cycle
func (*BytesBucket) Drain ¶
func (b *BytesBucket) Drain() [][]byte
Drain pour all the water out and make the bucket empty.
func (*BytesBucket) DroppedCount ¶
func (b *BytesBucket) DroppedCount() int
DroppedCount returns the number of dropped water during a drain cycle
func (*BytesBucket) Full ¶
func (b *BytesBucket) Full() bool
Full checks if it can be drained now. It is true either when the bucket is marked as full, or it reaches the maximum drain interval (we want to at least drain it periodically)
func (*BytesBucket) PourIn ¶
func (b *BytesBucket) PourIn() int
PourIn pours as much water as possible from the source into the bucket and returns the water it pours in. This method blocks until it's either full or timeout.
func (*BytesBucket) Watermark ¶
func (b *BytesBucket) Watermark() int
Watermark returns the current watermark of the bucket.
type DefaultDialer ¶
type DefaultDialer struct{}
DefaultDialer implements the Dialer interface to provide the default dialing method.
func (*DefaultDialer) Dial ¶
func (d *DefaultDialer) Dial(p DialParams) (*grpc.ClientConn, error)
Dial issues the connection to the remote address with attributes provided by the grpcConnection.
type DialParams ¶
type Dialer ¶
type Dialer interface {
Dial(options DialParams) (*grpc.ClientConn, error)
}
Dialer has a method Dial which accepts a grpcConnection object as the argument and returns a ClientConn object.
type Event ¶
type Event interface { AddKV(attribute.KeyValue) AddKVs([]attribute.KeyValue) SetLabel(Label) SetLayer(string) SetParent(trace.SpanID) GetXTrace() string GetSwTraceContext() string ToBson() []byte }
func CreateEntryEvent ¶
func CreateEntryEvent(ctx trace.SpanContext, t time.Time, parent trace.SpanContext) Event
func CreateExceptionEvent ¶
func CreateExceptionEvent(ctx trace.SpanContext, t time.Time) Event
func CreateExitEvent ¶
func CreateExitEvent(ctx trace.SpanContext, t time.Time) Event
func CreateInfoEvent ¶
func CreateInfoEvent(ctx trace.SpanContext, t time.Time) Event
func CreateInitMessage ¶ added in v1.1.0
func EventFromOtelEvent ¶
func EventFromOtelEvent(ctx trace.SpanContext, evt sdktrace.Event) Event
type FlushWriter ¶
FlushWriter offers an interface to write a byte slice to a specific destination. The caller needs to flush the buffer explicitly in async mode, while for sync mode, a flush is implicitly called after a write.
type GetSettingsMethod ¶
type GetSettingsMethod struct { Resp *collector.SettingsResult // contains filtered or unexported fields }
GetSettingsMethod is the struct for RPC method GetSettings
func (*GetSettingsMethod) Arg ¶
func (gs *GetSettingsMethod) Arg() string
Arg returns the Arg of the RPC call result
func (*GetSettingsMethod) Call ¶
func (gs *GetSettingsMethod) Call(ctx context.Context, c collector.TraceCollectorClient) error
Call issues an RPC call.
func (*GetSettingsMethod) CallSummary ¶
func (gs *GetSettingsMethod) CallSummary() string
CallSummary returns a string representation of the RPC call result.
func (*GetSettingsMethod) Message ¶
func (gs *GetSettingsMethod) Message() [][]byte
Message returns the message body of the RPC call.
func (*GetSettingsMethod) MessageLen ¶
func (gs *GetSettingsMethod) MessageLen() int64
MessageLen returns the length of the RPC message body.
func (*GetSettingsMethod) RequestSize ¶
func (gs *GetSettingsMethod) RequestSize() int64
RequestSize returns the total bytes for an rpc request body
func (*GetSettingsMethod) ResultCode ¶
func (gs *GetSettingsMethod) ResultCode() (collector.ResultCode, error)
ResultCode returns the result code of the RPC call
func (*GetSettingsMethod) RetryOnErr ¶
func (gs *GetSettingsMethod) RetryOnErr(err error) bool
RetryOnErr denotes if this method needs a retry on failure.
func (*GetSettingsMethod) ServiceKey ¶
func (gs *GetSettingsMethod) ServiceKey() string
func (*GetSettingsMethod) String ¶
func (gs *GetSettingsMethod) String() string
type GrpcConnOpt ¶
type GrpcConnOpt func(c *grpcConnection)
GrpcConnOpt defines the function type that sets an option of the grpcConnection
func WithBackoff ¶
func WithBackoff(b Backoff) GrpcConnOpt
WithBackoff return a function that sets the backoff option
func WithCert ¶
func WithCert(cert string) GrpcConnOpt
WithCert returns a function that sets the certificate
func WithDialer ¶
func WithDialer(d Dialer) GrpcConnOpt
WithDialer returns a function that sets the Dialer option
func WithMaxReqBytes ¶
func WithMaxReqBytes(size int64) GrpcConnOpt
WithMaxReqBytes sets the maximum size of an RPC request
func WithProxy ¶
func WithProxy(proxy string) GrpcConnOpt
WithProxy assign the proxy url to the gRPC connection
func WithProxyCertPath ¶
func WithProxyCertPath(certPath string) GrpcConnOpt
WithProxyCertPath assigns the proxy TLS certificate path to the gRPC connection
type Method ¶
type Method interface { // Call invokes the RPC method through a specified gRPC client. It may return // an error if the call is failed and no result code is returned by the collector // due to some reason, e.g., the transport issue. Call(ctx context.Context, c collector.TraceCollectorClient) error // CallSummary returns a string indicating the summary of this call, e.g., the // data chunks sent out and the round trip time.It is for logging purpose only. CallSummary() string // MessageLen returns the length (number of elements) of the method request MessageLen() int64 // RequestSize returns the total bytes for an rpc request body RequestSize() int64 // Message returns the message body, if any Message() [][]byte // ResultCode is the return code of the RPC call. It must only be called after // the Call() method is invoked. ResultCode() (collector.ResultCode, error) // Arg returns the Arg field of the RPC call result. It must only be called // after the Call() method is invoked. Arg() string // String returns the string representation of the Method object String() string // RetryOnErr checks if the method allows retry RetryOnErr(error) bool // ServiceKey returns the service key attached to this method ServiceKey() string }
Method defines the interface of an RPC call
type PingMethod ¶
type PingMethod struct { Resp *collector.MessageResult // contains filtered or unexported fields }
PingMethod defines the RPC method `Ping`
func (*PingMethod) Arg ¶
func (p *PingMethod) Arg() string
Arg returns the arg of the RPC call result
func (*PingMethod) Call ¶
func (p *PingMethod) Call(ctx context.Context, c collector.TraceCollectorClient) error
Call makes an RPC call with the information provided.
func (*PingMethod) CallSummary ¶
func (p *PingMethod) CallSummary() string
CallSummary returns a string representation for the RPC call result. It is mainly used for debug printing.
func (*PingMethod) Message ¶
func (p *PingMethod) Message() [][]byte
Message returns the message body, if any.
func (*PingMethod) MessageLen ¶
func (p *PingMethod) MessageLen() int64
MessageLen returns the length of the RPC call message body.
func (*PingMethod) RequestSize ¶
func (p *PingMethod) RequestSize() int64
RequestSize returns the total bytes for an rpc request body
func (*PingMethod) ResultCode ¶
func (p *PingMethod) ResultCode() (collector.ResultCode, error)
ResultCode returns the code of the RPC call result
func (*PingMethod) RetryOnErr ¶
func (p *PingMethod) RetryOnErr(err error) bool
RetryOnErr denotes if this RPC method needs a retry on failure.
func (*PingMethod) ServiceKey ¶
func (p *PingMethod) ServiceKey() string
func (*PingMethod) String ¶
func (p *PingMethod) String() string
type PostEventsMethod ¶
type PostEventsMethod struct { Resp *collector.MessageResult // contains filtered or unexported fields }
PostEventsMethod is the struct for RPC method PostEvents
func (*PostEventsMethod) Arg ¶
func (pe *PostEventsMethod) Arg() string
Arg returns the Arg of the PostEvents RPC call. This method should only be invoked after the method Call is called.
func (*PostEventsMethod) Call ¶
func (pe *PostEventsMethod) Call(ctx context.Context, c collector.TraceCollectorClient) error
Call issues an RPC call with the provided information
func (*PostEventsMethod) CallSummary ¶
func (pe *PostEventsMethod) CallSummary() string
CallSummary returns a string representation of the RPC call result. It is mainly used for debug printing.
func (*PostEventsMethod) Message ¶
func (pe *PostEventsMethod) Message() [][]byte
Message returns the message body of the RPC call
func (*PostEventsMethod) MessageLen ¶
func (pe *PostEventsMethod) MessageLen() int64
MessageLen returns the length of the PostEvents RPC message body.
func (*PostEventsMethod) RequestSize ¶
func (pe *PostEventsMethod) RequestSize() int64
RequestSize returns the total bytes for an rpc request body
func (*PostEventsMethod) ResultCode ¶
func (pe *PostEventsMethod) ResultCode() (collector.ResultCode, error)
ResultCode returns the result code of the PostEvents RPC call. This method should only be invoked after the method Call is called.
func (*PostEventsMethod) RetryOnErr ¶
func (pe *PostEventsMethod) RetryOnErr(err error) bool
RetryOnErr denotes if retry is needed for this RPC method
func (*PostEventsMethod) ServiceKey ¶
func (pe *PostEventsMethod) ServiceKey() string
func (*PostEventsMethod) String ¶
func (pe *PostEventsMethod) String() string
type PostMetricsMethod ¶
type PostMetricsMethod struct { Resp *collector.MessageResult // contains filtered or unexported fields }
PostMetricsMethod is the struct for RPC method PostMetrics
func (*PostMetricsMethod) Arg ¶
func (pm *PostMetricsMethod) Arg() string
Arg returns the Arg of the RPC call result
func (*PostMetricsMethod) Call ¶
func (pm *PostMetricsMethod) Call(ctx context.Context, c collector.TraceCollectorClient) error
Call issues an RPC request with the provided information.
func (*PostMetricsMethod) CallSummary ¶
func (pm *PostMetricsMethod) CallSummary() string
CallSummary returns a string representation of the RPC call result. It is mainly used for debug printing.
func (*PostMetricsMethod) Message ¶
func (pm *PostMetricsMethod) Message() [][]byte
Message returns the message body of the RPC call.
func (*PostMetricsMethod) MessageLen ¶
func (pm *PostMetricsMethod) MessageLen() int64
MessageLen returns the length of the RPC call message.
func (*PostMetricsMethod) RequestSize ¶
func (pm *PostMetricsMethod) RequestSize() int64
RequestSize returns the total bytes for an rpc request body
func (*PostMetricsMethod) ResultCode ¶
func (pm *PostMetricsMethod) ResultCode() (collector.ResultCode, error)
ResultCode returns the result code of the RPC call. This method should only be called after the method Call is invoked.
func (*PostMetricsMethod) RetryOnErr ¶
func (pm *PostMetricsMethod) RetryOnErr(err error) bool
RetryOnErr denotes if retry is needed for this RPC method
func (*PostMetricsMethod) ServiceKey ¶
func (pm *PostMetricsMethod) ServiceKey() string
func (*PostMetricsMethod) String ¶
func (pm *PostMetricsMethod) String() string
type PostStatusMethod ¶
type PostStatusMethod struct { Resp *collector.MessageResult // contains filtered or unexported fields }
PostStatusMethod is the struct for RPC method PostStatus
func (*PostStatusMethod) Arg ¶
func (ps *PostStatusMethod) Arg() string
Arg returns the Arg of the RPC call result.
func (*PostStatusMethod) Call ¶
func (ps *PostStatusMethod) Call(ctx context.Context, c collector.TraceCollectorClient) error
Call issues an RPC call with the provided information.
func (*PostStatusMethod) CallSummary ¶
func (ps *PostStatusMethod) CallSummary() string
CallSummary returns a string representation for the RPC call result. It is mainly used for debug printing.
func (*PostStatusMethod) Message ¶
func (ps *PostStatusMethod) Message() [][]byte
Message returns the RPC call message body
func (*PostStatusMethod) MessageLen ¶
func (ps *PostStatusMethod) MessageLen() int64
MessageLen returns the length of the RPC call message body
func (*PostStatusMethod) RequestSize ¶
func (ps *PostStatusMethod) RequestSize() int64
RequestSize returns the total bytes for an rpc request body
func (*PostStatusMethod) ResultCode ¶
func (ps *PostStatusMethod) ResultCode() (collector.ResultCode, error)
ResultCode returns the result code of the RPC call.
func (*PostStatusMethod) RetryOnErr ¶
func (ps *PostStatusMethod) RetryOnErr(err error) bool
RetryOnErr denotes if retry is needed for this RPC method
func (*PostStatusMethod) ServiceKey ¶
func (ps *PostStatusMethod) ServiceKey() string
func (*PostStatusMethod) String ¶
func (ps *PostStatusMethod) String() string
type Reporter ¶
type Reporter interface { ReportEvent(e Event) error ReportStatus(e Event) error // Shutdown closes the Reporter. Shutdown(ctx context.Context) error // ShutdownNow closes the Reporter immediately, logs on error ShutdownNow() // Closed returns if the Reporter is already closed. Closed() bool // WaitForReady waits until the Reporter becomes ready or the context is canceled. WaitForReady(context.Context) bool // SetServiceKey attaches a service key to the Reporter // Returns error if service key is invalid SetServiceKey(key string) error // GetServiceName retrieves the current service name, preferring an otel `service.name` from resource attributes, // falling back to the service name in the service key GetServiceName() string }
defines what methods a Reporter should offer (internal to Reporter package)
type SQLSanitizer ¶
type SQLSanitizer struct {
// contains filtered or unexported fields
}
SQLSanitizer sanitizes the SQL statement by removing literals from it.
func NewSQLSanitizer ¶
func NewSQLSanitizer(dbType string, sanitizeFlag int) *SQLSanitizer
NewSQLSanitizer returns the pointer of a new SQLSanitizer.
func (*SQLSanitizer) Sanitize ¶
func (s *SQLSanitizer) Sanitize(sql string) string
Sanitize does the SQL sanitization by removing literals from the statement, it also truncates the statement after sanitization if it's longer than MaxSQLLen.
type ServerlessMessage ¶
type ServerlessMessage struct {
Data LogData `json:"apm-data"`
}
ServerlessMessage denotes the message to be written to AWS CloudWatch. The forwarder will decode the message and sent the messages to the SolarWinds Observability collector.