metrics

package
v1.26.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 6 Imported by: 7

Documentation

Overview

Package metrics implements metrics gathering for SDK development purposes.

This package is designated as private and is intended for use only by the AWS client runtime. The exported API therein is not considered stable and is subject to breaking changes without notice.

Index

Constants

View Source
const (
	// ServiceIDKey is the key for the service ID metric.
	ServiceIDKey = "ServiceId"
	// OperationNameKey is the key for the operation name metric.
	OperationNameKey = "OperationName"
	// ClientRequestIDKey is the key for the client request ID metric.
	ClientRequestIDKey = "ClientRequestId"
	// APICallDurationKey is the key for the API call duration metric.
	APICallDurationKey = "ApiCallDuration"
	// APICallSuccessfulKey is the key for the API call successful metric.
	APICallSuccessfulKey = "ApiCallSuccessful"
	// MarshallingDurationKey is the key for the marshalling duration metric.
	MarshallingDurationKey = "MarshallingDuration"
	// InThroughputKey is the key for the input throughput metric.
	InThroughputKey = "InThroughput"
	// OutThroughputKey is the key for the output throughput metric.
	OutThroughputKey = "OutThroughput"
	// RetryCountKey is the key for the retry count metric.
	RetryCountKey = "RetryCount"
	// HTTPStatusCodeKey is the key for the HTTP status code metric.
	HTTPStatusCodeKey = "HttpStatusCode"
	// AWSExtendedRequestIDKey is the key for the AWS extended request ID metric.
	AWSExtendedRequestIDKey = "AwsExtendedRequestId"
	// AWSRequestIDKey is the key for the AWS request ID metric.
	AWSRequestIDKey = "AwsRequestId"
	// BackoffDelayDurationKey is the key for the backoff delay duration metric.
	BackoffDelayDurationKey = "BackoffDelayDuration"
	// StreamThroughputKey is the key for the stream throughput metric.
	StreamThroughputKey = "Throughput"
	// ConcurrencyAcquireDurationKey is the key for the concurrency acquire duration metric.
	ConcurrencyAcquireDurationKey = "ConcurrencyAcquireDuration"
	// PendingConcurrencyAcquiresKey is the key for the pending concurrency acquires metric.
	PendingConcurrencyAcquiresKey = "PendingConcurrencyAcquires"
	// SigningDurationKey is the key for the signing duration metric.
	SigningDurationKey = "SigningDuration"
	// UnmarshallingDurationKey is the key for the unmarshalling duration metric.
	UnmarshallingDurationKey = "UnmarshallingDuration"
	// TimeToFirstByteKey is the key for the time to first byte metric.
	TimeToFirstByteKey = "TimeToFirstByte"
	// ServiceCallDurationKey is the key for the service call duration metric.
	ServiceCallDurationKey = "ServiceCallDuration"
	// EndpointResolutionDurationKey is the key for the endpoint resolution duration metric.
	EndpointResolutionDurationKey = "EndpointResolutionDuration"
	// AttemptNumberKey is the key for the attempt number metric.
	AttemptNumberKey = "AttemptNumber"
	// MaxConcurrencyKey is the key for the max concurrency metric.
	MaxConcurrencyKey = "MaxConcurrency"
	// AvailableConcurrencyKey is the key for the available concurrency metric.
	AvailableConcurrencyKey = "AvailableConcurrency"
)

Variables

This section is empty.

Functions

func InitMetricContext

func InitMetricContext(
	ctx context.Context, counter *SharedConnectionCounter, publisher MetricPublisher,
) context.Context

InitMetricContext initializes the metric context with the provided counter and publisher. It returns the updated context.

Types

type AttemptMetrics

type AttemptMetrics struct {
	ServiceCallStart           time.Time
	ServiceCallEnd             time.Time
	ServiceCallDuration        time.Duration
	FirstByteTime              time.Time
	TimeToFirstByte            time.Duration
	ConnRequestedTime          time.Time
	ConnObtainedTime           time.Time
	ConcurrencyAcquireDuration time.Duration
	CredentialFetchStartTime   time.Time
	CredentialFetchEndTime     time.Time
	SignStartTime              time.Time
	SignEndTime                time.Time
	SigningDuration            time.Duration
	DeserializeStartTime       time.Time
	DeserializeEndTime         time.Time
	UnMarshallingDuration      time.Duration
	RetryDelay                 time.Duration
	ResponseContentLength      int64
	StatusCode                 int
	RequestID                  string
	ExtendedRequestID          string
	HTTPClient                 string
	MaxConcurrency             int
	PendingConnectionAcquires  int
	AvailableConcurrency       int
	ActiveRequests             int
	ReusedConnection           bool
}

