| 324 | } |
| 325 | |
| 326 | func (c *context) loopbackInternal(discardResponse bool) { |
| 327 | loopSpan := c.tracer.StartSpan(c.proxy.tracing.initialOperationName, opentracing.ChildOf(c.parentSpan.Context())) |
| 328 | defer loopSpan.Finish() |
| 329 | err := c.proxy.do(c, loopSpan) |
| 330 | if discardResponse && c.response != nil && c.response.Body != nil { |
| 331 | if _, err := io.Copy(io.Discard, c.response.Body); err != nil { |
| 332 | c.Logger().Errorf("context: error while discarding remainder response body: %v.", err) |
| 333 | } |
| 334 | err := c.response.Body.Close() |
| 335 | if err != nil { |
| 336 | c.Logger().Errorf("context: error during closing the response body: %v", err) |
| 337 | } |
| 338 | |
| 339 | // span tag `shadow: true` should only be set if the response is discarded |
| 340 | c.proxy.tracing.setTag(c.proxySpan, "shadow", "true") |
| 341 | } |
| 342 | |
| 343 | if c.proxySpan != nil { |
| 344 | c.proxySpan.Finish() |
| 345 | } |
| 346 | |
| 347 | perr, ok := err.(*proxyError) |
| 348 | if ok && perr.handled { |
| 349 | return |
| 350 | } |
| 351 | |
| 352 | if err != nil { |
| 353 | c.Logger().Errorf("context: failed to execute loopback request: %v", err) |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | func (m *filterMetrics) IncCounter(key string) { |
| 358 | m.impl.IncCounter(m.prefix + key) |