Skip to content

S3 Span Pointers#6655

Merged
nhulston merged 26 commits into
masterfrom
nicholas.hulston/s3-span-pointers
Mar 6, 2025
Merged

S3 Span Pointers#6655
nhulston merged 26 commits into
masterfrom
nicholas.hulston/s3-span-pointers

Conversation

@nhulston

@nhulston nhulston commented Feb 11, 2025

Copy link
Copy Markdown
Contributor

Summary of changes

Adds span pointers in S3 for putObject, copyObject, and completeMultipartUpload requests.

Span pointers are similar to Span Links, but for cases when it is impossible to pass the Trace ID and Span ID between the spans that need to be linked.

When the calculated hashes for the upstream and downstream lambdas match, the Datadog backend will automatically link the two traces together.
Screenshot 2025-02-20 at 12 15 32 PM

When clicking on the linked span, a new tab opens linking to the downstream Lambda function that was triggered by this S3 object update.

This feature can be disabled by setting the environment variable DD_TRACE_AWS_ADD_SPAN_POINTERS to false.

Reason for change

Span pointers is a new feature being developed by the Serverless team. This feature already exists in Python & Node, and I'm working on adding it to other runtimes.

Implementation details

Test coverage

Unit tests, integration tests (snapshots), and manual testing on Lambda

Other details

https://docs.google.com/document/d/1I8DLCbUXITaqOK7HLdDCR41WnTSi1WP2OM2J3lGT-rc/edit?tab=t.0#heading=h.ixjggxchsgmp

@datadog-ddstaging

Copy link
Copy Markdown

Datadog Report

Branch report: nicholas.hulston/s3-span-pointers
Commit report: 3d515cd
Test service: dd-trace-dotnet

✅ 0 Failed, 153143 Passed, 483 Skipped, 1h 29m 53.36s Total Time

@andrewlock

andrewlock commented Feb 11, 2025

Copy link
Copy Markdown
Member

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing the following branches/commits:

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 shown 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).

gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6655) - mean (70ms)  : 66, 73
     .   : milestone, 70,
    master - mean (70ms)  : 65, 74
     .   : milestone, 70,

    section CallTarget+Inlining+NGEN
    This PR (6655) - mean (1,008ms)  : 984, 1032
     .   : milestone, 1008,
    master - mean (1,003ms)  : 977, 1029
     .   : milestone, 1003,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6655) - mean (103ms)  : 101, 105
     .   : milestone, 103,
    master - mean (102ms)  : 100, 105
     .   : milestone, 102,

    section CallTarget+Inlining+NGEN
    This PR (6655) - mean (687ms)  : 663, 710
     .   : milestone, 687,
    master - mean (688ms)  : 664, 711
     .   : milestone, 688,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6655) - mean (89ms)  : 87, 91
     .   : milestone, 89,
    master - mean (89ms)  : 87, 91
     .   : milestone, 89,

    section CallTarget+Inlining+NGEN
    This PR (6655) - mean (639ms)  : 623, 656
     .   : milestone, 639,
    master - mean (640ms)  : 626, 654
     .   : milestone, 640,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6655) - mean (192ms)  : 187, 196
     .   : milestone, 192,
    master - mean (191ms)  : 187, 196
     .   : milestone, 191,

    section CallTarget+Inlining+NGEN
    This PR (6655) - mean (1,112ms)  : 1081, 1144
     .   : milestone, 1112,
    master - mean (1,107ms)  : 1081, 1133
     .   : milestone, 1107,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6655) - mean (271ms)  : 266, 276
     .   : milestone, 271,
    master - mean (271ms)  : 266, 275
     .   : milestone, 271,

    section CallTarget+Inlining+NGEN
    This PR (6655) - mean (876ms)  : 846, 905
     .   : milestone, 876,
    master - mean (877ms)  : 842, 913
     .   : milestone, 877,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6655) - mean (262ms)  : 259, 265
     .   : milestone, 262,
    master - mean (262ms)  : 259, 266
     .   : milestone, 262,

    section CallTarget+Inlining+NGEN
    This PR (6655) - mean (852ms)  : 822, 882
     .   : milestone, 852,
    master - mean (855ms)  : 817, 892
     .   : milestone, 855,

