1

So, I have a console .Net 6 application which runs as a BackgroundService using the extension method UseWindowsService(). In this app, I am using NewRelic custom instrumentations using a newrelic.config file. I have decorated the methods with [Transaction] attributes & also called Newrelic.SetTransactionName("Custom", nameof(MyClass)).

But the in NewRelic instrumentation UI it is showing a different transaction which has name like: OtherTransaction/Message/Kafka/Topic/Consume/Named/MyTopicName where MyTopicName is the topic I am using in the app. The package refs of the project are as below, with specific versions:

<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="5.0.11" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client.Core" Version="5.0.11" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
<PackageReference Include="Confluent.Kafka" Version="2.10.0" /> 
<PackageReference Include="NewRelic.Agent.Api" Version="8.20.262" />
<PackageReference Include="Polly" Version="7.2.2" />
<PackageReference Include="RestSharp" Version="107.3.0" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />

Any idea what could be the issue here? Why the transaction name is not being set as expected. SetTransactionName() is not being called from any other place in my code, it's called only once.

1
  • 1
    I'm getting similar error and getting this error in new relic logs: Agent API Error: An error occurred invoking API method "SetTransactionName" - "System.InvalidOperationException: The API method called is only valid from within a transaction. This error can occur if you call the API method from a thread other than the one the transaction started on. at NewRelic.Agent.Core.Api.AgentApiImplementation.GetCurrentInternalTransaction() at NewRelic.Agent.Core.Api.AgentApiImplementation.SetTransactionName(String category, String name) Commented May 20 at 10:36

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.