aws-sdk-go: github.com/aws/aws-sdk-go/aws/csm Index | Examples | Files

package csm

import "github.com/aws/aws-sdk-go/aws/csm"

Package csm provides Client Side Monitoring (CSM) which enables sending metrics via UDP connection. Using the Start function will enable the reporting of metrics on a given port. If Start is called, with different parameters, again, a panic will occur.

Pause can be called to pause any metrics publishing on a given port. Sessions that have had their handlers modified via InjectHandlers may still be used. However, the handlers will act as a no-op meaning no metrics will be published.

Example:
	r, err := csm.Start("clientID", ":31000")
	if err != nil {
		panic(fmt.Errorf("failed starting CSM:  %v", err))
	}

	sess, err := session.NewSession(&aws.Config{})
	if err != nil {
		panic(fmt.Errorf("failed loading session: %v", err))
	}

	r.InjectHandlers(&sess.Handlers)

	client := s3.New(sess)
	resp, err := client.GetObject(&s3.GetObjectInput{
		Bucket: aws.String("bucket"),
		Key: aws.String("key"),
	})

	// Will pause monitoring
	r.Pause()
	resp, err = client.GetObject(&s3.GetObjectInput{
		Bucket: aws.String("bucket"),
		Key: aws.String("key"),
	})

	// Resume monitoring
	r.Continue()

Start returns a Reporter that is used to enable or disable monitoring. If access to the Reporter is required later, calling Get will return the Reporter singleton.

Example:
	r := csm.Get()
	r.Continue()

Index

Examples

Package Files

doc.go enable.go metric.go metric_chan.go metric_exception.go reporter.go

Constants

const (
    APICallMetricHandlerName        = "awscsm.SendAPICallMetric"
    APICallAttemptMetricHandlerName = "awscsm.SendAPICallAttemptMetric"
)

Client side metric handler names

const (
    // DefaultPort is used when no port is specified
    DefaultPort = "31000"
)

Variables

var (
    // MetricsChannelSize of metrics to hold in the channel
    MetricsChannelSize = 100
)

type Reporter Uses

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

Reporter will gather metrics of API requests made and send those metrics to the CSM endpoint.

func Get Uses

func Get() *Reporter

Get will return a reporter if one exists, if one does not exist, nil will be returned.

func Start Uses

func Start(clientID string, url string) (*Reporter, error)

Start will start the a long running go routine to capture client side metrics. Calling start multiple time will only start the metric listener once and will panic if a different client ID or port is passed in.

Example:
	r, err := csm.Start("clientID", "127.0.0.1:8094")
	if err != nil {
		panic(fmt.Errorf("expected no error, but received %v", err))
	}
	sess := session.NewSession()
	r.InjectHandlers(sess.Handlers)

	svc := s3.New(sess)
	out, err := svc.GetObject(&s3.GetObjectInput{
		Bucket: aws.String("bucket"),
		Key: aws.String("key"),
	})

Code:

r, err := csm.Start("clientID", ":31000")
if err != nil {
    panic(fmt.Errorf("failed starting CSM:  %v", err))
}

sess, err := session.NewSession(&aws.Config{})
if err != nil {
    panic(fmt.Errorf("failed loading session: %v", err))
}

r.InjectHandlers(&sess.Handlers)

client := s3.New(sess)
client.GetObject(&s3.GetObjectInput{
    Bucket: aws.String("bucket"),
    Key:    aws.String("key"),
})

// Pauses monitoring
r.Pause()
client.GetObject(&s3.GetObjectInput{
    Bucket: aws.String("bucket"),
    Key:    aws.String("key"),
})

// Resume monitoring
r.Continue()

func (*Reporter) Continue Uses

func (rep *Reporter) Continue()

Continue will reopen the metric channel and allow for monitoring to be resumed.

func (*Reporter) InjectHandlers Uses

func (rep *Reporter) InjectHandlers(handlers *request.Handlers)

InjectHandlers will will enable client side metrics and inject the proper handlers to handle how metrics are sent.

Example:
	// Start must be called in order to inject the correct handlers
	r, err := csm.Start("clientID", "127.0.0.1:8094")
	if err != nil {
		panic(fmt.Errorf("expected no error, but received %v", err))
	}

	sess := session.NewSession()
	r.InjectHandlers(&sess.Handlers)

	// create a new service client with our client side metric session
	svc := s3.New(sess)

func (*Reporter) Pause Uses

func (rep *Reporter) Pause()

Pause will pause the metric channel preventing any new metrics from being added.

Package csm imports 10 packages (graph) and is imported by 7 packages. Updated 2019-01-14. Refresh now. Tools for package owners.