Loading

@andrewlock

andrewlock commented Feb 11, 2025

Copy link
Copy Markdown
Member

Benchmarks Report for tracer 🐌

Benchmarks for #6655 compared to master:

  • 1 benchmarks are slower, with geometric mean 1.122
  • All benchmarks have the same 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.ActivityBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 8.19μs 46.8ns 338ns 0.0119 0.00398 0 5.6 KB
master StartStopWithChild netcoreapp3.1 10.7μs 60.3ns 435ns 0.015 0.00499 0 5.81 KB
master StartStopWithChild net472 16.2μs 47.8ns 185ns 1.04 0.299 0.0969 6.2 KB
#6655 StartStopWithChild net6.0 8.43μs 48.8ns 414ns 0.013 0.00433 0 5.61 KB
#6655 StartStopWithChild netcoreapp3.1 10.5μs 59.2ns 401ns 0.0264 0.0106 0 5.8 KB
#6655 StartStopWithChild net472 16.1μs 33.4ns 125ns 1.03 0.296 0.0961 6.21 KB
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 483μs 358ns 1.39μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 644μs 635ns 2.46μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 849μs 397ns 1.54μs 0.422 0 0 3.3 KB
#6655 WriteAndFlushEnrichedTraces net6.0 485μs 262ns 945ns 0 0 0 2.7 KB
#6655 WriteAndFlushEnrichedTraces netcoreapp3.1 652μs 461ns 1.78μs 0 0 0 2.7 KB
#6655 WriteAndFlushEnrichedTraces net472 845μs 596ns 2.15μs 0.422 0 0 3.3 KB
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendRequest net6.0 133μs 411ns 1.59μs 0.199 0 0 14.47 KB
master SendRequest netcoreapp3.1 151μs 212ns 794ns 0.227 0 0 17.27 KB
master SendRequest net472 0.000146ns 9.84E‑05ns 0.000368ns 0 0 0 0 b
#6655 SendRequest net6.0 134μs 347ns 1.35μs 0.135 0 0 14.47 KB
#6655 SendRequest netcoreapp3.1 149μs 303ns 1.17μs 0.221 0 0 17.27 KB
#6655 SendRequest net472 0.000808ns 0.000387ns 0.00145ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 549μs 2.62μs 10.5μs 0.543 0 0 41.47 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 683μs 3.34μs 13.8μs 0.324 0 0 41.84 KB
master WriteAndFlushEnrichedTraces net472 878μs 3.73μs 13.9μs 8.19 2.59 0.431 53.32 KB
#6655 WriteAndFlushEnrichedTraces net6.0 555μs 3.04μs 16.9μs 0.279 0 0 41.52 KB
#6655 WriteAndFlushEnrichedTraces netcoreapp3.1 663μs 3.57μs 18.9μs 0.327 0 0 41.72 KB
#6655 WriteAndFlushEnrichedTraces net472 865μs 3.16μs 11.8μs 8.08 2.55 0.425 53.28 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 net6.0 1.33μs 1.28ns 4.97ns 0.014 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.82μs 1.88ns 7.28ns 0.0133 0 0 1.02 KB
master ExecuteNonQuery net472 2.12μs 1.29ns 4.81ns 0.156 0.00106 0 987 B
#6655 ExecuteNonQuery net6.0 1.34μs 1.37ns 5.3ns 0.0142 0 0 1.02 KB
#6655 ExecuteNonQuery netcoreapp3.1 1.75μs 1.09ns 4.21ns 0.0141 0 0 1.02 KB
#6655 ExecuteNonQuery net472 2.09μs 2.32ns 8.99ns 0.156 0.00104 0 987 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 net6.0 1.26μs 0.7ns 2.62ns 0.0139 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.55μs 3.3ns 12.3ns 0.0131 0 0 976 B
master CallElasticsearch net472 2.47μs 0.758ns 2.73ns 0.158 0 0 995 B
master CallElasticsearchAsync net6.0 1.24μs 1.08ns 4.18ns 0.0131 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.64μs 1.06ns 3.95ns 0.0131 0 0 1.02 KB
master CallElasticsearchAsync net472 2.64μs 1ns 3.62ns 0.166 0 0 1.05 KB
#6655 CallElasticsearch net6.0 1.18μs 0.303ns 1.13ns 0.0137 0 0 976 B
#6655 CallElasticsearch netcoreapp3.1 1.55μs 0.69ns 2.58ns 0.0134 0 0 976 B
#6655 CallElasticsearch net472 2.57μs 1.97ns 7.62ns 0.158 0 0 995 B
#6655 CallElasticsearchAsync net6.0 1.22μs 0.457ns 1.71ns 0.0129 0 0 952 B
#6655 CallElasticsearchAsync netcoreapp3.1 1.7μs 0.68ns 2.55ns 0.0136 0 0 1.02 KB
#6655 CallElasticsearchAsync net472 2.64μs 1.37ns 5.32ns 0.166 0 0 1.05 KB
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteAsync net6.0 1.34μs 1.58ns 5.9ns 0.0133 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.69μs 1.57ns 6.08ns 0.0128 0 0 952 B
master ExecuteAsync net472 1.85μs 0.672ns 2.6ns 0.145 0 0 915 B
#6655 ExecuteAsync net6.0 1.38μs 0.373ns 1.34ns 0.0132 0 0 952 B
#6655 ExecuteAsync netcoreapp3.1 1.62μs 0.916ns 3.43ns 0.013 0 0 952 B
#6655 ExecuteAsync net472 1.82μs 0.514ns 1.85ns 0.145 0 0 915 B
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendAsync net6.0 4.36μs 1.04ns 3.75ns 0.0325 0 0 2.31 KB
master SendAsync netcoreapp3.1 5.22μs 2.2ns 7.94ns 0.0393 0 0 2.85 KB
master SendAsync net472 7.45μs 2.36ns 9.15ns 0.492 0 0 3.12 KB
#6655 SendAsync net6.0 4.34μs 1.42ns 5.49ns 0.0323 0 0 2.31 KB
#6655 SendAsync netcoreapp3.1 5.38μs 2.68ns 10.4ns 0.0377 0 0 2.85 KB
#6655 SendAsync net472 7.36μs 1.52ns 5.69ns 0.492 0 0 3.12 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 net6.0 1.47μs 0.781ns 3.03ns 0.0234 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.14μs 5.9ns 22.9ns 0.0223 0 0 1.64 KB
master EnrichedLog net472 2.63μs 2.01ns 7.8ns 0.25 0 0 1.57 KB
#6655 EnrichedLog net6.0 1.5μs 1.1ns 4.12ns 0.0226 0 0 1.64 KB
#6655 EnrichedLog netcoreapp3.1 2.12μs 1.33ns 5.17ns 0.0227 0 0 1.64 KB
#6655 EnrichedLog net472 2.58μs 1.33ns 5.14ns 0.25 0 0 1.57 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 net6.0 114μs 158ns 612ns 0.0563 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 118μs 179ns 692ns 0 0 0 4.28 KB
master EnrichedLog net472 149μs 211ns 817ns 0.668 0.223 0 4.46 KB
#6655 EnrichedLog net6.0 115μs 192ns 745ns 0.0572 0 0 4.28 KB
#6655 EnrichedLog netcoreapp3.1 115μs 201ns 777ns 0 0 0 4.28 KB
#6655 EnrichedLog net472 152μs 204ns 790ns 0.68 0.227 0 4.46 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 net6.0 2.9μs 0.691ns 2.59ns 0.0318 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.16μs 3.18ns 11.5ns 0.029 0 0 2.2 KB
master EnrichedLog net472 5.01μs 1.69ns 6.54ns 0.32 0 0 2.02 KB
#6655 EnrichedLog net6.0 2.91μs 0.982ns 3.8ns 0.0305 0 0 2.2 KB
#6655 EnrichedLog netcoreapp3.1 4.16μs 1.82ns 7.04ns 0.0291 0 0 2.2 KB
#6655 EnrichedLog net472 5.03μs 1.16ns 4ns 0.319 0 0 2.02 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 net6.0 1.36μs 0.605ns 2.34ns 0.0156 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.74μs 0.624ns 2.41ns 0.0155 0 0 1.14 KB
master SendReceive net472 2.11μs 1.34ns 5.2ns 0.183 0 0 1.16 KB
#6655 SendReceive net6.0 1.36μs 0.489ns 1.83ns 0.0156 0 0 1.14 KB
#6655 SendReceive netcoreapp3.1 1.78μs 0.736ns 2.85ns 0.0151 0 0 1.14 KB
#6655 SendReceive net472 2.11μs 1.22ns 4.55ns 0.184 0 0 1.16 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 net6.0 2.74μs 0.565ns 2.19ns 0.022 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 3.9μs 2.99ns 11.6ns 0.0216 0 0 1.65 KB
master EnrichedLog net472 4.46μs 2.17ns 8.11ns 0.324 0 0 2.04 KB
#6655 EnrichedLog net6.0 2.77μs 0.849ns 3.29ns 0.0222 0 0 1.6 KB
#6655 EnrichedLog netcoreapp3.1 3.93μs 3.29ns 12.7ns 0.0216 0 0 1.65 KB
#6655 EnrichedLog net472 4.31μs 6.86ns 26.6ns 0.323 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #6655

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑net472 1.122 843.86 946.93

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 392ns 0.434ns 1.68ns 0.00798 0 0 576 B
master StartFinishSpan netcoreapp3.1 606ns 1.38ns 5.36ns 0.0079 0 0 576 B
master StartFinishSpan net472 589ns 0.892ns 3.46ns 0.0916 0 0 578 B
master StartFinishScope net6.0 481ns 0.798ns 3.09ns 0.00986 0 0 696 B
master StartFinishScope netcoreapp3.1 725ns 1.74ns 6.72ns 0.00921 0 0 696 B
master StartFinishScope net472 842ns 1.98ns 7.67ns 0.104 0 0 658 B
#6655 StartFinishSpan net6.0 396ns 0.0955ns 0.37ns 0.00802 0 0 576 B
#6655 StartFinishSpan netcoreapp3.1 612ns 0.446ns 1.73ns 0.00795 0 0 576 B
#6655 StartFinishSpan net472 633ns 0.201ns 0.778ns 0.0918 0 0 578 B
#6655 StartFinishScope net6.0 493ns 0.105ns 0.395ns 0.00985 0 0 696 B
#6655 StartFinishScope netcoreapp3.1 721ns 0.265ns 0.993ns 0.00941 0 0 696 B
#6655 StartFinishScope net472 947ns 0.762ns 2.95ns 0.104 0 0 658 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 net6.0 615ns 1.18ns 4.58ns 0.00981 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 922ns 1.49ns 5.78ns 0.00937 0 0 696 B
master RunOnMethodBegin net472 1.06μs 2.1ns 8.12ns 0.104 0 0 658 B
#6655 RunOnMethodBegin net6.0 659ns 0.45ns 1.74ns 0.00972 0 0 696 B
#6655 RunOnMethodBegin netcoreapp3.1 948ns 0.516ns 2ns 0.00914 0 0 696 B
#6655 RunOnMethodBegin net472 1.07μs 0.217ns 0.839ns 0.104 0 0 658 B

