2649 - Change receiver obsreport helpers pattern to match the Processor/Exporter#3227
Conversation
|
|
||
| ctx := obsreport.ReceiverContext(session.Context(), c.id, transport) | ||
| ctx = obsreport.StartTraceDataReceiveOp(ctx, c.id, transport) | ||
| rec := obsreport.NewReceiver(obsreport.ReceiverSettings{ReceiverID: c.id, Transport: transport}) |
There was a problem hiding this comment.
Same here, you can cache to object. Please apply the caching to all the non-test code where you can.
There was a problem hiding this comment.
Ok I applied to caching to all non-test code in my latest commit
| transportTag := transportType(r, asZipkinv1) | ||
| ctx = obsreport.ReceiverContext(ctx, zr.id, transportTag) | ||
| ctx = obsreport.StartTraceDataReceiveOp(ctx, zr.id, transportTag) | ||
| zr.receiver = obsreport.NewReceiver(obsreport.ReceiverSettings{ReceiverID: zr.id, Transport: transportTag}) |
There was a problem hiding this comment.
Here you cannot "cache" since you don't know the transport (actually it will cause a race condition). you cannot do things blindly :) Please check everywhere if that is the case.
There was a problem hiding this comment.
Ohhh ok I thought so. I just fixed this in the latest commit. I think that was the only place where we do not know the transport.
bogdandrutu
left a comment
There was a problem hiding this comment.
Same comments apply everywhere
| func (h *agentHandler) EmitBatch(ctx context.Context, batch *jaeger.Batch) error { | ||
| ctx = obsreport.ReceiverContext(ctx, h.id, h.transport) | ||
| ctx = obsreport.StartTraceDataReceiveOp(ctx, h.id, h.transport) | ||
| h.obsrecv = obsreport.NewReceiver(obsreport.ReceiverSettings{ReceiverID: h.id, Transport: h.transport}) |
There was a problem hiding this comment.
What about here? Does seem that you initialize the obsrecv every request so you will have a race. Probably initialize in the ctor if transport is known.
There was a problem hiding this comment.
Now initialized in the ctor in latest commit
|
|
||
| ctx = obsreport.ReceiverContext(ctx, jr.id, grpcTransport) | ||
| ctx = obsreport.StartTraceDataReceiveOp(ctx, jr.id, grpcTransport) | ||
| jr.obsrecv = obsreport.NewReceiver(obsreport.ReceiverSettings{ReceiverID: jr.id, Transport: grpcTransport}) |
There was a problem hiding this comment.
Same here. Or have different instances per transport is better.
There was a problem hiding this comment.
Initialized in ctor with different instances per transport
|
|
||
| ctx = obsreport.ReceiverContext(ctx, jr.id, collectorHTTPTransport) | ||
| ctx = obsreport.StartTraceDataReceiveOp(ctx, jr.id, collectorHTTPTransport) | ||
| jr.obsrecv = obsreport.NewReceiver(obsreport.ReceiverSettings{ReceiverID: jr.id, Transport: collectorHTTPTransport}) |
There was a problem hiding this comment.
Same here you modify the same variable.
There was a problem hiding this comment.
Now initialized in the ctor in latest commit
|
|
||
| ctx := obsreport.ReceiverContext(session.Context(), c.id, transport) | ||
| ctx = obsreport.StartTraceDataReceiveOp(ctx, c.id, transport) | ||
| c.obsrecv = obsreport.NewReceiver(obsreport.ReceiverSettings{ReceiverID: c.id, Transport: transport}) |
There was a problem hiding this comment.
You re-initialize the variable every request, this is not caching, you need to initialize it in the ctor of the tracesConsumerGroupHandler
There was a problem hiding this comment.
Now initialized in the ctor in latest commit
|
@humivo are you ready to also upgrade contrib right away? Otherwise better to keep as deprecated the old funcs and implement them as NewReceiver + calls into the new funcs, then we can upgrade contrib and change receivers one by one. |
Yes I will be ready to upgrade the contrib right away. But I am open to whichever option is preferred. |
|
Let's do the deprecation one, so I can ensure myself that I will not be the one doing it :))) |
Ok I'll update the PR right now with the deprecated old funcs |
|
@humivo waiting for that :) |
Yup sorry for the delay! Just made the fix. |
…or/Exporter (open-telemetry#3227) * Change Receiver to match pattern with structs and helpers * Added support for ReceiverSettings * Add receiver to end functions * Add comments for new receiver * Add entry to changelog * Cache the recevier in structs * Cache the receiver in other files * Fix name for var and fix caching * Fix caching so there is no race * Fix unit tests * Add deprecated old funcs back * Fix comments
Description: Change obsreport helpers for receiver to use the same pattern with structs and helpers as Processor/Exporter.
Link to tracking Issue: Issue #2649