Skip to content

Commit

Permalink
fix: Prevent creation of useless instances
Browse files Browse the repository at this point in the history
  • Loading branch information
PROFeNoM committed Jan 9, 2024
1 parent 2908881 commit 1f0e817
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/DDTrace/OpenTelemetry/Span.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ private function __construct(
$span->name = $this->operationNameConvention = Convention::defaultOperationName($span);
}

$this->uniqueIdentifier = \spl_object_hash($this); // traceId + spanId is NOT a valid unique identifier, as the traceId can be modified

// Set the span links
if ($isRemapped) {
// At initialization time (now), only set the links if the span was created using the OTel API
Expand All @@ -111,7 +109,7 @@ private function __construct(
$spanLink->droppedAttributesCount = 0; // Attributes limit aren't supported/meaningful in DD

// Save the link
ObjectKVStore::put($spanLink, $this->uniqueIdentifier, $link);
ObjectKVStore::put($spanLink, "link", $link);
$span->links[] = $spanLink;
}
}
Expand Down Expand Up @@ -453,7 +451,7 @@ private function updateSpanLinks()
$otel = [];
foreach ($datadogSpanLinks as $datadogSpanLink) {
// Check if the link relationship exists
$link = ObjectKVStore::get($datadogSpanLink, $this->uniqueIdentifier);
$link = ObjectKVStore::get($datadogSpanLink, "link");
if ($link === null) {
// Create the link
$link = new Link(
Expand All @@ -467,12 +465,9 @@ private function updateSpanLinks()
);

// Save the link
ObjectKVStore::put($datadogSpanLink, $this->uniqueIdentifier, $link);
$otel[] = $link;
} else {
// Save the link
$otel[] = $link;
ObjectKVStore::put($datadogSpanLink, "link", $link);
}
$otel[] = $link;
}

// Update the links
Expand Down

0 comments on commit 1f0e817

Please sign in to comment.