@nhulston nhulston force-pushed the nicholas.hulston/s3-span-pointers branch from 9786cbe to 3d515cd Compare February 20, 2025 15:40
@nhulston nhulston changed the title [wip] S3 Span Pointers S3 Span Pointers Feb 20, 2025
@github-actions

github-actions Bot commented Feb 20, 2025

Copy link
Copy Markdown
Contributor

Snapshots difference summary

The following differences have been observed in committed snapshots. It is meant to help the reviewer.
The diff is simplistic, so please check some files anyway while we improve it.

4 occurrences of :

+    SpanLinks: [
+      {
+        Attributes: {
+          link.kind: span-pointer,
+          ptr.dir: d,
+          ptr.hash: Guid_4,
+          ptr.kind: aws.s3.object
+        }
+      }
+    ]

4 occurrences of :

-      aws.requestId: Guid_4,
+      aws.requestId: Guid_5,

4 occurrences of :

-      aws.requestId: Guid_5,
+      aws.requestId: Guid_6,

4 occurrences of :

+    SpanLinks: [
+      {
+        Attributes: {
+          link.kind: span-pointer,
+          ptr.dir: d,
+          ptr.hash: Guid_7,
+          ptr.kind: aws.s3.object
+        }
+      }
+    ]

4 occurrences of :

