Add support for tracing via OpenCencus
This adds a few flags for configuring the tracer. Includes support for jaeger tracing (built into OC).
This commit is contained in:
@@ -4,6 +4,10 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"go.opencensus.io/plugin/ochttp/propagation/b3"
|
||||
|
||||
"go.opencensus.io/plugin/ochttp"
|
||||
|
||||
azure "github.com/virtual-kubelet/virtual-kubelet/providers/azure/client"
|
||||
)
|
||||
|
||||
@@ -40,6 +44,12 @@ func NewClient(auth *azure.Authentication) (*Client, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Creating Azure client failed: %v", err)
|
||||
}
|
||||
hc := client.HTTPClient
|
||||
hc.Transport = &ochttp.Transport{
|
||||
Base: hc.Transport,
|
||||
Propagation: &b3.HTTPFormat{},
|
||||
NewClientTrace: ochttp.NewSpanAnnotatingClientTrace,
|
||||
}
|
||||
|
||||
return &Client{hc: client.HTTPClient, auth: auth}, nil
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ func (c *Client) GetContainerGroup(ctx context.Context, resourceGroup, container
|
||||
|
||||
// Decode the body from the response.
|
||||
if resp.Body == nil {
|
||||
return nil, errors.New("Create container group returned an empty body in the response"), &resp.StatusCode
|
||||
return nil, errors.New("Get container group returned an empty body in the response"), &resp.StatusCode
|
||||
}
|
||||
var cg ContainerGroup
|
||||
if err := json.NewDecoder(resp.Body).Decode(&cg); err != nil {
|
||||
|
||||
@@ -72,7 +72,7 @@ func (c *Client) GetContainerGroupMetrics(ctx context.Context, resourceGroup, co
|
||||
return nil, errors.Wrap(err, "expanding URL with parameters failed")
|
||||
}
|
||||
|
||||
// SEnd the request.
|
||||
// Send the request.
|
||||
resp, err := c.hc.Do(req)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "sending get container group metrics request failed")
|
||||
|
||||
Reference in New Issue
Block a user