Skip to content

Fix exception in Kafka on .NET Framework#8366

Open
bouwkast wants to merge 1 commit intomasterfrom
steven/kafka-fix
Open

Fix exception in Kafka on .NET Framework#8366
bouwkast wants to merge 1 commit intomasterfrom
steven/kafka-fix

Conversation

@bouwkast
Copy link
Collaborator

@bouwkast bouwkast commented Mar 24, 2026

Summary of changes

Ran Kafka locally as I was attempting to port it to Testcontainers and was actually get exceptions / errors on it, this resolves them (or at least it seems to resolve them). Also noticed them in Error Tracking, but only a single instance, but I'm not 100% sure if it was the same, Error Tracking is linked in the linked Jira Ticket.

Reason for change

Previously this was using IsCompletedSuccessfully and then doing a cast and enumeration of all properties and was failing with the following error as IsCompletedSuccessfully isn't available on .NET Framework:

2026-03-24 15:43:11.768 -04:00 [WRN] Error extracting cluster_id from Kafka metadata Datadog.Trace.DuckTyping.DuckTypePropertyOrFieldNotFoundException: The property or field 'IsCompletedSuccessfully' for the proxy property 'IsCompletedSuccessfully' was not found in the instance of type 'System.Threading.Tasks.Task`1[[Confluent.Kafka.Admin.DescribeClusterResult, Confluent.Kafka, Version=2.6.1.0, Culture=neutral, PublicKeyToken=12c514ca49093d1e]]'.
   at Datadog.Trace.DuckTyping.DuckTypePropertyOrFieldNotFoundException.Throw(String name, String duckAttributeName, Type type)
   at Datadog.Trace.DuckTyping.DuckType.CreateProperties(TypeBuilder proxyTypeBuilder, Type proxyDefinitionType, Type targetType, FieldInfo instanceField)
   at Datadog.Trace.DuckTyping.DuckType.CreateProxyType(Type proxyDefinitionType, Type targetType, Boolean dryRun)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Datadog.Trace.DuckTyping.DuckType.CreateTypeResult.ThrowOnError[T](Object instance)
   at Datadog.Trace.DuckTyping.DuckType.CreateTypeResult.CreateInstance[T](Object instance)
   at Datadog.Trace.DuckTyping.DuckType.CreateCache`1.Create(Object instance)
   at Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka.KafkaHelper.DescribeClusterWithTimeout(IAdminClient adminClient, Type describeClusterOptionsType)
   at Datadog.Trace.ClrProfiler.AutoInstrumentation.Kafka.KafkaHelper.GetClusterId(String bootstrapServers, Object clientInstance)
 { MachineName: ".", Process: "[59476 Samples.Kafka]", AppDomain: "[1 Samples.Kafka.exe]", TracerVersion: "3.41.0.0" }

Implementation details

Does not use IsCompletedSuccessfully and instead uses a new custom IDescribeClusterTask ducktype and checks the task directly

Test coverage

Applied the fix, re-ran didn't see again, however, the Error Tracking one may be a different bug as it appears that it is on .NET 9.0 😕

Edit: yes appears to be a different error that came up during development that was addressed

Other details

Fixes https://datadoghq.atlassian.net/browse/APMLP-1146

@bouwkast bouwkast requested review from a team as code owners March 24, 2026 20:49
@bouwkast bouwkast added the AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos label Mar 24, 2026
Copy link
Contributor

@robcarlan-datadog robcarlan-datadog left a comment

Choose a reason for hiding this comment

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

Thank you!

@pr-commenter
Copy link

pr-commenter bot commented Mar 24, 2026

Benchmarks

Benchmark execution time: 2026-03-24 21:30:17

Comparing candidate commit c8c39dc in PR branch steven/kafka-fix with baseline commit 1bb5b79 in branch master.

Found 8 performance improvements and 12 performance regressions! Performance is the same for 253 metrics, 15 unstable metrics.

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.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net6.0

  • 🟩 execution_time [-22.252ms; -21.923ms] or [-17.902%; -17.638%]

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

  • 🟩 execution_time [-91.871ms; -91.695ms] or [-45.483%; -45.396%]

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

  • 🟥 execution_time [+13.632ms; +19.160ms] or [+6.915%; +9.720%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • 🟩 execution_time [-28.755ms; -23.874ms] or [-12.416%; -10.309%]

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

  • 🟥 execution_time [+140.967µs; +149.233µs] or [+10.146%; +10.741%]
  • 🟥 throughput [-70.006op/s; -66.119op/s] or [-9.726%; -9.186%]

scenario:Benchmarks.Trace.DbCommandBenchmark.ExecuteNonQuery net472

  • 🟥 throughput [-20575.148op/s; -18380.958op/s] or [-5.621%; -5.022%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net472

  • 🟥 throughput [-18891.691op/s; -17018.667op/s] or [-5.833%; -5.255%]

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

  • 🟩 throughput [+44626.908op/s; +56041.594op/s] or [+8.906%; +11.184%]

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

  • 🟩 throughput [+27646.817op/s; +37986.354op/s] or [+6.822%; +9.374%]

scenario:Benchmarks.Trace.HttpClientBenchmark.SendAsync netcoreapp3.1

  • 🟩 throughput [+7209.981op/s; +8574.021op/s] or [+5.814%; +6.914%]

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

  • 🟥 allocated_mem [+16.426KB; +16.454KB] or [+6.381%; +6.392%]

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

  • 🟥 allocated_mem [+19.859KB; +19.888KB] or [+7.759%; +7.770%]
  • 🟥 throughput [-277.409op/s; -123.533op/s] or [-14.214%; -6.330%]

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

  • 🟥 throughput [-16339.718op/s; -13166.846op/s] or [-6.817%; -5.494%]

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

  • 🟥 throughput [-10385.625op/s; -8873.615op/s] or [-5.860%; -5.007%]

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

  • 🟥 throughput [-16369852.528op/s; -15473628.498op/s] or [-6.782%; -6.411%]

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

  • 🟥 execution_time [+12.525ms; +17.450ms] or [+6.348%; +8.844%]

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

  • 🟩 execution_time [-23.751ms; -18.323ms] or [-10.857%; -8.376%]

scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net472

  • 🟩 throughput [+35071.013op/s; +42915.481op/s] or [+5.191%; +6.352%]

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

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos area:integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants