1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-04 09:43:23 +02:00

Build context pipeline in Jaeger upload process (#1809)

This commit is contained in:
Tyler Yahn 2021-04-19 14:27:22 +00:00 committed by GitHub
parent 2de86f23c3
commit a2bf04dc36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 9 deletions

View File

@ -111,9 +111,9 @@ func newAgentClientUDP(params agentClientUDPParams) (*agentClientUDP, error) {
}
// EmitBatch implements EmitBatch() of Agent interface
func (a *agentClientUDP) EmitBatch(batch *gen.Batch) error {
func (a *agentClientUDP) EmitBatch(ctx context.Context, batch *gen.Batch) error {
a.thriftBuffer.Reset()
if err := a.client.EmitBatch(context.Background(), batch); err != nil {
if err := a.client.EmitBatch(ctx, batch); err != nil {
return err
}
if a.thriftBuffer.Len() > a.maxPacketSize {

View File

@ -433,7 +433,8 @@ func (e *Exporter) Flush() {
func (e *Exporter) upload(spans []*sdktrace.SpanSnapshot) error {
batchList := jaegerBatchList(spans, e.defaultServiceName)
for _, batch := range batchList {
err := e.uploader.upload(batch)
// TODO (MrAlias): pass an appropriate context (#1799, #1803).
err := e.uploader.upload(context.TODO(), batch)
if err != nil {
return err
}

View File

@ -251,7 +251,7 @@ type testCollectorEndpoint struct {
batchesUploaded []*gen.Batch
}
func (c *testCollectorEndpoint) upload(batch *gen.Batch) error {
func (c *testCollectorEndpoint) upload(_ context.Context, batch *gen.Batch) error {
c.batchesUploaded = append(c.batchesUploaded, batch)
return nil
}

View File

@ -32,7 +32,7 @@ import (
// batchUploader send a batch of spans to Jaeger
type batchUploader interface {
upload(batch *gen.Batch) error
upload(ctx context.Context, batch *gen.Batch) error
}
type EndpointOption func() (batchUploader, error)
@ -187,8 +187,8 @@ type agentUploader struct {
var _ batchUploader = (*agentUploader)(nil)
func (a *agentUploader) upload(batch *gen.Batch) error {
return a.client.EmitBatch(batch)
func (a *agentUploader) upload(ctx context.Context, batch *gen.Batch) error {
return a.client.EmitBatch(ctx, batch)
}
// collectorUploader implements batchUploader interface sending batches to
@ -202,12 +202,12 @@ type collectorUploader struct {
var _ batchUploader = (*collectorUploader)(nil)
func (c *collectorUploader) upload(batch *gen.Batch) error {
func (c *collectorUploader) upload(ctx context.Context, batch *gen.Batch) error {
body, err := serialize(batch)
if err != nil {
return err
}
req, err := http.NewRequest("POST", c.endpoint, body)
req, err := http.NewRequestWithContext(ctx, "POST", c.endpoint, body)
if err != nil {
return err
}