-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2649 - Change receiver obsreport helpers pattern to match the Processor/Exporter #3227
2649 - Change receiver obsreport helpers pattern to match the Processor/Exporter #3227
Conversation
@@ -254,7 +254,8 @@ func (c *tracesConsumerGroupHandler) ConsumeClaim(session sarama.ConsumerGroupSe | |||
session.MarkMessage(message, "") | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I applied to caching to all non-test code in my latest commit
@@ -217,7 +219,8 @@ func (zr *ZipkinReceiver) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comments apply everywhere
@@ -239,10 +242,11 @@ func (h *agentHandler) EmitZipkinBatch(context.Context, []*zipkincore.Span) (err | |||
// Jaeger spans received by the Jaeger agent processor. | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now initialized in the ctor in latest commit
@@ -267,12 +271,13 @@ func (jr *jReceiver) PostSpans(ctx context.Context, r *api_v2.PostSpansRequest) | |||
} | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. Or have different instances per transport is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initialized in ctor with different instances per transport
@@ -415,12 +420,13 @@ func (jr *jReceiver) HandleThriftHTTPBatch(w http.ResponseWriter, r *http.Reques | |||
} | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here you modify the same variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now initialized in the ctor in latest commit
@@ -254,7 +258,8 @@ func (c *tracesConsumerGroupHandler) ConsumeClaim(session sarama.ConsumerGroupSe | |||
session.MarkMessage(message, "") | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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