-      aws.requestId: Guid_6,
+      aws.requestId: Guid_8,

4 occurrences of :

-      aws.requestId: Guid_7,
+      aws.requestId: Guid_9,

4 occurrences of :

-      aws.requestId: Guid_8,
+      aws.requestId: Guid_10,

4 occurrences of :

-      aws.requestId: Guid_9,
+      aws.requestId: Guid_11,

4 occurrences of :

-      aws.requestId: Guid_10,
+      aws.requestId: Guid_12,

4 occurrences of :

-      aws.requestId: Guid_11,
+      aws.requestId: Guid_13,

4 occurrences of :

-      aws.requestId: Guid_12,
+      aws.requestId: Guid_14,

4 occurrences of :

+    SpanLinks: [
+      {
+        Attributes: {
+          link.kind: span-pointer,
+          ptr.dir: d,
+          ptr.hash: Guid_15,
+          ptr.kind: aws.s3.object
+        }
+      }
+    ]

4 occurrences of :

-      aws.requestId: Guid_13,
+      aws.requestId: Guid_16,

4 occurrences of :

-      aws.requestId: Guid_14,
+      aws.requestId: Guid_17,

4 occurrences of :

-      aws.requestId: Guid_15,
+      aws.requestId: Guid_18,

4 occurrences of :

