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

Azure service bus new relic distributed tracing headers #102

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

<ItemGroup>
<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.13.1" />
<PackageReference Include="NewRelic.Agent.Api" Version="10.2.0" />
</ItemGroup>
<ItemGroup>
<None Include="knighbus-64.png" Pack="true" Visible="false" PackagePath="" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ private async Task<ServiceBusMessage> CreateMessageAsync<T>(T body) where T : IM
}
}

NewRelic.Api.Agent.NewRelic.GetAgent().CurrentTransaction.InsertDistributedTraceHeaders(message.ApplicationProperties,
((carrier, key, value) =>
{
carrier.Add(key, value);
}));

return message;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using KnightBus.Core;
Expand All @@ -22,6 +23,9 @@ public async Task ProcessAsync<T>(IMessageStateHandler<T> messageStateHandler, I
var messageName = typeof(T).FullName;
NewRelic.Api.Agent.NewRelic.SetTransactionName("Message", messageName);
var transaction = _agent.CurrentTransaction;
transaction.AcceptDistributedTraceHeaders(messageStateHandler.MessageProperties,
((carrier, key) => carrier.TryGetValue(key, out var value) ? new[] { value } : null),
TransportType.AMQP);
try
{
await next.ProcessAsync(messageStateHandler, cancellationToken).ConfigureAwait(false);
Expand Down
Loading