opentelemetry-dotnet-contrib
opentelemetry-dotnet-contrib copied to clipboard
Hangfire scheduling does not get instrumentated
Issue with OpenTelemetry.Instrumentation.Hangfire
List of all OpenTelemetry NuGet
packages and version that you are
using (e.g. OpenTelemetry 1.3.2):
<PackageReference Include="OpenTelemetry.Instrumentation.Hangfire" Version="1.6.0-beta.1" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.4.0-beta.3" />
<PackageReference Include="OpenTelemetry.Extensions.Propagators" Version="1.4.0-beta.3" />
<PackageReference Include="Hangfire.Core" Version="1.8.7" />
<PackageReference Include="HangFire.Redis.StackExchange" Version="1.9.3" />
<!-- Only for Tests -->
<PackageReference Include="Hangfire.MemoryStorage" Version="1.8.0" />
Runtime version (e.g. net462, net48, net6.0, net7.0 etc. You can
find this information from the *.csproj file):
net6.0
Is this a feature request or a bug?
- [x] Feature Request
- [ ] Bug
What is the expected behavior?
Hangfire should create a span when scheduling the job.
What is the actual behavior?
Hangfire will not create any activity when scheduling a message. Scheduled jobs doesn't get traced, only when executed.
Additional Context
I think the current implementation of hangfire filter will not be able to notify when the job is scheduled.
@fred2u Could you take a look at this?
Hi, I encountered similar problem. In my case Reccuring Jobs didn't send any trace data. I've noticed that Reccuring Jobs are first handled by HangfireInstrumentationJobFilterAttribute.OnCreating method which does not occure when we just enqueue Job using BackgroundJobClient. Implementing your own JobFilter with the same implementation as HangfireInstrumentationJobFilterAttribute aside from OnCreating and OnCreated methods do the work. Note that this might not be a perfect workaround.