-      aws.requestId: Guid_16,
+      aws.requestId: Guid_19,

Comment thread tracer/src/Datadog.Trace/SpanContext.cs
@nhulston nhulston force-pushed the nicholas.hulston/s3-span-pointers branch from 7e81f2c to ffc46b6 Compare February 21, 2025 18:19
@nhulston

This comment was marked as resolved.

@nhulston nhulston marked this pull request as ready for review February 24, 2025 15:45
@nhulston nhulston requested review from a team as code owners February 24, 2025 15:45
@lucaspimentel lucaspimentel added area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) area:serverless area:integrations type:new-feature labels Feb 24, 2025
Comment thread tracer/src/Datadog.Trace/SpanContext.cs Outdated
@lucaspimentel lucaspimentel requested a review from a team as a code owner February 25, 2025 15:29
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Feb 25, 2025

Copy link
Copy Markdown

Datadog Report

All test runs 9125a85 🔗

2 Total Test Services: 0 Failed, 2 Passed
❄️ 1 with New Flaky

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Test Service View
dd-trace-dotnet 0 0 2 566671 4458 34h 38m 47.93s Link
exploration_tests 0 0 0 22085 3 2m 8.95s Link

@lucaspimentel lucaspimentel 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.

Thanks! Someone else should look at SpanPointers and SpanPointersTests since I made a few changes to those that should get reviewed.

@lucaspimentel lucaspimentel requested a review from a team February 26, 2025 23:53

namespace Datadog.Trace.ClrProfiler.Managed.Tests.AutoInstrumentation.AWS.Shared;

