• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..09-Nov-2021-

README.mdH A D09-Nov-20212.7 KiB5742

client.goH A D09-Nov-2021688 3125

config.goH A D09-Nov-20211.5 KiB5536

main.goH A D09-Nov-20212 KiB9068

trace.goH A D09-Nov-202111.5 KiB426320

README.md

1# Example
2
3Demonstrates how the Go standard library `httptrace` can be used with the SDK
4to collect HTTP request tracing timing using the SDK's API operation methods
5like SNS's `PublishWithContext`.
6
7The `trace.go` file demonstrates how the `httptrace` package's `ClientTrace`
8can be created to gather timing information from HTTP requests made.
9
10The `config.go` file provides additional configuration settings to control how
11the HTTP client and its transport is configured. Such as, timeouts, and
12keepalive.
13
14## Usage
15
16Run the example providing your SNS topic's ARN as the `-topic` parameter. This
17example assumes that the region is provided via the environment variable and
18the AWS shared credentials file (~/.aws/credentials)'s `default` provide
19provides credentials.
20
21```sh
22AWS_REGION=us-west-2 go run -tags example . -topic arn:aws:sns:us-west-2:0123456789:mytopicname
23```
24
25Once the example starts you'll be prompted with a `Message:` statement. Input
26the message that you'd like to send to the topic on a single line and hit
27`enter` to send it.
28
29```
30Message: My Really cool Message
31```
32
33The example will output the http trace timing information for how long the request took.
34
35```
362020/07/21 15:39:07 Latency: 278.508656ms, Validate: 19.515µs, Build: 190.755µs, Attempts: 1,
37	Attempt: 0, Latency: 278.240054ms, Sign: 453.163µs, Send: 277.580235ms, Unmarshal: 202.311µs, WillRetry: false,
38		HTTP: Latency: 277.580856ms, ConnReused: false, GetConn: 225.662398ms, WriteRequest: 325.956µs, WaitResponseFirstByte: 277.509316ms, ReadResponseHeader: 71.234µs,
39			Conn: DNS: 20.385136ms, Connect: 14.947772ms, TLS: 189.910822ms,
40
41Message: second
422020/07/21 15:39:09 Latency: 101.936094ms, Validate: 2.644µs, Build: 67.157µs, Attempts: 1,
43	Attempt: 0, Latency: 101.836442ms, Sign: 122.098µs, Send: 101.517516ms, Unmarshal: 191.31µs, WillRetry: false,
44		HTTP: Latency: 101.518147ms, ConnReused: true, GetConn: 38.265µs, WriteRequest: 178.058µs, WaitResponseFirstByte: 101.457147ms, ReadResponseHeader: 60.526µs,
45
46Message: third
472020/07/21 15:39:10 Latency: 32.373919ms, Validate: 2.998µs, Build: 39.136µs, Attempts: 1,
48	Attempt: 0, Latency: 32.295677ms, Sign: 104.978µs, Send: 32.040306ms, Unmarshal: 146.096µs, WillRetry: false,
49		HTTP: Latency: 32.04078ms, ConnReused: true, GetConn: 33.36µs, WriteRequest: 166.508µs, WaitResponseFirstByte: 31.980933ms, ReadResponseHeader: 59.235µs,
50
51Message: fourth
522020/07/21 15:39:13 Latency: 33.353819ms, Validate: 2.002µs, Build: 36.807µs, Attempts: 1,
53	Attempt: 0, Latency: 33.29846ms, Sign: 70.238µs, Send: 33.125914ms, Unmarshal: 98.181µs, WillRetry: false,
54		HTTP: Latency: 33.126453ms, ConnReused: true, GetConn: 47.516µs, WriteRequest: 251.875µs, WaitResponseFirstByte: 33.05992ms, ReadResponseHeader: 66.017µs,
55```
56
57