Skip to content

Commit 1f0e817

Browse files
committed
fix: Prevent creation of useless instances
1 parent 2908881 commit 1f0e817

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/DDTrace/OpenTelemetry/Span.php

+4-9
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ private function __construct(
9393
$span->name = $this->operationNameConvention = Convention::defaultOperationName($span);
9494
}
9595

96-
$this->uniqueIdentifier = \spl_object_hash($this); // traceId + spanId is NOT a valid unique identifier, as the traceId can be modified
97-
9896
// Set the span links
9997
if ($isRemapped) {
10098
// At initialization time (now), only set the links if the span was created using the OTel API
@@ -111,7 +109,7 @@ private function __construct(
111109
$spanLink->droppedAttributesCount = 0; // Attributes limit aren't supported/meaningful in DD
112110

113111
// Save the link
114-
ObjectKVStore::put($spanLink, $this->uniqueIdentifier, $link);
112+
ObjectKVStore::put($spanLink, "link", $link);
115113
$span->links[] = $spanLink;
116114
}
117115
}
@@ -453,7 +451,7 @@ private function updateSpanLinks()
453451
$otel = [];
454452
foreach ($datadogSpanLinks as $datadogSpanLink) {
455453
// Check if the link relationship exists
456-
$link = ObjectKVStore::get($datadogSpanLink, $this->uniqueIdentifier);
454+
$link = ObjectKVStore::get($datadogSpanLink, "link");
457455
if ($link === null) {
458456
// Create the link
459457
$link = new Link(
@@ -467,12 +465,9 @@ private function updateSpanLinks()
467465
);
468466

469467
// Save the link
470-
ObjectKVStore::put($datadogSpanLink, $this->uniqueIdentifier, $link);
471-
$otel[] = $link;
472-
} else {
473-
// Save the link
474-
$otel[] = $link;
468+
ObjectKVStore::put($datadogSpanLink, "link", $link);
475469
}
470+
$otel[] = $link;
476471
}
477472

478473
// Update the links

0 commit comments

Comments
 (0)