Skip to content

HotChocolate GraphQL integration#3004

Merged
dromanol merged 29 commits into
masterfrom
dani/hotchocolate_clean
Sep 2, 2022
Merged

HotChocolate GraphQL integration#3004
dromanol merged 29 commits into
masterfrom
dani/hotchocolate_clean

Conversation

@dromanol

@dromanol dromanol commented Jul 22, 2022

Copy link
Copy Markdown
Contributor

Summary of changes

HotChocolate v11-v12 Tracer integration and sample application (chose the most popular latest versions)

Reason for change

Implement integration with Hotchocolate GraphQL .net library

Implementation details

Instrumented HotChocolate.Execution.RequestExecutor.ExecuteAsync
This captures the main boundary of the operation and all semantic errors.
Instrumented HotChocolate.Execution.Processing.QueryExecutor from
This captures the operation type if it is well formed. For V11 it only captures Query types.
Instrumented HotChocolate.Execution.Processing.MutationExecutorfrom for V11
This captures the Mutation operation type if it is well formed.

Moved .Net GraphQL specific implementatiosn to Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL.Net namespace
HotChocolate specific implementation set on namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL.HotChocolate
Common code left on Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL

Test coverage

image
image

Other details

@dromanol
dromanol requested review from a team as code owners July 22, 2022 10:28
@dromanol dromanol changed the title HotChocolate GraphQL integration HotChocolate GraphQL integration area:integrations Jul 22, 2022
@dromanol dromanol changed the title HotChocolate GraphQL integration area:integrations HotChocolate GraphQL integration Jul 22, 2022
@dromanol dromanol added the area:automatic-instrumentation Automatic instrumentation managed C# code (Datadog.Trace.ClrProfiler.Managed) label Jul 22, 2022
@andrewlock

This comment has been minimized.

@pierotibou pierotibou left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks a lot for doing that. Here's a first set of review as I haven't finished.
My main comments/question are:

  • should we merge more things with the graphql integration as both should behave the same functionally (i mean in Datadog)
  • don't hesitate to be ;ore verbose in your PR description. The more you say, the less questions we ask ;)

Comment thread tracer/build/PackageVersionsGeneratorDefinitions.json Outdated
Comment thread tracer/build/PackageVersionsGeneratorDefinitions.json
Comment thread tracer/build/PackageVersionsGeneratorDefinitions.json Outdated
Comment thread tracer/test/snapshots/HotChocolate12Tests.SubmitsTraces.verified.txt Outdated
@andrewlock

This comment has been minimized.

@dromanol
dromanol force-pushed the dani/hotchocolate_clean branch from a600040 to 4732650 Compare July 24, 2022 11:28
@andrewlock

This comment has been minimized.

@andrewlock

This comment has been minimized.

@andrewlock andrewlock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice work, thanks! 👍 I have a bunch of small nits, mostly around some optimisations, but overall this looks really good to me.

The main things to look at is adding testing for multiple package versions (currently it's only testing the latest version)

Comment thread tracer/build/PackageVersionsGeneratorDefinitions.json
Comment thread tracer/build/_build/Honeypot/IntegrationGroups.cs
Comment thread tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/HotChocolateTests.cs Outdated
@dromanol
dromanol force-pushed the dani/hotchocolate_clean branch from 32e95ba to 9b22989 Compare August 4, 2022 08:54
@andrewlock

This comment has been minimized.

@dromanol
dromanol force-pushed the dani/hotchocolate_clean branch from 77d6f70 to ccb139e Compare August 7, 2022 15:59
@andrewlock

This comment has been minimized.

@pierotibou pierotibou left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for doing this. I've left a few comments and +1 a few Andrew's one.
If you were to fix things and get a second approval, please wait for #2982 to be merged before merging this one please 🙏. That will avoid an extra change of snapshots for Lucas. Though it will mean that you'll need to rebase and update the snapshots once he has merged

Comment thread docs/development/AutomaticInstrumentation.md Outdated
@andrewlock

This comment has been minimized.

@dromanol
dromanol force-pushed the dani/hotchocolate_clean branch from 897b41e to 797e671 Compare August 17, 2022 19:07
@andrewlock

This comment has been minimized.

@dromanol
dromanol force-pushed the dani/hotchocolate_clean branch from 797e671 to 4818415 Compare September 1, 2022 08:49
@andrewlock

Copy link
Copy Markdown
Member

Code Coverage Report 📊

✔️ Merging #3004 into master will not change line coverage
✔️ Merging #3004 into master will not change branch coverage
⛔ Merging #3004 into master will will increase complexity by 74

master #3004 Change
Lines 17420 / 23769 17459 / 23861
Lines % 73% 73% 0% ✔️
Branches 10309 / 14621 10368 / 14691
Branches % 71% 71% 0% ✔️
Complexity 15784 15858 74

View the full report for further details:

Datadog.Trace Breakdown ✔️

master #3004 Change
Lines % 73% 73% 0% ✔️
Branches % 71% 71% 0% ✔️
Complexity 15784 15858 74

The following classes have significant coverage changes.

File Line coverage change Branch coverage change Complexity change
Datadog.Trace.Ci.GitInfo -17% -11% 0 ✔️
Datadog.Trace.Telemetry.Transports.JsonTelemetryTransport -9% -17% 0 ✔️
Datadog.Trace.DuckTyping.DuckTypePropertyOrFieldNotFoundException 0% ✔️ -62% 7
Datadog.Trace.Ci.CIVisibility 5% ✔️ 6% ✔️ 0 ✔️

The following classes were added in #3004:

File Line coverage Branch coverage Complexity
Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL.GraphQLCommonBase 96% 100% 11
Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL.HotChocolate.ExecuteAsyncIntegration 83% 60% 11
Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL.HotChocolate.ExecuteAsyncIntegrationExtra 100% 100% 1
Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL.HotChocolate.HotChocolateCommon 70% 65% 35
Datadog.Trace.ClrProfiler.AutoInstrumentation.GraphQL.Net.ExecuteAsyncIntegration 83% 50% 9
...And 6 more

7 classes were removed from Datadog.Trace in #3004

View the full reports for further details:

@dromanol
dromanol force-pushed the dani/hotchocolate_clean branch 2 times, most recently from ccdc927 to 9f092c2 Compare September 1, 2022 20:36
@andrewlock

This comment has been minimized.

@dromanol
dromanol force-pushed the dani/hotchocolate_clean branch from 9f092c2 to 7cfd665 Compare September 2, 2022 13:08
@andrewlock

Copy link
Copy Markdown
Member

Benchmarks Report 🐌

Benchmarks for #3004 compared to master:

  • All benchmarks have the same speed
  • 2 benchmarks have more allocations

The following thresholds were used for comparing the benchmark speeds:

  • Mann–Whitney U test with statistical test for significance of 5%
  • Only results indicating a difference greater than 10% and 0.3 ns are considered.

Allocation changes below 0.5% are ignored.

Benchmark details

Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net472 706μs 1.18μs 4.56μs 0.355 0 0 3.18 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 493μs 681ns 2.55μs 0 0 0 2.58 KB
#3004 WriteAndFlushEnrichedTraces net472 721μs 719ns 2.78μs 0.355 0 0 3.18 KB
#3004 WriteAndFlushEnrichedTraces netcoreapp3.1 471μs 619ns 2.4μs 0 0 0 2.58 KB
Benchmarks.Trace.AppSecBodyBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master AllCycleSimpleBody net472 184ns 0.233ns 0.841ns 0.0675 9.25E-05 0 425 B
master AllCycleSimpleBody netcoreapp3.1 239ns 0.298ns 1.15ns 0.00577 0 0 424 B
master AllCycleMoreComplexBody net472 184ns 0.198ns 0.741ns 0.0637 0 0 401 B
master AllCycleMoreComplexBody netcoreapp3.1 234ns 0.285ns 1.1ns 0.00562 0 0 400 B
master BodyExtractorSimpleBody net472 265ns 0.249ns 0.963ns 0.0574 0 0 361 B
master BodyExtractorSimpleBody netcoreapp3.1 221ns 0.243ns 0.877ns 0.00366 0 0 272 B
master BodyExtractorMoreComplexBody net472 14.2μs 12.2ns 45.5ns 1.21 0.0212 0 7.62 KB
master BodyExtractorMoreComplexBody netcoreapp3.1 12.3μs 6.75ns 23.4ns 0.0923 0 0 6.75 KB
#3004 AllCycleSimpleBody net472 187ns 0.526ns 1.97ns 0.0676 9.21E-05 0 425 B
#3004 AllCycleSimpleBody netcoreapp3.1 238ns 0.281ns 1.09ns 0.00573 0 0 424 B
#3004 AllCycleMoreComplexBody net472 184ns 0.159ns 0.593ns 0.0637 0 0 401 B
#3004 AllCycleMoreComplexBody netcoreapp3.1 233ns 0.215ns 0.833ns 0.00556 0 0 400 B
#3004 BodyExtractorSimpleBody net472 258ns 0.395ns 1.53ns 0.0573 0 0 361 B
#3004 BodyExtractorSimpleBody netcoreapp3.1 222ns 0.334ns 1.25ns 0.00366 0 0 272 B
#3004 BodyExtractorMoreComplexBody net472 14.3μs 12.5ns 48.6ns 1.21 0.0214 0 7.62 KB
#3004 BodyExtractorMoreComplexBody netcoreapp3.1 12.1μs 14.3ns 55.4ns 0.0904 0 0 6.75 KB
Benchmarks.Trace.AspNetCoreBenchmark - Unknown 🤷 Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendRequest net472 0ns 0ns 0ns 0 0 0 0 b
master SendRequest netcoreapp3.1 183μs 126ns 489ns 0.273 0 0 20.57 KB
#3004 SendRequest net472 0ns 0ns 0ns 0 0 0 0 b
#3004 SendRequest netcoreapp3.1 183μs 140ns 544ns 0.275 0 0 20.57 KB
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteNonQuery net472 1.81μs 3.61ns 14ns 0.15 0.000889 0 947 B
master ExecuteNonQuery netcoreapp3.1 1.51μs 1.67ns 6.48ns 0.0128 0 0 936 B
#3004 ExecuteNonQuery net472 1.79μs 1.45ns 5.6ns 0.15 0.000892 0 947 B
#3004 ExecuteNonQuery netcoreapp3.1 1.47μs 1.13ns 4.36ns 0.0123 0 0 936 B
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master CallElasticsearch net472 2.54μs 1.43ns 5.53ns 0.183 0 0 1.16 KB
master CallElasticsearch netcoreapp3.1 1.51μs 0.615ns 2.3ns 0.0153 0 0 1.1 KB
master CallElasticsearchAsync net472 2.73μs 0.493ns 1.91ns 0.205 0 0 1.29 KB
master CallElasticsearchAsync netcoreapp3.1 1.62μs 0.828ns 3.1ns 0.0162 0 0 1.22 KB
#3004 CallElasticsearch net472 2.59μs 1.22ns 4.71ns 0.184 0 0 1.16 KB
#3004 CallElasticsearch netcoreapp3.1 1.49μs 0.926ns 3.59ns 0.0149 0 0 1.1 KB
#3004 CallElasticsearchAsync net472 2.56μs 0.47ns 1.82ns 0.205 0 0 1.29 KB
#3004 CallElasticsearchAsync netcoreapp3.1 1.58μs 0.309ns 1.2ns 0.0166 0 0 1.22 KB
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #3004

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync‑netcoreapp3.1 1.34 KB 1.34 KB 8 B 0.60%
Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync‑net472 1.41 KB 1.42 KB 8 B 0.57%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteAsync net472 2.54μs 4.45ns 16.7ns 0.224 0 0 1.41 KB
master ExecuteAsync netcoreapp3.1 1.72μs 3.89ns 14.5ns 0.0179 0 0 1.34 KB
#3004 ExecuteAsync net472 2.6μs 5.8ns 22.5ns 0.225 0 0 1.42 KB
#3004 ExecuteAsync netcoreapp3.1 1.71μs 3.95ns 15.3ns 0.0185 0 0 1.34 KB
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendAsync net472 5.76μs 14.2ns 54.9ns 0.438 0 0 2.77 KB
master SendAsync netcoreapp3.1 3.62μs 8.85ns 34.3ns 0.0343 0 0 2.6 KB
#3004 SendAsync net472 5.71μs 12.8ns 49.6ns 0.439 0 0 2.77 KB
#3004 SendAsync netcoreapp3.1 3.53μs 8.22ns 31.8ns 0.0341 0 0 2.6 KB
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net472 3.06μs 2.98ns 11.5ns 0.287 0 0 1.81 KB
master EnrichedLog netcoreapp3.1 2.47μs 1.59ns 5.96ns 0.0246 0 0 1.85 KB
#3004 EnrichedLog net472 3.24μs 4.13ns 16ns 0.287 0 0 1.81 KB
#3004 EnrichedLog netcoreapp3.1 2.58μs 1.18ns 4.27ns 0.0245 0 0 1.85 KB
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net472 152μs 88.3ns 342ns 0.683 0.228 0 4.65 KB
master EnrichedLog netcoreapp3.1 116μs 138ns 533ns 0 0 0 4.49 KB
#3004 EnrichedLog net472 151μs 125ns 468ns 0.686 0.229 0 4.65 KB
#3004 EnrichedLog netcoreapp3.1 116μs 261ns 1.01μs 0.0587 0 0 4.49 KB
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net472 5.66μs 9.49ns 36.7ns 0.568 0.00284 0 3.59 KB
master EnrichedLog netcoreapp3.1 4.39μs 7.56ns 28.3ns 0.0547 0 0 3.91 KB
#3004 EnrichedLog net472 5.67μs 25ns 97ns 0.568 0.00283 0 3.59 KB
#3004 EnrichedLog netcoreapp3.1 4.41μs 9.21ns 35.7ns 0.0535 0 0 3.91 KB
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendReceive net472 2.22μs 1.12ns 4.18ns 0.218 0 0 1.37 KB
master SendReceive netcoreapp3.1 1.88μs 7.85ns 30.4ns 0.0176 0 0 1.32 KB
#3004 SendReceive net472 2.31μs 2.45ns 9.48ns 0.218 0 0 1.37 KB
#3004 SendReceive netcoreapp3.1 1.8μs 1.06ns 3.82ns 0.0179 0 0 1.32 KB
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net472 5.06μs 0.834ns 3.12ns 0.352 0 0 2.23 KB
master EnrichedLog netcoreapp3.1 4.22μs 0.964ns 3.73ns 0.0233 0 0 1.8 KB
#3004 EnrichedLog net472 4.97μs 2.37ns 9.17ns 0.352 0 0 2.23 KB
#3004 EnrichedLog netcoreapp3.1 4.45μs 1.52ns 5.7ns 0.0243 0 0 1.8 KB
Benchmarks.Trace.SpanBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net472 1.18μs 0.447ns 1.67ns 0.129 0 0 810 B
master StartFinishSpan netcoreapp3.1 1.01μs 0.213ns 0.767ns 0.0101 0 0 760 B
master StartFinishScope net472 1.37μs 0.645ns 2.41ns 0.141 0 0 891 B
master StartFinishScope netcoreapp3.1 1.09μs 0.316ns 1.14ns 0.0116 0 0 880 B
#3004 StartFinishSpan net472 1.19μs 0.361ns 1.4ns 0.128 0 0 810 B
#3004 StartFinishSpan netcoreapp3.1 918ns 0.443ns 1.71ns 0.0102 0 0 760 B
#3004 StartFinishScope net472 1.42μs 0.581ns 2.17ns 0.141 0 0 891 B
#3004 StartFinishScope netcoreapp3.1 1.14μs 10.7ns 101ns 0.0117 0 0 880 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net472 1.51μs 0.623ns 2.41ns 0.141 0 0 891 B
master RunOnMethodBegin netcoreapp3.1 1.25μs 0.423ns 1.58ns 0.0119 0 0 880 B
#3004 RunOnMethodBegin net472 1.48μs 0.502ns 1.88ns 0.142 0 0 891 B
#3004 RunOnMethodBegin netcoreapp3.1 1.19μs 0.835ns 3.23ns 0.0119 0 0 880 B

@dromanol
dromanol merged commit c53c8c3 into master Sep 2, 2022
@dromanol
dromanol deleted the dani/hotchocolate_clean branch September 2, 2022 14:46
@github-actions github-actions Bot added this to the vNext milestone Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:automatic-instrumentation Automatic instrumentation managed C# code (Datadog.Trace.ClrProfiler.Managed) needs-docs-update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants