Skip to content
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

"Can not start an Activity that was already started" in BaseProducer #327

Open
gius opened this issue Mar 31, 2024 · 0 comments
Open

"Can not start an Activity that was already started" in BaseProducer #327

gius opened this issue Mar 31, 2024 · 0 comments

Comments

@gius
Copy link

gius commented Mar 31, 2024

Describe the bug
When producing an event, System.InvalidOperationException: '"Can not start an Activity that was already started"' is thrown (and immediately swallowed) by System.Diagnostics.DiagnosticSource.dll!System.Diagnostics.Activity.NotifyError(System.Exception exception).

The reason is that in BaseProducer.Produce, we explicitly call act?.Start(), but the activity has already been started by the previous line's call to ProducerActivity.Start.

var (act, producedMessage) = ProducerActivity.Start(messagesArray[0], DefaultTags);
return (act?.Start(), new[] { producedMessage });

To Reproduce
Steps to reproduce the behavior:

  1. Enable Break When Thrown for System.InvalidOperationException in Visual Studio's Exception Settings
  2. Publish an event through RabbitMqProducer
  3. See error

Expected behavior
No exception should be thrown.

I can provide a PR if you want. As far as I can understand, simply changing

return (act?.Start(), new[] { producedMessage });
to return (act, new[] { producedMessage }); should be enough.

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

No branches or pull requests

1 participant