1

We have a distributed system and I am working on a ticket to add attributes to the Open Telemetry traces for NewRelic. In dotnet this is done by setting tags, like so:

Activity.Current.SetTag("bf.my_attribute", "myAttributeValue");

Because the messages are coming from MassTransit (MT), I created a custom Filter to add to the MT pipeline. So far so good. But given that this is part of a library and not the Service itself, I can only perform Unit tests, no integration ones.

My question is, how do I test it? The static Activity class is null in my tests. Any ideas?

1
  • Did you try to create an Activity and then call Start on that instance. That should make it Current. You can do this in TestSetup and dispose in TestCleanup. Commented May 5, 2024 at 20:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.