public class SpanPointersTests

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we add tests for null and empty data?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've made eTag nullable and added a check+test for it. However, I don't think we need to add logic to handle empty or missing bucket/key, because these values should theoretically always be there. Even if they are missing, all that will happen is we generate a hash with no matching downstream hash (which is not a big deal)

Comment thread tracer/src/Datadog.Trace/SpanContext.cs Outdated
/// to specify that the new span should not inherit the currently active scope as its parent.
/// </summary>
public static readonly ISpanContext None = new ReadOnlySpanContext(traceId: Trace.TraceId.Zero, spanId: 0, serviceName: null);
public static readonly SpanContext None = new();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Seems like a pretty large change to go from a ReadOnlySpanContext implementation that is an ISpanContext to a full fledged SpanContext

This will change behavior of anything else that uses None potentially.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Additionally, I am unsure if this needs to be mapped the manual code as well

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this could potentially cause different context creation here

internal SpanContext CreateSpanContext(ISpanContext parent = null, string serviceName = null, TraceId traceId = default, ulong spanId = 0, string rawTraceId = null, string rawSpanId = null)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

cc @lucaspimentel thoughts on this as I see you recommended it and I am unsure if this was already discussed?

@lucaspimentel lucaspimentel Mar 3, 2025

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.

For context, SpanContext.None and the ReadOnlySpanContext type were added in #2309 and were meant only for public consumption, not for internal use (see the PR description and the related issue for more details). These days, Datadog.Trace.Manual has its own copy of ReadOnlySpanContext here and it's own SpanContext.None to keep the existing API from 2.x to 3.x. I don't think the changes in this PR affect the public API.

As for the internal API, maybe we should keep SpanContext.None and ReadOnlySpanContext.None as two separate properties (of type SpanContext and ReadOnlySpanContext, respectively)? This way the existing code can switch to using ReadOnlySpanContext.None to maintain it's current behavior, and this new code can use SpanContext.None (because it requires a SpanContext, not a ISpanContext). Does that make sense? I can push a quick commit to this PR if you agree.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes that sounds good to me thanks!
And thanks for the historical context around the context!

@lucaspimentel lucaspimentel Mar 5, 2025

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.

Never mind. After trying this out, I'm going to recommend reverting this change for now to be safe and going back to something like SpanContext.Zero, like @nhulston had before.

There's definitely some cleanup/refactoring we can do around SpanContext and ReadOnlySpanContext now that it's all internal APIs, but we should do that in separate PRs.

@lucaspimentel lucaspimentel Mar 5, 2025

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.

I pushed a commit to revert the change and another to rename ZeroContext to Zero. Apologies for all the back and forth 😅 Thank you @bouwkast for catching that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

span.AddLink(spanLink);
}

internal static string ConcatenateComponents(string bucketName, string key, string eTag)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you get the RFC owners to validate whether this adheres to the expected logic?

@nhulston nhulston Feb 28, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These rules are defined here: https://github.com/DataDog/dd-span-pointer-rules/tree/main/AWS/S3/Object
but we have identical unit tests (and later functional tests once this is out) across the tracers.

cc @apiarian-datadog

@lucaspimentel lucaspimentel 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.

Changing my review just so this doesn't get merged yet.

@lucaspimentel lucaspimentel requested a review from a team March 5, 2025 17:22
@nhulston nhulston requested a review from bouwkast March 5, 2025 19:15

@bouwkast bouwkast left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks! LGTM

@nhulston nhulston merged commit b63f5cf into master Mar 6, 2025
@nhulston nhulston deleted the nicholas.hulston/s3-span-pointers branch March 6, 2025 14:46
@github-actions github-actions Bot added this to the vNext-v3 milestone Mar 6, 2025
ddyurchenko pushed a commit that referenced this pull request Mar 31, 2025
chojomok pushed a commit that referenced this pull request Jul 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:integrations area:serverless area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) type:new-feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants