1 // Package csm provides the Client Side Monitoring (CSM) client which enables
2 // sending metrics via UDP connection to the CSM agent. This package provides
3 // control options, and configuration for the CSM client. The client can be
4 // controlled manually, or automatically via the SDK's Session configuration.
6 // Enabling CSM client via SDK's Session configuration
8 // The CSM client can be enabled automatically via SDK's Session configuration.
9 // The SDK's session configuration enables the CSM client if the AWS_CSM_PORT
10 // environment variable is set to a non-empty value.
12 // The configuration options for the CSM client via the SDK's session
15 // * AWS_CSM_PORT=<port number>
16 // The port number the CSM agent will receive metrics on.
18 // * AWS_CSM_HOST=<hostname or ip>
19 // The hostname, or IP address the CSM agent will receive metrics on.
20 // Without port number.
22 // Manually enabling the CSM client
24 // The CSM client can be started, paused, and resumed manually. The Start
25 // function will enable the CSM client to publish metrics to the CSM agent. It
26 // is safe to call Start concurrently, but if Start is called additional times
27 // with different ClientID or address it will panic.
29 // r, err := csm.Start("clientID", ":31000")
31 // panic(fmt.Errorf("failed starting CSM: %v", err))
34 // When controlling the CSM client manually, you must also inject its request
35 // handlers into the SDK's Session configuration for the SDK's API clients to
38 // sess, err := session.NewSession(&aws.Config{})
40 // panic(fmt.Errorf("failed loading session: %v", err))
43 // // Add CSM client's metric publishing request handlers to the SDK's
44 // // Session Configuration.
45 // r.InjectHandlers(&sess.Handlers)
47 // Controlling CSM client
49 // Once the CSM client has been enabled the Get function will return a Reporter
50 // value that you can use to pause and resume the metrics published to the CSM
51 // agent. If Get function is called before the reporter is enabled with the
52 // Start function or via SDK's Session configuration nil will be returned.
54 // The Pause method can be called to stop the CSM client publishing metrics to
55 // the CSM agent. The Continue method will resume metric publishing.
57 // // Get the CSM client Reporter.
60 // // Will pause monitoring
62 // resp, err = client.GetObject(&s3.GetObjectInput{
63 // Bucket: aws.String("bucket"),
64 // Key: aws.String("key"),
67 // // Resume monitoring