The Sauce Labs Cookbook

Sauce Headless

Front End Performance Testing

Insights

External Resources

More Info


Page tree
Skip to end of metadata
Go to start of metadata

Sauce Connect Proxy has a performance metrics feature that you can use to monitor and measure the data and activities of your Sauce Connect client. You can access these metrics over an HTTP connection to a local expvar server, which will display the metrics as a JSON file.

See the following sections for more information:

Configuring Sauce Connect Proxy Performance Metrics Monitoring 

By default, the expvar server listens on localhost:8888, but you can change the interface and port with the --metrics-address command.

--metrics-address :8000 # listens on all the interfaces' port 8080
--metrics-address 1.2.3.4:80 # listens on 1.2.3.4 port 80

Viewing Sauce Connect Proxy Performance Metrics

You can view performance metrics by using an HTTP client or web browser to access http://{SauceConnect IP or Localhost:8888}/debug/vars. Once you've got access, the performance metrics will typically look like this:

"cmdline": ["/Users/<USER_ID>/Downloads/sc-<VERSION>-<PLATFORM>/bin/sc","-u","User","-k","<ACCESS_KEY>"],
 
"http": {
			"BytesReceived":31290,
			"BytesTransmitted":1388944,
			"NumRequests":34,
			"NumResponses":34
		},
"kgp": 	{
			"Connected":true,
			"LastStatusChange":1532052072,
			"RoundTripTimeMs":35,
			"ReconnectCount":0
		},
"memstats": {
			"Alloc":1630808,
			"TotalAlloc":10647440,
			"Sys":9509112,
			"Lookups":55,
			"Mallocs":220719,
			"Frees":204517,
			"HeapAlloc":1630808,
			"HeapSys":5668864,
			"HeapIdle":1753088,
			"HeapInuse":3915776,
			"HeapReleased":270336,
			"HeapObjects":16202,
			"StackInuse":622592,
			"StackSys":622592,
			"MSpanInuse":74024,
			"MSpanSys":98304,
			"MCacheInuse":4800,
			"MCacheSys":16384,
			"BuckHashSys":1446894,
			"GCSys":436224,
			"OtherSys":1219850,
			"NextGC":4194304,
			"LastGC":1532052496921727000,
			"PauseTotalNs":753000,
			"PauseNs":[...]
		}
}

Sauce Connect Proxy Client Metrics Definitions

Below is a full list of performance metrics and definitions for the Sauce Connect Proxy client.

Metric

Definition

kgp.Connected

Indicates whether the client is connected to the Sauce Connect back end. This field can be used for monitoring tunnel health.

kgp.LastStatusChange

A UNIX timestamp indicating the time of the last connectivity change from the client.

kgp.ReconnectCount

Number of times the connection to the Sauce Connect back end had to be re-established because of the timeout.

kgp.RoundTripTimeMs
Application layer latency over the last minute.
http.BytesReceived
Number of bytes received by the Sauce Connect Proxy client.
http.BytesTransmitted
Number of bytes transmitted by the Sauce Connect Proxy client.
http.NumRequests
Number of requests currently in flight.
http.NumResponses
Number of responses currently in flight.

Sauce Connect Proxy Client Health Metrics

While Sauce Connect Proxy is running, a basic webpage with metrics is made available at localhost:8888/debug/vars on the host machine. It serves a JSON blob containing a plethora of information, including the important healthMetrics section, which gives three vital metrics to the state of the Sauce Connect Proxy client:

