Skip to content

Commit c78c92a

Browse files
authored
adding LogRecord phpdocs (#956)
clarify that timestamps expect timestamp in nanoseconds, plus minor logging example fixes.
1 parent 0554a4f commit c78c92a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Logs/LogRecord.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,18 @@ class LogRecord
1818
protected $body = null;
1919
protected array $attributes = [];
2020

21+
/**
22+
* @param mixed $body
23+
*/
2124
public function __construct($body = null)
2225
{
2326
$this->body = $body;
2427
}
2528

29+
/**
30+
* @param int $timestamp Timestamp, in nanoseconds since the unix epoch, when the event occurred.
31+
* @see https://opentelemetry.io/docs/reference/specification/logs/data-model/#field-timestamp
32+
*/
2633
public function setTimestamp(int $timestamp): self
2734
{
2835
$this->timestamp = $timestamp;
@@ -37,20 +44,32 @@ public function setContext(?ContextInterface $context = null): self
3744
return $this;
3845
}
3946

47+
/**
48+
* @param int $severityNumber Severity number
49+
* @see https://opentelemetry.io/docs/reference/specification/logs/data-model/#field-severitynumber
50+
*/
4051
public function setSeverityNumber(int $severityNumber): self
4152
{
4253
$this->severityNumber = $severityNumber;
4354

4455
return $this;
4556
}
4657

58+
/**
59+
* @param string $severityText Severity text, also known as log level
60+
* @see https://opentelemetry.io/docs/reference/specification/logs/data-model/#field-severitynumber
61+
*/
4762
public function setSeverityText(string $severityText): self
4863
{
4964
$this->severityText = $severityText;
5065

5166
return $this;
5267
}
5368

69+
/**
70+
* @param iterable $attributes Additional information about the specific event occurrence.
71+
* @see https://opentelemetry.io/docs/reference/specification/logs/data-model/#field-attributes
72+
*/
5473
public function setAttributes(iterable $attributes): self
5574
{
5675
foreach ($attributes as $name => $value) {
@@ -67,13 +86,19 @@ public function setAttribute(string $name, $value): self
6786
return $this;
6887
}
6988

89+
/**
90+
* @param mixed $body The log record body
91+
*/
7092
public function setBody($body = null): self
7193
{
7294
$this->body = $body;
7395

7496
return $this;
7597
}
7698

99+
/**
100+
* @param int|null $observedTimestamp Time, in nanoseconds since the unix epoch, when the event was observed by the collection system.
101+
*/
77102
public function setObservedTimestamp(int $observedTimestamp = null): self
78103
{
79104
$this->observedTimestamp = $observedTimestamp;

0 commit comments

Comments
 (0)