From af5018f64e406aaa646dae066f28de57321ea5ce Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 9 Mar 2020 23:54:35 -0400 Subject: content: convert to Markdown-enabled present inputs Converted blog to Markdown-enabled present (CL 222846) using present2md (CL 222847). For golang/go#33955. Change-Id: Ib39fa1ddd9a46f9c7a62a2ca7b96e117635553e8 Reviewed-on: https://go-review.googlesource.com/c/blog/+/222848 Run-TryBot: Russ Cox Reviewed-by: Andrew Bonventre --- content/http-tracing.article | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'content/http-tracing.article') diff --git a/content/http-tracing.article b/content/http-tracing.article index 710ae60..665ee1a 100644 --- a/content/http-tracing.article +++ b/content/http-tracing.article @@ -1,34 +1,35 @@ -Introducing HTTP Tracing +# Introducing HTTP Tracing 4 Oct 2016 Tags: http, technical +Summary: In Go 1.7 we introduced HTTP tracing, a facility to gather fine-grained information throughout the lifecycle of an HTTP client request. Support for HTTP tracing is provided by the [`net/http/httptrace`](https://golang.org/pkg/net/http/httptrace/) package. The collected information can be used for debugging latency issues, service monitoring, writing adaptive systems, and more. Jaana Burcu Dogan -* Introduction +## Introduction In Go 1.7 we introduced HTTP tracing, a facility to gather fine-grained information throughout the lifecycle of an HTTP client request. -Support for HTTP tracing is provided by the [[https://golang.org/pkg/net/http/httptrace/][`net/http/httptrace`]] +Support for HTTP tracing is provided by the [`net/http/httptrace`](https://golang.org/pkg/net/http/httptrace/) package. The collected information can be used for debugging latency issues, service monitoring, writing adaptive systems, and more. -* HTTP events +## HTTP events The `httptrace` package provides a number of hooks to gather information during an HTTP round trip about a variety of events. These events include: -- Connection creation -- Connection reuse -- DNS lookups -- Writing the request to the wire -- Reading the response + - Connection creation + - Connection reuse + - DNS lookups + - Writing the request to the wire + - Reading the response -* Tracing events +## Tracing events You can enable HTTP tracing by putting an -[[https://golang.org/pkg/net/http/httptrace/#ClientTrace][`*httptrace.ClientTrace`]] -containing hook functions into a request's [[https://golang.org/pkg/context/#Context][`context.Context`]]. -Various [[https://golang.org/pkg/net/http/#RoundTripper][`http.RoundTripper`]] +[`*httptrace.ClientTrace`](https://golang.org/pkg/net/http/httptrace/#ClientTrace) +containing hook functions into a request's [`context.Context`](https://golang.org/pkg/context/#Context). +Various [`http.RoundTripper`](https://golang.org/pkg/net/http/#RoundTripper) implementations report the internal events by looking for context's `*httptrace.ClientTrace` and calling the relevant hook functions. @@ -42,7 +43,7 @@ as an event happens. The program above will print the DNS information as soon as the DNS lookup is complete. It will similarly print connection information when a connection is established to the request's host. -* Tracing with http.Client +## Tracing with http.Client The tracing mechanism is designed to trace the events in the lifecycle of a single `http.Transport.RoundTrip`. However, a client may @@ -67,11 +68,11 @@ If you are an author of a custom `http.RoundTripper` implementation, you can support tracing by checking the request context for an `*httptest.ClientTrace` and invoking the relevant hooks as the events occur. -* Conclusion +## Conclusion HTTP tracing is a valuable addition to Go for those who are interested in debugging HTTP request latency and writing tools for network debugging for outbound traffic. By enabling this new facility, we hope to see HTTP debugging, benchmarking and visualization tools from the community — such as -[[https://github.com/davecheney/httpstat][httpstat]]. +[httpstat](https://github.com/davecheney/httpstat). -- cgit v1.2.3