AttemptMetrics stores metrics related to individual attempts.

type DefaultSerializer

type DefaultSerializer struct{}

DefaultSerializer is an implementation of the Serializer interface.

func (DefaultSerializer) Serialize

func (DefaultSerializer) Serialize(obj interface{}) (string, error)

Serialize uses the default JSON serializer to obtain the string representation of an object.

type MetricContext

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

MetricContext contains fields to store metric-related information.

func Context

func Context(ctx context.Context) *MetricContext

Context returns the metric context from the given context. It returns nil if the metric context is not found.

func (*MetricContext) ConnectionCounter

func (mc *MetricContext) ConnectionCounter() *SharedConnectionCounter

ConnectionCounter returns the SharedConnectionCounter associated with the MetricContext.

func (*MetricContext) Data

func (mc *MetricContext) Data() *MetricData

Data returns the MetricData associated with the MetricContext.

func (*MetricContext) Publisher

func (mc *MetricContext) Publisher() MetricPublisher

Publisher returns the MetricPublisher associated with the MetricContext.

type MetricData

type MetricData struct {
	RequestStartTime           time.Time
	RequestEndTime             time.Time
	APICallDuration            time.Duration
	SerializeStartTime         time.Time
	SerializeEndTime           time.Time
	MarshallingDuration        time.Duration
	ResolveEndpointStartTime   time.Time
	ResolveEndpointEndTime     time.Time
	EndpointResolutionDuration time.Duration
	InThroughput               float64
	OutThroughput              float64
	RetryCount                 int
	Success                    uint8
	StatusCode                 int
	ClientRequestID            string
	ServiceID                  string
	OperationName              string
	PartitionID                string
	Region                     string
	RequestContentLength       int64
	Stream                     StreamMetrics
	Attempts                   []AttemptMetrics
}

MetricData stores the collected metric data.

func (*MetricData) ComputeRequestMetrics

func (md *MetricData) ComputeRequestMetrics()

ComputeRequestMetrics calculates and populates derived metrics based on the collected data.

func (*MetricData) LatestAttempt

func (md *MetricData) LatestAttempt() (*AttemptMetrics, error)

LatestAttempt returns the latest attempt metrics. It returns an error if no attempts are initialized.

func (*MetricData) NewAttempt

func (md *MetricData) NewAttempt()

NewAttempt initializes new attempt metrics.

type MetricPublisher

type MetricPublisher interface {
	PostRequestMetrics(*MetricData) error
	PostStreamMetrics(*MetricData) error
}

MetricPublisher provides the interface to provide custom MetricPublishers. PostRequestMetrics will be invoked by the MetricCollection middleware to post request. PostStreamMetrics will be invoked by ReadCloserWithMetrics to post stream metrics.

type Serializer

type Serializer interface {
	Serialize(obj interface{}) (string, error)
}

Serializer provides the interface to provide custom Serializers. Serialize will transform any input object in its corresponding string representation.

type SharedConnectionCounter

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

SharedConnectionCounter is a counter shared across API calls.

func (*SharedConnectionCounter) ActiveRequests

func (cc *SharedConnectionCounter) ActiveRequests() int

ActiveRequests returns the count of active requests.

func (*SharedConnectionCounter) AddActiveRequest

func (cc *SharedConnectionCounter) AddActiveRequest()

AddActiveRequest increments the count of active requests.

func (*SharedConnectionCounter) AddPendingConnectionAcquire

func (cc *SharedConnectionCounter) AddPendingConnectionAcquire()

AddPendingConnectionAcquire increments the count of pending connection acquires.

func (*SharedConnectionCounter) PendingConnectionAcquire

func (cc *SharedConnectionCounter) PendingConnectionAcquire() int

PendingConnectionAcquire returns the count of pending connection acquires.

func (*SharedConnectionCounter) RemoveActiveRequest

func (cc *SharedConnectionCounter) RemoveActiveRequest()

RemoveActiveRequest decrements the count of active requests.

func (*SharedConnectionCounter) RemovePendingConnectionAcquire

func (cc *SharedConnectionCounter) RemovePendingConnectionAcquire()

RemovePendingConnectionAcquire decrements the count of pending connection acquires.

type StreamMetrics

type StreamMetrics struct {
	ReadDuration time.Duration
	ReadBytes    int64
	Throughput   float64
}

StreamMetrics stores metrics related to streaming data.

Directories

Path Synopsis
Package emf implements an EMF metrics publisher.
Package emf implements an EMF metrics publisher.

Jump to

Keyboard shortcuts

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