billing

package
v0.33.0-k8s-1.28 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: Apache-2.0 Imports: 18 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 GetHostname added in v0.28.0

func GetHostname() string

GetHostname returns the hostname to be used for enriching billing events (see Enrich())

This function MUST NOT be run before init has finished.

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 AzureAuthSharedKey added in v0.33.0

type AzureAuthSharedKey struct {
	AccountName string `json:"accountName"`
	AccountKey  string `json:"accountKey"`
}

type AzureBlobStorageClientConfig added in v0.33.0

type AzureBlobStorageClientConfig struct {
	// In Azure a Container is close to a bucket in AWS S3
	Container string `json:"container"`
	// Files will be created with name starting with PrefixInContainer
	PrefixInContainer string `json:"prefixInContainer"`
	// Example Endpoint: "https://MYSTORAGEACCOUNT.blob.core.windows.net/"
	Endpoint string `json:"endpoint"`
	// contains filtered or unexported fields
}

type AzureClient added in v0.33.0

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

func NewAzureBlobStorageClient added in v0.33.0

func NewAzureBlobStorageClient(cfg AzureBlobStorageClientConfig) (*AzureClient, error)

func (AzureClient) LogFields added in v0.33.0

func (c AzureClient) LogFields() zap.Field

type AzureError added in v0.33.0

type AzureError struct {
	Err error
}

func (AzureError) Error added in v0.33.0

func (e AzureError) Error() string

func (AzureError) Unwrap added in v0.33.0

func (e AzureError) Unwrap() error

type Client

type Client interface {
	LogFields() zap.Field
	// contains filtered or unexported methods
}

type Event added in v0.12.0

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

type HTTPClient added in v0.29.0

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

func NewHTTPClient added in v0.29.0

func NewHTTPClient(url string, c *http.Client) HTTPClient

func (HTTPClient) LogFields added in v0.29.0

func (c HTTPClient) LogFields() zap.Field

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 S3Client added in v0.29.0

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

func NewS3Client added in v0.29.0

func NewS3Client(ctx context.Context, cfg S3ClientConfig) (*S3Client, error)

func (S3Client) LogFields added in v0.29.0

func (c S3Client) LogFields() zap.Field

type S3ClientConfig added in v0.29.0

type S3ClientConfig struct {
	Bucket         string `json:"bucket"`
	Region         string `json:"region"`
	PrefixInBucket string `json:"prefixInBucket"`
	Endpoint       string `json:"endpoint"`
}

type S3Error added in v0.29.0

type S3Error struct {
	Err error
}

func (S3Error) Error added in v0.29.0

func (e S3Error) Error() string

func (S3Error) Unwrap added in v0.29.0

func (e S3Error) Unwrap() error

type TraceID added in v0.12.0

type TraceID string

func GenerateTraceID added in v0.29.0

func GenerateTraceID() TraceID

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