12 // Client side metric handler names
14 APICallMetricHandlerName = "awscsm.SendAPICallMetric"
15 APICallAttemptMetricHandlerName = "awscsm.SendAPICallAttemptMetric"
18 // Start will start the a long running go routine to capture
19 // client side metrics. Calling start multiple time will only
20 // start the metric listener once and will panic if a different
21 // client ID or port is passed in.
24 // r, err := csm.Start("clientID", "127.0.0.1:8094")
26 // panic(fmt.Errorf("expected no error, but received %v", err))
28 // sess := session.NewSession()
29 // r.InjectHandlers(sess.Handlers)
31 // svc := s3.New(sess)
32 // out, err := svc.GetObject(&s3.GetObjectInput{
33 // Bucket: aws.String("bucket"),
34 // Key: aws.String("key"),
36 func Start(clientID string, url string) (*Reporter, error) {
41 sender = newReporter(clientID, url)
43 if sender.clientID != clientID {
44 panic(fmt.Errorf("inconsistent client IDs. %q was expected, but received %q", sender.clientID, clientID))
47 if sender.url != url {
48 panic(fmt.Errorf("inconsistent URLs. %q was expected, but received %q", sender.url, url))
52 if err := connect(url); err != nil {
60 // Get will return a reporter if one exists, if one does not exist, nil will
62 func Get() *Reporter {