Skip to content

[tracing] Add MassTransit 7 integration#8538

Open
chojomok wants to merge 11 commits intomasterfrom
mohammad/mass_transit7
Open

[tracing] Add MassTransit 7 integration#8538
chojomok wants to merge 11 commits intomasterfrom
mohammad/mass_transit7

Conversation

@chojomok
Copy link
Copy Markdown
Collaborator

Summary of changes

Adds auto-instrumentation for MassTransit 7. Produces masstransit.send, masstransit.publish, masstransit.receive, masstransit.consume, masstransit.handle, and masstransit.saga spans, with context propagation across the in-memory, RabbitMQ, AWS SQS/SNS, and Azure Service Bus transports.

This is the first half of a two-part split: MassTransit 8 support is added on top in the stacked follow-up PR. See #8055 for the original combined branch.

Reason for change

Customer-requested support for the MassTransit messaging library. MassTransit is one of the most widely used messaging abstractions in the .NET ecosystem and the only major broker-agnostic library still missing first-class APM coverage.

Implementation details

MassTransit 7 emits DiagnosticSource events (it predates ActivitySource), so instrumentation hangs off a custom observer plus a few targeted CallTarget hooks for things diagnostic events don't cover.

  • tracer/src/Datadog.Trace/DiagnosticListeners/MassTransitDiagnosticObserver.cs — listens for MassTransit.Transport.Send, MassTransit.Transport.Receive, MassTransit.Consumer.Consume, MassTransit.Consumer.Handle, and MassTransit.Saga.RaiseEvent events and creates Datadog spans.
  • tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/MassTransit/ — shared integration code:
    • MassTransitCommon.cs — span creation, tagging, context propagation utilities.
    • ContextPropagation.cs + SendHeadersInjectAdapter.cs — header injection across transports.
    • DuckTypes/ — version-agnostic access to SendContext, ConsumeContext, ReceiveContext, and headers.
    • CallTarget/NotifyFaultedIntegration.cs — captures exceptions from BaseReceiveContext.NotifyFaulted (diagnostic events don't carry the exception).
    • CallTarget/InMemoryTransportMessageIntegration.cs — restores trace context across the in-memory transport's thread boundary.
  • tracer/src/Datadog.Trace/Activity/Handlers/MassTransitActivityHandler.cs — placeholder handler kept here for the MT8 PR to consume. (No-op on this branch; included so the MT8 stack is purely additive.)
  • New IntegrationId.MassTransit and supporting MassTransitTags.
  • RabbitMQ context propagation tweaked to prefer the active scope over context headers when both are present (fixes a duplicate-span issue when MassTransit's RabbitMQ transport is used).

A detailed architecture overview, including known limitations and flake notes, lives in tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/MassTransit-Integration.md.

Test coverage

  • tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/MassTransit7Tests.cs — integration tests covering in-memory, RabbitMQ, and AWS SQS transports, plus a Windows-only in-memory variant.
  • Snapshot verification for each transport: MassTransit7TestsInMemory.verified.txt, MassTransit7TestsInMemoryWindows.verified.txt, MassTransit7TestsRabbitMq.verified.txt, MassTransit7TestsSqs.verified.txt.
  • New sample app tracer/test/test-applications/integrations/Samples.MassTransit7/ exercises the producer / consumer / saga / fault paths against MassTransit 7.3.1.
  • Shared sample helpers under Samples.MassTransit.Shared/ (consumers, contracts, fault observer, deterministic test signal) — reused by the MT8 PR.
  • Package version coverage via PackageVersionsGeneratorDefinitions.json entry for MassTransit7.

Other details

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f4427a70e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

/// </summary>
/// <param name="transactionId">A stable identifier for the transaction being tracked (e.g. a message ID or trace ID).</param>
/// <param name="checkpointName">The logical name of the checkpoint (e.g. "kafka-produce", "http-send").</param>
public static void TrackTransaction(string transactionId, string checkpointName)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore the public DataStreams API

Deleting Datadog.Trace.DataStreams.TrackTransaction removes a public method from the Datadog.Trace.Manual package, so any customer code that adopted this manual DSM API will stop compiling after upgrading the NuGet package. The companion CallTarget was also removed, which means apps pinned to an older manual assembly would lose the transaction-tracking behavior when run with a newer tracer home; keep the API/instrumentation or obsolete it in a compatible release first.

Useful? React with 👍 / 👎.

Comment on lines +35 to +36
var extractedContext = ContextPropagation.ExtractHeadersFromMessage(tracer, messageAttributesProxy);
parentContext = extractedContext.SpanContext;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prefer the active scope over stale SNS headers

When the same PublishRequest instance is published more than once, the _datadog message attribute written by the previous call is still present when this extraction runs, and CreateScope(..., parentContext) then overrides the current active request span with that stale context. That makes the second SNS span/message a child of the previous publish trace; only extract from message attributes when there is no active scope, or clear/overwrite the Datadog attribute before using it as a parent.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the tracer.ActiveScope is null in the if statement checks to prefer thee active scope

@chojomok chojomok force-pushed the mohammad/mass_transit7 branch from f4427a7 to 5027224 Compare April 28, 2026 21:14
Split from mohammad/mass_transit_intg. Contains shared MassTransit
integration code (MassTransitCommon, duck types, diagnostic observer,
generated files, build/sln updates) plus MassTransit 7-specific
sample app, tests, and snapshots. MT8-specific files excluded.
@chojomok chojomok force-pushed the mohammad/mass_transit7 branch from 5027224 to 51efcf3 Compare April 28, 2026 21:45
chojomok and others added 3 commits April 28, 2026 17:53
When the same PublishRequest instance is reused for multiple Publish
calls, the _datadog message attribute from the prior publish lingers
on the request. Extracting it as a parent context made the new SNS
span a child of the previous publish trace.

Mirrors the RabbitMQ producer fix: only extract from message
attributes when there is no active scope.
The ActivitySource-based handler is only used by MassTransit 8.
MT7 instruments via DiagnosticSource (MassTransitDiagnosticObserver)
and does not need this handler.
@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented Apr 28, 2026

Benchmarks

Benchmark execution time: 2026-04-29 22:25:42

Comparing candidate commit 2a335b0 in PR branch mohammad/mass_transit7 with baseline commit 27142fd in branch master.

Found 0 performance improvements and 1 performance regressions! Performance is the same for 26 metrics, 0 unstable metrics, 61 known flaky benchmarks, 26 flaky benchmarks without significant changes.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:Benchmarks.Trace.NLogBenchmark.EnrichedLog net472

  • 🟥 throughput [-7673.369op/s; -6542.411op/s] or [-5.878%; -5.012%]

Known flaky benchmarks

These benchmarks are marked as flaky and will not trigger a failure. Modify FLAKY_BENCHMARKS_REGEX to control which benchmarks are marked as flaky.

scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild net472

  • 🟥 throughput [-5414.851op/s; -4957.647op/s] or [-6.420%; -5.878%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • 🟥 execution_time [+315.903ms; +321.418ms] or [+156.762%; +159.499%]
  • 🟥 throughput [-44.056op/s; -40.215op/s] or [-7.926%; -7.235%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net6.0

  • 🟥 execution_time [+381.358ms; +384.022ms] or [+301.296%; +303.401%]
  • 🟩 throughput [+91.071op/s; +95.030op/s] or [+12.007%; +12.529%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1

  • 🟥 execution_time [+396.260ms; +399.196ms] or [+350.675%; +353.273%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody net472

  • 🟥 allocated_mem [+1.308KB; +1.308KB] or [+27.529%; +27.541%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody net6.0

  • 🟥 allocated_mem [+471 bytes; +472 bytes] or [+9.977%; +9.987%]
  • 🟩 execution_time [-15.692ms; -11.516ms] or [-7.329%; -5.378%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody netcoreapp3.1

  • 🟥 allocated_mem [+1.272KB; +1.272KB] or [+27.502%; +27.510%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody net472

  • 🟥 allocated_mem [+1.307KB; +1.307KB] or [+105.746%; +105.759%]
  • 🟥 throughput [-278109.286op/s; -273032.788op/s] or [-28.396%; -27.878%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody net6.0

  • 🟥 allocated_mem [+471 bytes; +472 bytes] or [+38.558%; +38.566%]
  • 🟩 execution_time [-25.986ms; -21.090ms] or [-11.589%; -9.405%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody netcoreapp3.1

  • 🟥 allocated_mem [+1.272KB; +1.272KB] or [+105.292%; +105.304%]
  • 🟥 throughput [-133220.066op/s; -117128.657op/s] or [-19.141%; -16.829%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody net6.0

  • 🟩 throughput [+7864.084op/s; +10842.006op/s] or [+5.004%; +6.899%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody netcoreapp3.1

  • 🟩 throughput [+6771.704op/s; +9413.873op/s] or [+5.395%; +7.499%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody net6.0

  • 🟩 throughput [+283447.802op/s; +308429.210op/s] or [+9.451%; +10.284%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody netcoreapp3.1

  • 🟩 execution_time [-19.017ms; -14.679ms] or [-8.766%; -6.766%]
  • 🟩 throughput [+188836.083op/s; +242872.098op/s] or [+7.495%; +9.640%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs net472

  • 🟥 execution_time [+299.763ms; +300.502ms] or [+149.781%; +150.150%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs net6.0

  • 🟥 execution_time [+300.354ms; +303.634ms] or [+151.469%; +153.123%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs netcoreapp3.1

  • 🟥 execution_time [+299.943ms; +304.430ms] or [+151.088%; +153.348%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs net472

  • 🟥 execution_time [+297.526ms; +298.072ms] or [+146.133%; +146.401%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs net6.0

  • 🟥 execution_time [+296.510ms; +298.491ms] or [+144.953%; +145.921%]
  • 🟥 throughput [-454.177op/s; -423.180op/s] or [-6.598%; -6.148%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs netcoreapp3.1

  • 🟥 execution_time [+302.600ms; +304.958ms] or [+151.239%; +152.418%]
  • 🟥 throughput [-342.589op/s; -307.302op/s] or [-6.800%; -6.100%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack net6.0

  • 🟥 execution_time [+23.341µs; +46.934µs] or [+7.452%; +14.984%]
  • 🟥 throughput [-436.127op/s; -237.599op/s] or [-13.595%; -7.407%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net472

  • 🟥 execution_time [+299.897ms; +300.544ms] or [+149.680%; +150.002%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net6.0

  • unstable execution_time [+364.066ms; +398.562ms] or [+395.572%; +433.054%]
  • 🟩 throughput [+989.753op/s; +1151.956op/s] or [+8.133%; +9.466%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest netcoreapp3.1

  • unstable execution_time [+249.068ms; +294.542ms] or [+189.115%; +223.643%]
  • 🟩 throughput [+627.182op/s; +828.656op/s] or [+6.072%; +8.022%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • unstable execution_time [+334.500ms; +365.333ms] or [+153.800%; +167.977%]
  • 🟥 throughput [-515.120op/s; -483.214op/s] or [-46.675%; -43.784%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net6.0

  • unstable execution_time [+203.749ms; +337.007ms] or [+86.829%; +143.618%]
  • 🟥 throughput [-692.056op/s; -607.972op/s] or [-46.160%; -40.552%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1

  • 🟥 execution_time [+351.951ms; +359.298ms] or [+210.507%; +214.902%]
  • 🟥 throughput [-409.830op/s; -373.704op/s] or [-28.536%; -26.020%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net6.0

  • 🟩 execution_time [-92.033µs; -60.748µs] or [-8.536%; -5.634%]
  • 🟩 throughput [+59.722op/s; +96.047op/s] or [+6.439%; +10.356%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice net6.0

  • 🟩 execution_time [-151.820µs; -117.058µs] or [-7.691%; -5.930%]
  • 🟩 throughput [+33.549op/s; +42.694op/s] or [+6.623%; +8.428%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net472

  • 🟥 execution_time [+300.913ms; +302.306ms] or [+151.534%; +152.235%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net6.0

  • 🟥 execution_time [+302.080ms; +304.106ms] or [+151.373%; +152.388%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch netcoreapp3.1

  • 🟥 execution_time [+301.142ms; +304.228ms] or [+151.281%; +152.831%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync net472

  • 🟥 execution_time [+304.346ms; +305.792ms] or [+152.833%; +153.558%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync net6.0

  • 🟥 execution_time [+297.431ms; +298.935ms] or [+147.066%; +147.810%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync netcoreapp3.1

  • 🟥 execution_time [+303.427ms; +306.947ms] or [+153.790%; +155.574%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync net472

  • 🟥 execution_time [+302.156ms; +303.922ms] or [+151.655%; +152.541%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync net6.0

  • 🟥 execution_time [+300.623ms; +302.582ms] or [+149.833%; +150.809%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync netcoreapp3.1

  • 🟥 execution_time [+300.707ms; +303.277ms] or [+149.599%; +150.878%]

scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog net6.0

  • 🟩 execution_time [-16.220ms; -12.561ms] or [-7.542%; -5.841%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark net472

  • unstable execution_time [+8.042µs; +49.323µs] or [+1.986%; +12.183%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark net6.0

  • 🟩 allocated_mem [-26.827KB; -26.807KB] or [-9.786%; -9.779%]
  • unstable execution_time [-49.802µs; +2.305µs] or [-9.843%; +0.456%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark net6.0

  • unstable execution_time [+8.559µs; +13.425µs] or [+20.232%; +31.733%]
  • 🟥 throughput [-5528.413op/s; -3615.063op/s] or [-23.273%; -15.218%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark netcoreapp3.1

  • unstable execution_time [-13.201µs; -5.991µs] or [-20.481%; -9.294%]
  • 🟩 throughput [+1480.480op/s; +3008.713op/s] or [+9.083%; +18.459%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net472

  • 🟥 execution_time [+302.454ms; +304.044ms] or [+152.877%; +153.681%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net6.0

  • 🟥 execution_time [+302.001ms; +304.505ms] or [+153.717%; +154.992%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog netcoreapp3.1

  • 🟥 execution_time [+300.846ms; +302.812ms] or [+150.611%; +151.595%]

scenario:Benchmarks.Trace.RedisBenchmark.SendReceive net472

  • 🟥 throughput [-22362.342op/s; -21034.990op/s] or [-6.191%; -5.823%]

scenario:Benchmarks.Trace.RedisBenchmark.SendReceive net6.0

  • 🟩 throughput [+33079.462op/s; +36052.343op/s] or [+6.261%; +6.824%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog net472

  • 🟥 execution_time [+300.291ms; +301.990ms] or [+149.668%; +150.515%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog net6.0

  • 🟥 execution_time [+302.020ms; +303.246ms] or [+151.660%; +152.276%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog netcoreapp3.1

  • 🟥 execution_time [+303.923ms; +306.012ms] or [+154.130%; +155.190%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net472

  • 🟥 execution_time [+300.435ms; +301.225ms] or [+149.859%; +150.253%]
  • 🟩 throughput [+61112377.397op/s; +61386042.645op/s] or [+44.506%; +44.705%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net6.0

  • 🟥 execution_time [+414.326ms; +419.588ms] or [+515.288%; +521.832%]
  • 🟩 throughput [+1104.229op/s; +1269.622op/s] or [+8.536%; +9.815%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore netcoreapp3.1

  • 🟥 execution_time [+299.352ms; +300.246ms] or [+149.310%; +149.756%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope net6.0

  • 🟩 throughput [+84465.111op/s; +96320.964op/s] or [+7.886%; +8.993%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope netcoreapp3.1

  • 🟩 throughput [+63292.438op/s; +82865.921op/s] or [+7.326%; +9.592%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan net6.0

  • 🟩 throughput [+97248.240op/s; +126846.160op/s] or [+7.527%; +9.818%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan netcoreapp3.1

  • 🟩 throughput [+80084.838op/s; +90713.811op/s] or [+7.954%; +9.009%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes net6.0

  • 🟩 throughput [+53028.916op/s; +57619.692op/s] or [+9.629%; +10.463%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes netcoreapp3.1

  • 🟩 throughput [+25921.891op/s; +35601.159op/s] or [+5.802%; +7.969%]

scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net6.0

  • 🟩 throughput [+71895.875op/s; +90662.883op/s] or [+8.033%; +10.129%]

Known flaky benchmarks without significant changes:

  • scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild net6.0
  • scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild netcoreapp3.1
  • scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody net472
  • scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody net472
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark net472
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark net6.0
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark netcoreapp3.1
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack net472
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack netcoreapp3.1
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net6.0
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice netcoreapp3.1
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool netcoreapp3.1
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice netcoreapp3.1
  • scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog net472
  • scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog netcoreapp3.1
  • scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark netcoreapp3.1
  • scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark net472
  • scenario:Benchmarks.Trace.RedisBenchmark.SendReceive netcoreapp3.1
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope net472
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan net472
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes net472
  • scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net472
  • scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin netcoreapp3.1

@@ -0,0 +1,175 @@
# MassTransit Integration
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

going to delete this before merging - just hear for my own notes

chojomok and others added 5 commits April 29, 2026 14:59
The Windows and non-Windows snapshots were byte-identical, so use a
single InMemory snapshot for both platforms and drop the now-unused
IsWindows helper.
Move GetActivityKind, SetActivityKind, CreateResourceName, and
EnhanceActivityMetadata to the MassTransit 8 PR — they are only
called by MassTransitActivityHandler (the ActivitySource-based
v8 handler), not by the v7 DiagnosticSource observer.

ExtractTraceIdFromActivity had no callers on either branch and is
deleted outright.
Drop trailing blank line before class closing brace left over from
the method removal.
public IEnumerable<string> Get(IDictionary<string, object> carrier, string key)
{
if (carrier.TryGetValue(key, out var value) && value is byte[] bytes)
if (carrier.TryGetValue(key, out var value))
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding support for context propagation with MassTransit

/// <summary>
/// Extracts trace context from message attributes.
/// </summary>
public static PropagationContext ExtractHeadersFromMessage(Tracer tracer, IContainsMessageAttributes? carrier)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a lot going on here - need to determine if it's needed

@dd-trace-dotnet-ci-bot
Copy link
Copy Markdown

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing This PR (8538) and master.

✅ No regressions detected - check the details below

Full Metrics Comparison

FakeDbCommand

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration73.08 ± (73.16 - 73.53) ms75.42 ± (74.98 - 75.64) ms+3.2%✅⬆️
.NET Framework 4.8 - Bailout
duration79.52 ± (79.37 - 79.91) ms77.83 ± (77.70 - 78.20) ms-2.1%
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1076.92 ± (1071.03 - 1080.94) ms1082.43 ± (1083.47 - 1093.74) ms+0.5%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms22.56 ± (22.51 - 22.62) ms22.80 ± (22.73 - 22.87) ms+1.0%✅⬆️
process.time_to_main_ms85.09 ± (84.84 - 85.35) ms86.72 ± (86.41 - 87.04) ms+1.9%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.86 ± (10.86 - 10.87) MB10.94 ± (10.94 - 10.95) MB+0.7%✅⬆️
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms22.36 ± (22.32 - 22.41) ms22.36 ± (22.32 - 22.41) ms+0.0%✅⬆️
process.time_to_main_ms85.45 ± (85.23 - 85.67) ms85.78 ± (85.58 - 85.98) ms+0.4%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.94 ± (10.94 - 10.94) MB10.97 ± (10.97 - 10.97) MB+0.3%✅⬆️
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms212.85 ± (211.97 - 213.73) ms213.97 ± (212.89 - 215.04) ms+0.5%✅⬆️
process.time_to_main_ms527.85 ± (526.55 - 529.14) ms531.41 ± (530.09 - 532.74) ms+0.7%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed47.87 ± (47.84 - 47.90) MB48.04 ± (48.02 - 48.07) MB+0.4%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.0%
.NET 6 - Baseline
process.internal_duration_ms21.29 ± (21.24 - 21.34) ms21.46 ± (21.40 - 21.53) ms+0.8%✅⬆️
process.time_to_main_ms74.58 ± (74.32 - 74.84) ms74.92 ± (74.61 - 75.22) ms+0.5%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.61 ± (10.61 - 10.62) MB10.64 ± (10.63 - 10.64) MB+0.2%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms21.00 ± (20.96 - 21.04) ms21.50 ± (21.44 - 21.56) ms+2.4%✅⬆️
process.time_to_main_ms74.17 ± (74.00 - 74.34) ms77.40 ± (77.09 - 77.72) ms+4.4%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.73 ± (10.73 - 10.73) MB10.75 ± (10.75 - 10.76) MB+0.2%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms380.48 ± (378.38 - 382.58) ms380.76 ± (378.70 - 382.82) ms+0.1%✅⬆️
process.time_to_main_ms530.19 ± (528.87 - 531.50) ms529.85 ± (528.44 - 531.25) ms-0.1%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed49.31 ± (49.28 - 49.34) MB49.52 ± (49.49 - 49.54) MB+0.4%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.2%
.NET 8 - Baseline
process.internal_duration_ms19.39 ± (19.36 - 19.41) ms19.46 ± (19.43 - 19.50) ms+0.4%✅⬆️
process.time_to_main_ms72.90 ± (72.72 - 73.08) ms72.89 ± (72.74 - 73.03) ms-0.0%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.68 ± (7.67 - 7.69) MB7.67 ± (7.67 - 7.68) MB-0.1%
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms19.80 ± (19.76 - 19.85) ms19.72 ± (19.67 - 19.78) ms-0.4%
process.time_to_main_ms76.49 ± (76.26 - 76.71) ms75.50 ± (75.20 - 75.81) ms-1.3%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.72 ± (7.71 - 7.72) MB7.72 ± (7.72 - 7.73) MB+0.1%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms300.41 ± (298.39 - 302.43) ms298.99 ± (296.98 - 301.00) ms-0.5%
process.time_to_main_ms490.47 ± (489.27 - 491.66) ms494.28 ± (492.96 - 495.60) ms+0.8%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed36.54 ± (36.51 - 36.57) MB36.65 ± (36.62 - 36.68) MB+0.3%✅⬆️
runtime.dotnet.threads.count27 ± (27 - 27)27 ± (27 - 27)+0.1%✅⬆️

HttpMessageHandler

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration206.10 ± (205.94 - 207.26) ms201.69 ± (201.49 - 202.41) ms-2.1%
.NET Framework 4.8 - Bailout
duration210.05 ± (209.84 - 211.16) ms205.81 ± (205.78 - 206.83) ms-2.0%
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1215.01 ± (1215.13 - 1221.81) ms1190.55 ± (1191.59 - 1199.26) ms-2.0%
.NET Core 3.1 - Baseline
process.internal_duration_ms198.13 ± (197.40 - 198.85) ms195.24 ± (194.73 - 195.74) ms-1.5%
process.time_to_main_ms86.50 ± (86.15 - 86.84) ms84.83 ± (84.57 - 85.09) ms-1.9%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.04 ± (16.03 - 16.06) MB16.05 ± (16.03 - 16.07) MB+0.1%✅⬆️
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)-0.2%
.NET Core 3.1 - Bailout
process.internal_duration_ms198.37 ± (197.71 - 199.03) ms193.75 ± (193.25 - 194.25) ms-2.3%
process.time_to_main_ms87.76 ± (87.42 - 88.10) ms85.49 ± (85.25 - 85.74) ms-2.6%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.00 ± (15.98 - 16.01) MB16.07 ± (16.05 - 16.09) MB+0.4%✅⬆️
runtime.dotnet.threads.count21 ± (21 - 21)21 ± (21 - 21)+0.1%✅⬆️
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms394.01 ± (392.25 - 395.77) ms388.32 ± (387.33 - 389.31) ms-1.4%
process.time_to_main_ms541.33 ± (539.60 - 543.06) ms528.56 ± (527.36 - 529.76) ms-2.4%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed58.34 ± (58.19 - 58.49) MB57.62 ± (57.46 - 57.78) MB-1.2%
runtime.dotnet.threads.count30 ± (30 - 30)30 ± (30 - 30)-0.3%
.NET 6 - Baseline
process.internal_duration_ms206.96 ± (206.13 - 207.79) ms200.41 ± (199.84 - 200.99) ms-3.2%
process.time_to_main_ms77.40 ± (76.96 - 77.83) ms74.06 ± (73.81 - 74.32) ms-4.3%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.24 ± (16.22 - 16.25) MB16.34 ± (16.32 - 16.36) MB+0.6%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)-1.1%
.NET 6 - Bailout
process.internal_duration_ms204.60 ± (203.83 - 205.37) ms198.83 ± (198.33 - 199.33) ms-2.8%
process.time_to_main_ms76.35 ± (76.06 - 76.64) ms74.38 ± (74.18 - 74.59) ms-2.6%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.27 ± (16.25 - 16.28) MB16.42 ± (16.40 - 16.44) MB+1.0%✅⬆️
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)-0.4%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms593.92 ± (591.12 - 596.72) ms593.90 ± (591.65 - 596.15) ms-0.0%
process.time_to_main_ms537.75 ± (536.53 - 538.97) ms528.82 ± (527.62 - 530.01) ms-1.7%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed60.87 ± (60.77 - 60.98) MB61.18 ± (61.07 - 61.29) MB+0.5%✅⬆️
runtime.dotnet.threads.count31 ± (31 - 31)31 ± (31 - 31)-0.2%
.NET 8 - Baseline
process.internal_duration_ms200.64 ± (200.12 - 201.16) ms198.35 ± (197.80 - 198.90) ms-1.1%
process.time_to_main_ms74.14 ± (73.90 - 74.38) ms73.05 ± (72.81 - 73.29) ms-1.5%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.62 ± (11.60 - 11.63) MB11.68 ± (11.67 - 11.69) MB+0.5%✅⬆️
runtime.dotnet.threads.count18 ± (18 - 18)18 ± (18 - 18)-0.5%
.NET 8 - Bailout
process.internal_duration_ms200.11 ± (199.58 - 200.64) ms197.33 ± (196.73 - 197.93) ms-1.4%
process.time_to_main_ms74.92 ± (74.68 - 75.16) ms74.33 ± (74.09 - 74.57) ms-0.8%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.65 ± (11.63 - 11.67) MB11.77 ± (11.75 - 11.78) MB+1.0%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)-0.4%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms519.31 ± (516.14 - 522.47) ms522.52 ± (518.93 - 526.10) ms+0.6%✅⬆️
process.time_to_main_ms492.77 ± (491.79 - 493.74) ms491.04 ± (489.86 - 492.21) ms-0.4%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed50.32 ± (50.28 - 50.35) MB50.28 ± (50.25 - 50.32) MB-0.1%
runtime.dotnet.threads.count30 ± (30 - 30)30 ± (30 - 30)-0.3%
Comparison explanation

Execution-time benchmarks measure the whole time it takes to execute a program, and are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are highlighted in **red**. The following thresholds were used for comparing the execution times:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard.

Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph).

Duration charts
FakeDbCommand (.NET Framework 4.8)
gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8538) - mean (75ms)  : 70, 80
    master - mean (73ms)  : 71, 76

    section Bailout
    This PR (8538) - mean (78ms)  : 74, 82
    master - mean (80ms)  : 76, 84

    section CallTarget+Inlining+NGEN
    This PR (8538) - mean (1,089ms)  : 1013, 1164
    master - mean (1,076ms)  : 1020, 1132

Loading
FakeDbCommand (.NET Core 3.1)
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8538) - mean (117ms)  : 110, 123
    master - mean (115ms)  : 109, 121

    section Bailout
    This PR (8538) - mean (115ms)  : 112, 118
    master - mean (115ms)  : 112, 117

    section CallTarget+Inlining+NGEN
    This PR (8538) - mean (784ms)  : 757, 810
    master - mean (779ms)  : 750, 808

Loading
FakeDbCommand (.NET 6)
gantt
    title Execution time (ms) FakeDbCommand (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8538) - mean (103ms)  : 97, 110
    master - mean (102ms)  : 98, 107

    section Bailout
    This PR (8538) - mean (106ms)  : 99, 112
    master - mean (101ms)  : 99, 104

    section CallTarget+Inlining+NGEN
    This PR (8538) - mean (939ms)  : 906, 972
    master - mean (940ms)  : 894, 985

Loading
FakeDbCommand (.NET 8)
gantt
    title Execution time (ms) FakeDbCommand (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8538) - mean (100ms)  : 97, 103
    master - mean (100ms)  : 97, 104

    section Bailout
    This PR (8538) - mean (103ms)  : 97, 110
    master - mean (105ms)  : 100, 109

    section CallTarget+Inlining+NGEN
    This PR (8538) - mean (823ms)  : 787, 860
    master - mean (822ms)  : 786, 859

Loading
HttpMessageHandler (.NET Framework 4.8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8538) - mean (202ms)  : 196, 208
    master - mean (207ms)  : 197, 216

    section Bailout
    This PR (8538) - mean (206ms)  : 199, 214
    master - mean (211ms)  : 201, 220

    section CallTarget+Inlining+NGEN
    This PR (8538) - mean (1,195ms)  : 1138, 1252
    master - mean (1,218ms)  : 1170, 1267

Loading
HttpMessageHandler (.NET Core 3.1)
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8538) - mean (289ms)  : 276, 302
    master - mean (296ms)  : 278, 314

    section Bailout
    This PR (8538) - mean (289ms)  : 280, 297
    master - mean (297ms)  : 280, 313

    section CallTarget+Inlining+NGEN
    This PR (8538) - mean (950ms)  : 918, 982
    master - mean (976ms)  : 946, 1007

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8538) - mean (283ms)  : 270, 297
    master - mean (294ms)  : 274, 314

    section Bailout
    This PR (8538) - mean (283ms)  : 271, 294
    master - mean (292ms)  : 272, 311

    section CallTarget+Inlining+NGEN
    This PR (8538) - mean (1,153ms)  : 1114, 1192
    master - mean (1,163ms)  : 1111, 1215

Loading
HttpMessageHandler (.NET 8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8538) - mean (282ms)  : 269, 295
    master - mean (285ms)  : 274, 297

    section Bailout
    This PR (8538) - mean (283ms)  : 268, 297
    master - mean (286ms)  : 275, 297

    section CallTarget+Inlining+NGEN
    This PR (8538) - mean (1,046ms)  : 991, 1101
    master - mean (1,044ms)  : 993, 1094

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant