|
@@ -20,20 +20,67 @@ import (
|
|
"go.opencensus.io/tag"
|
|
"go.opencensus.io/tag"
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+// Deprecated: client HTTP measures.
|
|
|
|
+var (
|
|
|
|
+ // Deprecated: Use a Count aggregation over one of the other client measures to achieve the same effect.
|
|
|
|
+ ClientRequestCount = stats.Int64(
|
|
|
|
+ "opencensus.io/http/client/request_count",
|
|
|
|
+ "Number of HTTP requests started",
|
|
|
|
+ stats.UnitDimensionless)
|
|
|
|
+ // Deprecated: Use ClientSentBytes.
|
|
|
|
+ ClientRequestBytes = stats.Int64(
|
|
|
|
+ "opencensus.io/http/client/request_bytes",
|
|
|
|
+ "HTTP request body size if set as ContentLength (uncompressed)",
|
|
|
|
+ stats.UnitBytes)
|
|
|
|
+ // Deprecated: Use ClientReceivedBytes.
|
|
|
|
+ ClientResponseBytes = stats.Int64(
|
|
|
|
+ "opencensus.io/http/client/response_bytes",
|
|
|
|
+ "HTTP response body size (uncompressed)",
|
|
|
|
+ stats.UnitBytes)
|
|
|
|
+ // Deprecated: Use ClientRoundtripLatency.
|
|
|
|
+ ClientLatency = stats.Float64(
|
|
|
|
+ "opencensus.io/http/client/latency",
|
|
|
|
+ "End-to-end latency",
|
|
|
|
+ stats.UnitMilliseconds)
|
|
|
|
+)
|
|
|
|
+
|
|
// The following client HTTP measures are supported for use in custom views.
|
|
// The following client HTTP measures are supported for use in custom views.
|
|
var (
|
|
var (
|
|
- ClientRequestCount = stats.Int64("opencensus.io/http/client/request_count", "Number of HTTP requests started", stats.UnitDimensionless)
|
|
|
|
- ClientRequestBytes = stats.Int64("opencensus.io/http/client/request_bytes", "HTTP request body size if set as ContentLength (uncompressed)", stats.UnitBytes)
|
|
|
|
- ClientResponseBytes = stats.Int64("opencensus.io/http/client/response_bytes", "HTTP response body size (uncompressed)", stats.UnitBytes)
|
|
|
|
- ClientLatency = stats.Float64("opencensus.io/http/client/latency", "End-to-end latency", stats.UnitMilliseconds)
|
|
|
|
|
|
+ ClientSentBytes = stats.Int64(
|
|
|
|
+ "opencensus.io/http/client/sent_bytes",
|
|
|
|
+ "Total bytes sent in request body (not including headers)",
|
|
|
|
+ stats.UnitBytes,
|
|
|
|
+ )
|
|
|
|
+ ClientReceivedBytes = stats.Int64(
|
|
|
|
+ "opencensus.io/http/client/received_bytes",
|
|
|
|
+ "Total bytes received in response bodies (not including headers but including error responses with bodies)",
|
|
|
|
+ stats.UnitBytes,
|
|
|
|
+ )
|
|
|
|
+ ClientRoundtripLatency = stats.Float64(
|
|
|
|
+ "opencensus.io/http/client/roundtrip_latency",
|
|
|
|
+ "Time between first byte of request headers sent to last byte of response received, or terminal error",
|
|
|
|
+ stats.UnitMilliseconds,
|
|
|
|
+ )
|
|
)
|
|
)
|
|
|
|
|
|
// The following server HTTP measures are supported for use in custom views:
|
|
// The following server HTTP measures are supported for use in custom views:
|
|
var (
|
|
var (
|
|
- ServerRequestCount = stats.Int64("opencensus.io/http/server/request_count", "Number of HTTP requests started", stats.UnitDimensionless)
|
|
|
|
- ServerRequestBytes = stats.Int64("opencensus.io/http/server/request_bytes", "HTTP request body size if set as ContentLength (uncompressed)", stats.UnitBytes)
|
|
|
|
- ServerResponseBytes = stats.Int64("opencensus.io/http/server/response_bytes", "HTTP response body size (uncompressed)", stats.UnitBytes)
|
|
|
|
- ServerLatency = stats.Float64("opencensus.io/http/server/latency", "End-to-end latency", stats.UnitMilliseconds)
|
|
|
|
|
|
+ ServerRequestCount = stats.Int64(
|
|
|
|
+ "opencensus.io/http/server/request_count",
|
|
|
|
+ "Number of HTTP requests started",
|
|
|
|
+ stats.UnitDimensionless)
|
|
|
|
+ ServerRequestBytes = stats.Int64(
|
|
|
|
+ "opencensus.io/http/server/request_bytes",
|
|
|
|
+ "HTTP request body size if set as ContentLength (uncompressed)",
|
|
|
|
+ stats.UnitBytes)
|
|
|
|
+ ServerResponseBytes = stats.Int64(
|
|
|
|
+ "opencensus.io/http/server/response_bytes",
|
|
|
|
+ "HTTP response body size (uncompressed)",
|
|
|
|
+ stats.UnitBytes)
|
|
|
|
+ ServerLatency = stats.Float64(
|
|
|
|
+ "opencensus.io/http/server/latency",
|
|
|
|
+ "End-to-end latency",
|
|
|
|
+ stats.UnitMilliseconds)
|
|
)
|
|
)
|
|
|
|
|
|
// The following tags are applied to stats recorded by this package. Host, Path
|
|
// The following tags are applied to stats recorded by this package. Host, Path
|
|
@@ -41,28 +88,89 @@ var (
|
|
// ClientRequestCount or ServerRequestCount, since it is recorded before the status is known.
|
|
// ClientRequestCount or ServerRequestCount, since it is recorded before the status is known.
|
|
var (
|
|
var (
|
|
// Host is the value of the HTTP Host header.
|
|
// Host is the value of the HTTP Host header.
|
|
- Host, _ = tag.NewKey("http.host")
|
|
|
|
|
|
+ //
|
|
|
|
+ // The value of this tag can be controlled by the HTTP client, so you need
|
|
|
|
+ // to watch out for potentially generating high-cardinality labels in your
|
|
|
|
+ // metrics backend if you use this tag in views.
|
|
|
|
+ Host = tag.MustNewKey("http.host")
|
|
|
|
|
|
// StatusCode is the numeric HTTP response status code,
|
|
// StatusCode is the numeric HTTP response status code,
|
|
// or "error" if a transport error occurred and no status code was read.
|
|
// or "error" if a transport error occurred and no status code was read.
|
|
- StatusCode, _ = tag.NewKey("http.status")
|
|
|
|
|
|
+ StatusCode = tag.MustNewKey("http.status")
|
|
|
|
|
|
// Path is the URL path (not including query string) in the request.
|
|
// Path is the URL path (not including query string) in the request.
|
|
- Path, _ = tag.NewKey("http.path")
|
|
|
|
|
|
+ //
|
|
|
|
+ // The value of this tag can be controlled by the HTTP client, so you need
|
|
|
|
+ // to watch out for potentially generating high-cardinality labels in your
|
|
|
|
+ // metrics backend if you use this tag in views.
|
|
|
|
+ Path = tag.MustNewKey("http.path")
|
|
|
|
|
|
// Method is the HTTP method of the request, capitalized (GET, POST, etc.).
|
|
// Method is the HTTP method of the request, capitalized (GET, POST, etc.).
|
|
- Method, _ = tag.NewKey("http.method")
|
|
|
|
|
|
+ Method = tag.MustNewKey("http.method")
|
|
|
|
+
|
|
|
|
+ // KeyServerRoute is a low cardinality string representing the logical
|
|
|
|
+ // handler of the request. This is usually the pattern registered on the a
|
|
|
|
+ // ServeMux (or similar string).
|
|
|
|
+ KeyServerRoute = tag.MustNewKey("http_server_route")
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+// Client tag keys.
|
|
|
|
+var (
|
|
|
|
+ // KeyClientMethod is the HTTP method, capitalized (i.e. GET, POST, PUT, DELETE, etc.).
|
|
|
|
+ KeyClientMethod = tag.MustNewKey("http_client_method")
|
|
|
|
+ // KeyClientPath is the URL path (not including query string).
|
|
|
|
+ KeyClientPath = tag.MustNewKey("http_client_path")
|
|
|
|
+ // KeyClientStatus is the HTTP status code as an integer (e.g. 200, 404, 500.), or "error" if no response status line was received.
|
|
|
|
+ KeyClientStatus = tag.MustNewKey("http_client_status")
|
|
|
|
+ // KeyClientHost is the value of the request Host header.
|
|
|
|
+ KeyClientHost = tag.MustNewKey("http_client_host")
|
|
)
|
|
)
|
|
|
|
|
|
// Default distributions used by views in this package.
|
|
// Default distributions used by views in this package.
|
|
var (
|
|
var (
|
|
- DefaultSizeDistribution = view.Distribution(0, 1024, 2048, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864, 268435456, 1073741824, 4294967296)
|
|
|
|
- DefaultLatencyDistribution = view.Distribution(0, 1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 25, 30, 40, 50, 65, 80, 100, 130, 160, 200, 250, 300, 400, 500, 650, 800, 1000, 2000, 5000, 10000, 20000, 50000, 100000)
|
|
|
|
|
|
+ DefaultSizeDistribution = view.Distribution(1024, 2048, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864, 268435456, 1073741824, 4294967296)
|
|
|
|
+ DefaultLatencyDistribution = view.Distribution(1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 25, 30, 40, 50, 65, 80, 100, 130, 160, 200, 250, 300, 400, 500, 650, 800, 1000, 2000, 5000, 10000, 20000, 50000, 100000)
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+// Package ochttp provides some convenience views for client measures.
|
|
|
|
+// You still need to register these views for data to actually be collected.
|
|
|
|
+var (
|
|
|
|
+ ClientSentBytesDistribution = &view.View{
|
|
|
|
+ Name: "opencensus.io/http/client/sent_bytes",
|
|
|
|
+ Measure: ClientSentBytes,
|
|
|
|
+ Aggregation: DefaultSizeDistribution,
|
|
|
|
+ Description: "Total bytes sent in request body (not including headers), by HTTP method and response status",
|
|
|
|
+ TagKeys: []tag.Key{KeyClientMethod, KeyClientStatus},
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ClientReceivedBytesDistribution = &view.View{
|
|
|
|
+ Name: "opencensus.io/http/client/received_bytes",
|
|
|
|
+ Measure: ClientReceivedBytes,
|
|
|
|
+ Aggregation: DefaultSizeDistribution,
|
|
|
|
+ Description: "Total bytes received in response bodies (not including headers but including error responses with bodies), by HTTP method and response status",
|
|
|
|
+ TagKeys: []tag.Key{KeyClientMethod, KeyClientStatus},
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ClientRoundtripLatencyDistribution = &view.View{
|
|
|
|
+ Name: "opencensus.io/http/client/roundtrip_latency",
|
|
|
|
+ Measure: ClientRoundtripLatency,
|
|
|
|
+ Aggregation: DefaultLatencyDistribution,
|
|
|
|
+ Description: "End-to-end latency, by HTTP method and response status",
|
|
|
|
+ TagKeys: []tag.Key{KeyClientMethod, KeyClientStatus},
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ClientCompletedCount = &view.View{
|
|
|
|
+ Name: "opencensus.io/http/client/completed_count",
|
|
|
|
+ Measure: ClientRoundtripLatency,
|
|
|
|
+ Aggregation: view.Count(),
|
|
|
|
+ Description: "Count of completed requests, by HTTP method and response status",
|
|
|
|
+ TagKeys: []tag.Key{KeyClientMethod, KeyClientStatus},
|
|
|
|
+ }
|
|
)
|
|
)
|
|
|
|
|
|
-// Package ochttp provides some convenience views.
|
|
|
|
-// You need to subscribe to the views for data to actually be collected.
|
|
|
|
|
|
+// Deprecated: Old client Views.
|
|
var (
|
|
var (
|
|
|
|
+ // Deprecated: No direct replacement, but see ClientCompletedCount.
|
|
ClientRequestCountView = &view.View{
|
|
ClientRequestCountView = &view.View{
|
|
Name: "opencensus.io/http/client/request_count",
|
|
Name: "opencensus.io/http/client/request_count",
|
|
Description: "Count of HTTP requests started",
|
|
Description: "Count of HTTP requests started",
|
|
@@ -70,43 +178,52 @@ var (
|
|
Aggregation: view.Count(),
|
|
Aggregation: view.Count(),
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Deprecated: Use ClientSentBytesDistribution.
|
|
ClientRequestBytesView = &view.View{
|
|
ClientRequestBytesView = &view.View{
|
|
Name: "opencensus.io/http/client/request_bytes",
|
|
Name: "opencensus.io/http/client/request_bytes",
|
|
Description: "Size distribution of HTTP request body",
|
|
Description: "Size distribution of HTTP request body",
|
|
- Measure: ClientRequestBytes,
|
|
|
|
|
|
+ Measure: ClientSentBytes,
|
|
Aggregation: DefaultSizeDistribution,
|
|
Aggregation: DefaultSizeDistribution,
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Deprecated: Use ClientReceivedBytesDistribution instead.
|
|
ClientResponseBytesView = &view.View{
|
|
ClientResponseBytesView = &view.View{
|
|
Name: "opencensus.io/http/client/response_bytes",
|
|
Name: "opencensus.io/http/client/response_bytes",
|
|
Description: "Size distribution of HTTP response body",
|
|
Description: "Size distribution of HTTP response body",
|
|
- Measure: ClientResponseBytes,
|
|
|
|
|
|
+ Measure: ClientReceivedBytes,
|
|
Aggregation: DefaultSizeDistribution,
|
|
Aggregation: DefaultSizeDistribution,
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Deprecated: Use ClientRoundtripLatencyDistribution instead.
|
|
ClientLatencyView = &view.View{
|
|
ClientLatencyView = &view.View{
|
|
Name: "opencensus.io/http/client/latency",
|
|
Name: "opencensus.io/http/client/latency",
|
|
Description: "Latency distribution of HTTP requests",
|
|
Description: "Latency distribution of HTTP requests",
|
|
- Measure: ClientLatency,
|
|
|
|
|
|
+ Measure: ClientRoundtripLatency,
|
|
Aggregation: DefaultLatencyDistribution,
|
|
Aggregation: DefaultLatencyDistribution,
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Deprecated: Use ClientCompletedCount instead.
|
|
ClientRequestCountByMethod = &view.View{
|
|
ClientRequestCountByMethod = &view.View{
|
|
Name: "opencensus.io/http/client/request_count_by_method",
|
|
Name: "opencensus.io/http/client/request_count_by_method",
|
|
Description: "Client request count by HTTP method",
|
|
Description: "Client request count by HTTP method",
|
|
TagKeys: []tag.Key{Method},
|
|
TagKeys: []tag.Key{Method},
|
|
- Measure: ClientRequestCount,
|
|
|
|
|
|
+ Measure: ClientSentBytes,
|
|
Aggregation: view.Count(),
|
|
Aggregation: view.Count(),
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Deprecated: Use ClientCompletedCount instead.
|
|
ClientResponseCountByStatusCode = &view.View{
|
|
ClientResponseCountByStatusCode = &view.View{
|
|
Name: "opencensus.io/http/client/response_count_by_status_code",
|
|
Name: "opencensus.io/http/client/response_count_by_status_code",
|
|
Description: "Client response count by status code",
|
|
Description: "Client response count by status code",
|
|
TagKeys: []tag.Key{StatusCode},
|
|
TagKeys: []tag.Key{StatusCode},
|
|
- Measure: ClientLatency,
|
|
|
|
|
|
+ Measure: ClientRoundtripLatency,
|
|
Aggregation: view.Count(),
|
|
Aggregation: view.Count(),
|
|
}
|
|
}
|
|
|
|
+)
|
|
|
|
|
|
|
|
+// Package ochttp provides some convenience views for server measures.
|
|
|
|
+// You still need to register these views for data to actually be collected.
|
|
|
|
+var (
|
|
ServerRequestCountView = &view.View{
|
|
ServerRequestCountView = &view.View{
|
|
Name: "opencensus.io/http/server/request_count",
|
|
Name: "opencensus.io/http/server/request_count",
|
|
Description: "Count of HTTP requests started",
|
|
Description: "Count of HTTP requests started",
|
|
@@ -153,6 +270,7 @@ var (
|
|
)
|
|
)
|
|
|
|
|
|
// DefaultClientViews are the default client views provided by this package.
|
|
// DefaultClientViews are the default client views provided by this package.
|
|
|
|
+// Deprecated: No replacement. Register the views you would like individually.
|
|
var DefaultClientViews = []*view.View{
|
|
var DefaultClientViews = []*view.View{
|
|
ClientRequestCountView,
|
|
ClientRequestCountView,
|
|
ClientRequestBytesView,
|
|
ClientRequestBytesView,
|
|
@@ -163,6 +281,7 @@ var DefaultClientViews = []*view.View{
|
|
}
|
|
}
|
|
|
|
|
|
// DefaultServerViews are the default server views provided by this package.
|
|
// DefaultServerViews are the default server views provided by this package.
|
|
|
|
+// Deprecated: No replacement. Register the views you would like individually.
|
|
var DefaultServerViews = []*view.View{
|
|
var DefaultServerViews = []*view.View{
|
|
ServerRequestCountView,
|
|
ServerRequestCountView,
|
|
ServerRequestBytesView,
|
|
ServerRequestBytesView,
|