Skip to content

2649 - Change receiver obsreport helpers pattern to match the Processor/Exporter#3227

Merged
bogdandrutu merged 13 commits intoopen-telemetry:mainfrom
humivo:2649-ChangeReceiverPattern
May 20, 2021
Merged

2649 - Change receiver obsreport helpers pattern to match the Processor/Exporter#3227
bogdandrutu merged 13 commits intoopen-telemetry:mainfrom
humivo:2649-ChangeReceiverPattern

Conversation

@humivo
Copy link
Copy Markdown
Member

@humivo humivo commented May 18, 2021

Description: Change obsreport helpers for receiver to use the same pattern with structs and helpers as Processor/Exporter.

Link to tracking Issue: Issue #2649

@humivo humivo requested a review from a team May 18, 2021 21:27

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})
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member Author

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

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})
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member Author

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.

Copy link
Copy Markdown
Member

@bogdandrutu bogdandrutu left a 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

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})
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member Author

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


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})
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member Author

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


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})
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member Author

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


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})
Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member Author

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

@bogdandrutu
Copy link
Copy Markdown
Member

@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.

@humivo
Copy link
Copy Markdown
Member Author

humivo commented May 19, 2021

@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.

@bogdandrutu
Copy link
Copy Markdown
Member

Let's do the deprecation one, so I can ensure myself that I will not be the one doing it :)))

@humivo
Copy link
Copy Markdown
Member Author

humivo commented May 19, 2021

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

@bogdandrutu
Copy link
Copy Markdown
Member

@humivo waiting for that :)

@humivo
Copy link
Copy Markdown
Member Author

humivo commented May 20, 2021

@humivo waiting for that :)

Yup sorry for the delay! Just made the fix.

@bogdandrutu bogdandrutu merged commit f7674b2 into open-telemetry:main May 20, 2021
dashpole pushed a commit to dashpole/opentelemetry-collector that referenced this pull request Jun 14, 2021
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants