Skip to content

Commit

Permalink
Actually make the OpenTelemetry code properly 8.4 compatible.
Browse files Browse the repository at this point in the history
That code is not available on PHP 7.0 anyway.
  • Loading branch information
bwoebi committed Jan 6, 2025
1 parent aa32943 commit 62ba353
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/DDTrace/Integrations/Logs/LogsIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static function replacePlaceholders(
): string {
return strtr(
$message,
$placeholders ? $placeholders : LogsIntegration::getPlaceholders($traceIdSubstitute, $spanIdSubstitute)
$placeholders ?: LogsIntegration::getPlaceholders($traceIdSubstitute, $spanIdSubstitute)
);
}

Expand Down
9 changes: 5 additions & 4 deletions src/DDTrace/OpenTelemetry/Span.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScopeInterface;
use OpenTelemetry\SDK\Common\Time\ClockFactory;
use OpenTelemetry\SDK\Resource\ResourceInfo;
use Psr\Link\LinkInterface;
use Throwable;
use function DDTrace\close_span;
use function DDTrace\switch_stack;
Expand Down Expand Up @@ -427,7 +428,7 @@ public function updateName(string $name): SpanInterface
/**
* @inheritDoc
*/
public function setStatus(string $code, $description = null): SpanInterface
public function setStatus(string $code, ?string $description = null): SpanInterface
{
if ($this->hasEnded()) {
return $this;
Expand Down Expand Up @@ -459,7 +460,7 @@ public function setStatus(string $code, $description = null): SpanInterface
/**
* @inheritDoc
*/
public function end($endEpochNanos = null): void
public function end(?int $endEpochNanos = null): void
{
if ($this->hasEnded()) {
return;
Expand All @@ -472,7 +473,7 @@ public function end($endEpochNanos = null): void
$this->spanProcessor->onEnd($this);
}

public function endOTelSpan($endEpochNanos = null): void
public function endOTelSpan(?int $endEpochNanos = null): void
{
if ($this->hasEnded()) {
return;
Expand Down Expand Up @@ -572,7 +573,7 @@ private function updateSpanEvents()
$this->totalRecordedEvents = count($otel);
}

private function createAndSaveSpanLink(SpanContextInterface $context, iterable $attributes = [], $link = null)
private function createAndSaveSpanLink(SpanContextInterface $context, iterable $attributes = [], ?LinkInterface $link = null)
{
$spanLink = new SpanLink();
$spanLink->traceId = $context->getTraceId();
Expand Down
6 changes: 3 additions & 3 deletions src/DDTrace/OpenTelemetry/SpanBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,18 @@ public function addLink(SpanContextInterface $context, iterable $attributes = []
return $this;
}

public function addEvent(string $name, iterable $attributes = [], $timestamp = null): SpanBuilderInterface
public function addEvent(string $name, iterable $attributes = [], ?int $timestamp = null): SpanBuilderInterface
{
$this->events[] = new Event(
$name,
$name,
$timestamp ?? (int)(microtime(true) * 1e9),
$this->tracerSharedState
->getSpanLimits()
->getEventAttributesFactory()
->builder($attributes)
->build(),
);

return $this;
}

Expand Down

0 comments on commit 62ba353

Please sign in to comment.