Skip to content

Commit

Permalink
Captured metrics for non hedged requests
Browse files Browse the repository at this point in the history
  • Loading branch information
josephwoodward committed Jun 15, 2021
1 parent e3af498 commit fdbaf94
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions tempodb/backend/azure/azure_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,27 @@ func GetContainerURL(ctx context.Context, cfg *Config, hedge bool) (blob.Contain
retryOptions.TryTimeout = time.Until(deadline)
}

var httpSender pipeline.Factory
if hedge && cfg.HedgeRequestsAt != 0 {
httpSender = pipeline.FactoryFunc(func(next pipeline.Policy, po *pipeline.PolicyOptions) pipeline.PolicyFunc {
return func(ctx context.Context, request pipeline.Request) (pipeline.Response, error) {
httpSender := pipeline.FactoryFunc(func(next pipeline.Policy, po *pipeline.PolicyOptions) pipeline.PolicyFunc {
return func(ctx context.Context, request pipeline.Request) (pipeline.Response, error) {

customTransport := http.DefaultTransport.(*http.Transport).Clone()
customTransport := http.DefaultTransport.(*http.Transport).Clone()

transport := newInstrumentedTransport(customTransport)
// add instrumentation
transport := newInstrumentedTransport(customTransport)

// hedge if desired (0 means disabled)
if hedge && cfg.HedgeRequestsAt != 0 {
transport = hedgedhttp.NewRoundTripper(cfg.HedgeRequestsAt, uptoHedgedRequests, transport)
}

client := http.Client{Transport: transport}
client := http.Client{Transport: transport}

// Send the request over the network
resp, err := client.Do(request.WithContext(ctx))
// Send the request over the network
resp, err := client.Do(request.WithContext(ctx))

return pipeline.NewHTTPResponse(resp), err
}
})
}
return pipeline.NewHTTPResponse(resp), err
}
})

p := blob.NewPipeline(c, blob.PipelineOptions{
Retry: retryOptions,
Expand Down

0 comments on commit fdbaf94

Please sign in to comment.