billing

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enrich added in v0.12.0

func Enrich[E Event](now time.Time, hostname string, countInBatch, batchSize int, event E) E

Enrich sets the event's Type and IdempotencyKey fields, so that users of this API don't need to manually set them

func Send added in v0.12.0

func Send[E Event](ctx context.Context, client Client, traceID TraceID, events []E) error

Send attempts to push the events to the remote endpoint.

On failure, the error is guaranteed to be one of: JSONError, RequestError, or UnexpectedStatusCodeError.

Types

type AbsoluteEvent

type AbsoluteEvent struct {
	IdempotencyKey string    `json:"idempotency_key"`
	MetricName     string    `json:"metric"`
	Type           string    `json:"type"`
	TenantID       string    `json:"tenant_id"`
	TimelineID     string    `json:"timeline_id"`
	Time           time.Time `json:"time"`
	Value          int       `json:"value"`
}

type Client

type Client struct {
	URL string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(url string, c *http.Client) Client

func (Client) GenerateTraceID added in v0.12.0

func (c Client) GenerateTraceID() TraceID

func (Client) Hostname added in v0.12.0

func (c Client) Hostname() string

type Event added in v0.12.0

type Event interface {
	*AbsoluteEvent | *IncrementalEvent
	// contains filtered or unexported methods
}

type IncrementalEvent

type IncrementalEvent struct {
	IdempotencyKey string    `json:"idempotency_key"`
	MetricName     string    `json:"metric"`
	Type           string    `json:"type"`
	EndpointID     string    `json:"endpoint_id"`
	StartTime      time.Time `json:"start_time"`
	StopTime       time.Time `json:"stop_time"`
	Value          int       `json:"value"`
}

type JSONError added in v0.18.0

type JSONError struct {
	Err error
}

func (JSONError) Error added in v0.18.0

func (e JSONError) Error() string

func (JSONError) Unwrap added in v0.18.0

func (e JSONError) Unwrap() error

type RequestError added in v0.18.0

type RequestError struct {
	Err error
}

func (RequestError) Error added in v0.18.0

func (e RequestError) Error() string

func (RequestError) Unwrap added in v0.18.0

func (e RequestError) Unwrap() error

type TraceID added in v0.12.0

type TraceID string

type UnexpectedStatusCodeError added in v0.18.0

type UnexpectedStatusCodeError struct {
	StatusCode int
}

func (UnexpectedStatusCodeError) Error added in v0.18.0

Jump to

Keyboard shortcuts

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