telemetry

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Welcome is displayed the first time the telemetry config is created.
	Welcome = `` /* 141-byte string literal not displayed */

)

Variables

View Source
var ConfigFile = filepath.Join(".airbyte", "analytics.yml")

Functions

func Wrapper added in v0.3.0

func Wrapper(ctx context.Context, et EventType, f func() error) error

Wrapper wraps the function calls with the telemetry handlers

Types

type Client

type Client interface {
	// Start should be called as soon quickly as possible.
	Start(context.Context, EventType) error
	// Success should be called only if the activity succeeded.
	Success(context.Context, EventType) error
	// Failure should be called only if the activity failed.
	Failure(context.Context, EventType, error) error
	// Attr should be called to add additional attributes to this activity.
	Attr(key, val string)
}

Client interface for telemetry data.

func Get added in v0.2.0

func Get(opts ...GetOption) Client

Get returns the already configured telemetry Client or configures a new one returning it. If a previously configured Client exists, that one will be returned.

type Config

type Config struct {
	UserID ULID `yaml:"anonymous_user_id"`
}

Config represents the analytics.yaml file.

type Doer added in v0.3.0

type Doer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer interface for testing purposes

type EventState

type EventState string
const (
	Start   EventState = "started"
	Failed  EventState = "failed"
	Success EventState = "succeeded"
)

type EventType

type EventType string
const (
	Install   EventType = "install"
	Uninstall EventType = "uninstall"
)

type GetOption added in v0.2.0

type GetOption func(*getConfig)

GetOption is for optional configuration of the Get call.

func WithDnt added in v0.2.0

func WithDnt() GetOption

WithDnt tells the Get call to enable the do-not-track configuration.

func WithUserHome added in v0.2.0

func WithUserHome(userHome string) GetOption

WithUserHome tells the Get call which directory should be considered the user's home. Primary for testing purposes.

type NoopClient

type NoopClient struct {
}

NoopClient client, all methods are no-ops.

func (NoopClient) Attr

func (n NoopClient) Attr(_, _ string)

func (NoopClient) Failure

func (NoopClient) Start

func (NoopClient) Success

type Option added in v0.3.0

type Option func(*SegmentClient)

Option is a configuration option for segment

func WithHTTPClient added in v0.3.0

func WithHTTPClient(d Doer) Option

WithHTTPClient overrides the default http.Client, primarily for testing purposes.

func WithSessionID added in v0.3.0

func WithSessionID(sessionID ulid.ULID) Option

WithSessionID overrides the default ulid session, primarily for testing purposes.

type SegmentClient

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

SegmentClient client, all methods communicate with segment.

func NewSegmentClient

func NewSegmentClient(cfg Config, opts ...Option) *SegmentClient

func (*SegmentClient) Attr

func (s *SegmentClient) Attr(key, val string)

func (*SegmentClient) Failure

func (s *SegmentClient) Failure(ctx context.Context, et EventType, err error) error

func (*SegmentClient) Start

func (s *SegmentClient) Start(ctx context.Context, et EventType) error

func (*SegmentClient) Success

func (s *SegmentClient) Success(ctx context.Context, et EventType) error

type ULID

type ULID ulid.ULID

ULID is a wrapper around ulid.ULID so that we can implement the yaml interfaces.

func NewULID

func NewULID() ULID

NewULID returns a new randomized ULID.

func (ULID) MarshalYAML

func (u ULID) MarshalYAML() (any, error)

MarshalYAML allows for converting a ULID into a yaml field.

func (ULID) String

func (u ULID) String() string

String returns a string representation of this ULID.

func (*ULID) UnmarshalYAML

func (u *ULID) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML allows for converting a yaml field into a ULID.

Jump to

Keyboard shortcuts

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