MetricValueDefinition
kgpIsConnected
True/FalseTrue if the KGP connection is currently alive and healthy, false otherwise
kgpLastStatusChange
Unix Epoch TimestampTimestamp of when the value for kgpIsConnected last changed
kgpReconnectCount
IntegerA running count of how many times Sauce Connect Proxy had to re-establish its KGP connection
 Click here to see example raw output..
 {
"cmdline": ["/Users/acampbell/Documents/sc-4.4.6-osx/bin/sc","-u","******","-k","******","--pidfile","currentA","--se-port","4445"],
"healthMetrics": {"kgpIsConnected": true, "kgpLastStatusChange": 1492568535, "kgpReconnectCount": 0},
"memstats": {"Alloc":1891072,"TotalAlloc":11894816,"Sys":10590456,"Lookups":23,"Mallocs":171948,"Frees":155551,"HeapAlloc":1891072,"HeapSys":6619136,"HeapIdle":2277376,"HeapInuse":4341760,"HeapReleased":0,"HeapObjects":16397,"StackInuse":720896,"StackSys":720896,"MSpanInuse":82536,"MSpanSys":98304,"MCacheInuse":4800,"MCacheSys":16384,"BuckHashSys":1446133,"GCSys":471040,"OtherSys":1218563,"NextGC":4194304,"LastGC":1492568665306899183,"PauseTotalNs":449320,"PauseNs":[124228,169728,73016,38885,43463,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"PauseEnd":[1492568520772418515,1492568575257556530,1492568624109846929,1492568644101261105,1492568665306899183,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"NumGC":5,"NumForcedGC":0,"GCCPUFraction":0.000017483197350069177,"EnableGC":true,"DebugGC":false,"BySize":[{"Size":0,"Mallocs":0,"Frees":0},{"Size":8,"Mallocs":638,"Frees":602},{"Size":16,"Mallocs":67329,"Frees":62319},{"Size":32,"Mallocs":31514,"Frees":23432},{"Size":48,"Mallocs":14514,"Frees":13882},{"Size":64,"Mallocs":11311,"Frees":10957},{"Size":80,"Mallocs":7748,"Frees":7476},{"Size":96,"Mallocs":3122,"Frees":2969},{"Size":112,"Mallocs":1350,"Frees":1267},{"Size":128,"Mallocs":1133,"Frees":1079},{"Size":144,"Mallocs":665,"Frees":622},{"Size":160,"Mallocs":1033,"Frees":686},{"Size":176,"Mallocs":713,"Frees":663},{"Size":192,"Mallocs":2538,"Frees":2524},{"Size":208,"Mallocs":162,"Frees":137},{"Size":224,"Mallocs":445,"Frees":295},{"Size":240,"Mallocs":30,"Frees":27},{"Size":256,"Mallocs":283,"Frees":254},{"Size":288,"Mallocs":436,"Frees":395},{"Size":320,"Mallocs":274,"Frees":50},{"Size":352,"Mallocs":622,"Frees":590},{"Size":384,"Mallocs":50,"Frees":36},{"Size":416,"Mallocs":167,"Frees":95},{"Size":448,"Mallocs":133,"Frees":84},{"Size":480,"Mallocs":20,"Frees":17},{"Size":512,"Mallocs":65,"Frees":62},{"Size":576,"Mallocs":335,"Frees":272},{"Size":640,"Mallocs":91,"Frees":83},{"Size":704,"Mallocs":280,"Frees":263},{"Size":768,"Mallocs":216,"Frees":215},{"Size":896,"Mallocs":125,"Frees":80},{"Size":1024,"Mallocs":106,"Frees":43},{"Size":1152,"Mallocs":424,"Frees":173},{"Size":1280,"Mallocs":56,"Frees":44},{"Size":1408,"Mallocs":59,"Frees":39},{"Size":1536,"Mallocs":105,"Frees":80},{"Size":1792,"Mallocs":30,"Frees":19},{"Size":2048,"Mallocs":79,"Frees":53},{"Size":2304,"Mallocs":164,"Frees":154},{"Size":2688,"Mallocs":25,"Frees":18},{"Size":3072,"Mallocs":10,"Frees":4},{"Size":3200,"Mallocs":0,"Frees":0},{"Size":3456,"Mallocs":4,"Frees":1},{"Size":4096,"Mallocs":186,"Frees":155},{"Size":4864,"Mallocs":153,"Frees":144},{"Size":5376,"Mallocs":5,"Frees":4},{"Size":6144,"Mallocs":151,"Frees":144},{"Size":6528,"Mallocs":0,"Frees":0},{"Size":6784,"Mallocs":1,"Frees":0},{"Size":6912,"Mallocs":0,"Frees":0},{"Size":8192,"Mallocs":5,"Frees":5},{"Size":9472,"Mallocs":0,"Frees":0},{"Size":9728,"Mallocs":0,"Frees":0},{"Size":10240,"Mallocs":0,"Frees":0},{"Size":10880,"Mallocs":4,"Frees":2},{"Size":12288,"Mallocs":0,"Frees":0},{"Size":13568,"Mallocs":0,"Frees":0},{"Size":14336,"Mallocs":0,"Frees":0},{"Size":16384,"Mallocs":0,"Frees":0},{"Size":18432,"Mallocs":0,"Frees":0},{"Size":19072,"Mallocs":0,"Frees":0}]}
}

If you plan to run multiple instances of Sauce Connect Proxy on a single machine and wish to access the health metrics of each tunnel, then you''ll need to assign a unique port to each instance of Sauce Connect Proxy that is running.

 Click here to see an example...

For example, if we were to start two instances of Sauce Connect Proxy on the same machine, using the following commands in the code block below, then the metrics for SCP1 would be available at http://localhost:8001/debug/vars. Similarly, SCP2's metrics would be available at http://localhost:8000/debug/vars.

>./sc --user *** --api-key *** --metrics-address localhost:8000 --se-port 4445 --tunnel-identifier SCP1 --pidfile SCP1
>...
>./sc --user *** --api-key *** --metrics-address localhost:8001 --se-port 4446 --tunnel-identifier SCP2 --pidfile SCP2

NOTE: If you start multiple instances of Sauce Connect Proxy without assigning unique ports, this would not affect their normal operations, however, only the first instance of Sauce Connect Proxy started to the duplicated port would be available.

Specifying a Custom URL for Client Metrics

If you wish to customize the URL where metrics are served, you can do so by adding an entry to the host file on the machine where Sauce Connect Proxy is running and then updating the --metrics-address command-line arguments when starting Sauce Connect Proxy.

For example, let's say we want to have the metrics available at http://tunnelmetrics.com:8080/debug/vars. In order to accomplish this, add the entry '127.0.0.1 tunnelmetrics.com' to the host file where Sauce Connect Proxy is running.

 Click here to see an example host file...

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
fe80::1%lo0 localhost
127.0.0.1 tunnelmetrics.com

Once the host file has been altered, start Sauce Connect Proxy with the added argument '--metrics-address tunnelmetrics.com:8080'. Then, on the machine hosting Sauce Connect Proxy, you will see the metrics served at http://tunnelmetrics.com:8080/debug/vars.