aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/aws/aws-sdk-go/aws/csm/enable.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/aws/aws-sdk-go/aws/csm/enable.go')
-rw-r--r--vendor/github.com/aws/aws-sdk-go/aws/csm/enable.go34
1 files changed, 28 insertions, 6 deletions
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/csm/enable.go b/vendor/github.com/aws/aws-sdk-go/aws/csm/enable.go
index 2f0c6ea..4b19e28 100644
--- a/vendor/github.com/aws/aws-sdk-go/aws/csm/enable.go
+++ b/vendor/github.com/aws/aws-sdk-go/aws/csm/enable.go
@@ -2,6 +2,7 @@ package csm
2 2
3import ( 3import (
4 "fmt" 4 "fmt"
5 "strings"
5 "sync" 6 "sync"
6) 7)
7 8
@@ -9,19 +10,40 @@ var (
9 lock sync.Mutex 10 lock sync.Mutex
10) 11)
11 12
12// Client side metric handler names
13const ( 13const (
14 APICallMetricHandlerName = "awscsm.SendAPICallMetric" 14 // DefaultPort is used when no port is specified.
15 APICallAttemptMetricHandlerName = "awscsm.SendAPICallAttemptMetric" 15 DefaultPort = "31000"
16
17 // DefaultHost is the host that will be used when none is specified.
18 DefaultHost = "127.0.0.1"
16) 19)
17 20
18// Start will start the a long running go routine to capture 21// AddressWithDefaults returns a CSM address built from the host and port
22// values. If the host or port is not set, default values will be used
23// instead. If host is "localhost" it will be replaced with "127.0.0.1".
24func AddressWithDefaults(host, port string) string {
25 if len(host) == 0 || strings.EqualFold(host, "localhost") {
26 host = DefaultHost
27 }
28
29 if len(port) == 0 {
30 port = DefaultPort
31 }
32
33 // Only IP6 host can contain a colon
34 if strings.Contains(host, ":") {
35 return "[" + host + "]:" + port
36 }
37
38 return host + ":" + port
39}
40
41// Start will start a long running go routine to capture
19// client side metrics. Calling start multiple time will only 42// client side metrics. Calling start multiple time will only
20// start the metric listener once and will panic if a different 43// start the metric listener once and will panic if a different
21// client ID or port is passed in. 44// client ID or port is passed in.
22// 45//
23// Example: 46// r, err := csm.Start("clientID", "127.0.0.1:31000")
24// r, err := csm.Start("clientID", "127.0.0.1:8094")
25// if err != nil { 47// if err != nil {
26// panic(fmt.Errorf("expected no error, but received %v", err)) 48// panic(fmt.Errorf("expected no error, but received %v", err))
27// } 49// }