Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# For list of PHP versions see: https://hub.docker.com/r/phpstorm/php-apache/tags
FROM phpstorm/php-apache:8.2-xdebug3.2

RUN pecl install opentelemetry \
&& docker-php-ext-enable opentelemetry
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
// name of the dev container
"name": "highlight-php-sdk-container",

"build": {
// Path is relative to the devcontainer.json file.
"dockerfile": "Dockerfile"
},

// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
"settings": {},
"extensions": [
"bmewburn.vscode-intelephense-client",
"xdebug.php-debug"
]
}
},

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "php --ri opentelemetry && composer install && composer test"
}
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: "Continuous Integration"

on:
push:
branches: ['main']
pull_request:
types: [opened, synchronize]

jobs:
tests:
name: CI
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
coverage: "none"
extensions: "opentelemetry"
php-version: "8.2"
tools: composer

- name: Install Dependencies
uses: ramsey/composer-install@v2
with:
composer-options: "--ansi --no-interaction --no-progress --prefer-dist"

- name: Run Tests
run: composer test
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/.idea
/.php-cs-fixer.php
/.php-cs-fixer.cache
/.phpunit.cache
/.psalm/cache
/composer.lock
/vendor
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,9 @@
"rector/rector": ">=0.15.20",
"symfony/http-client": "^5.2",
"symfony/yaml": "^6 || ^5"
}
},
"scripts": {
"testSilent": "vendor/bin/phpunit tests",
"test": "@testSilent --verbose"
}
}
2 changes: 1 addition & 1 deletion src/SDK/Common/HighlightHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct($sessionId, $requestId)
$this->requestId = $requestId;
}

public static function parse($header): HighlightHeader
public static function parse($header): ?HighlightHeader
{
$split = explode('/', $header);
if (count($split) == 2) {
Expand Down
10 changes: 5 additions & 5 deletions src/SDK/Common/Priority.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ public function difference(): int
return $this->difference;
}

public static function LOW()
public static function LOW(): self
{
return new Priority(self::LOW);
}

public static function NORMAL()
public static function NORMAL(): self
{
return new Priority(self::NORMAL);
}

public static function MEDIUM()
public static function MEDIUM(): self
{
return new Priority(self::MEDIUM);
}

public static function HIGH()
public static function HIGH(): self
{
return new Priority(self::HIGH);
}
}
}
2 changes: 1 addition & 1 deletion src/SDK/Common/Record/HighlightRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getTimeOccurred(): DateTimeImmutable
/**
* Returns the attributes associated with the record.
*
* @return Attribute the attributes associated with the record
* @return Attributes the attributes associated with the record
*/
public function getAttributes(): Attributes
{
Expand Down
14 changes: 7 additions & 7 deletions src/SDK/Common/Record/HighlightRecordBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class HighlightRecordBuilder
protected ?string $requestId;

/**
* Constructs a new instance of `Builder`.
* Constructs a new instance of `HighlightRecordBuilder`.
*/
protected function __construct(?HighlightRecord $record = null)
{
Expand All @@ -43,7 +43,7 @@ protected function __construct(?HighlightRecord $record = null)
* Sets the time the record occurred.
*
* @param DateTimeImmutable $timeOccurred the time the record occurred
* @return this `Builder` instance
* @return this `HighlightRecordBuilder` instance
*/
public function timeOccurred(DateTimeImmutable $timeOccurred): self
{
Expand All @@ -55,7 +55,7 @@ public function timeOccurred(DateTimeImmutable $timeOccurred): self
* Sets the user session and request id associated with the record.
*
* @param HighlightHeader $header associated with the record.
* @return this `Builder` instance
* @return this `HighlightRecordBuilder` instance
*/
public function requestHeader(HighlightHeader $header): self
{
Expand All @@ -68,7 +68,7 @@ public function requestHeader(HighlightHeader $header): self
* Sets the user session associated with the record using a session ID string.
*
* @param string|null $sessionId the session ID string to use as the user session ID
* @return this `Builder` instance
* @return this `HighlightRecordBuilder` instance
*/
public function userSessionString(?string $sessionId): self
{
Expand All @@ -80,7 +80,7 @@ public function userSessionString(?string $sessionId): self
* Sets the user session associated with the record.
*
* @param HighlightSessionId|null $userSession the user session associated with the record
* @return this `Builder` instance
* @return this `HighlightRecordBuilder` instance
*/
public function userSession(?HighlightSessionId $userSession): self
{
Expand All @@ -92,7 +92,7 @@ public function userSession(?HighlightSessionId $userSession): self
* Sets the request ID associated with the record.
*
* @param string|null $requestId the request ID associated with the record
* @return this `Builder` instance
* @return this `HighlightRecordBuilder` instance
*/
public function requestId(?string $requestId): self
{
Expand All @@ -104,7 +104,7 @@ public function requestId(?string $requestId): self
* Applies the specified closure to the attributes builder.
*
* @param callable $function the closure to apply to the attributes builder
* @return this `Builder` instance
* @return this `HighlightRecordBuilder` instance
*/
public function attributes(callable $function): self
{
Expand Down
2 changes: 1 addition & 1 deletion src/SDK/Common/Record/HighlightSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class HighlightSession implements HighlightSessionId
{
private string $sessionId;

public function __constructor(string $sessionId)
public function __construct(string $sessionId)
{
$this->sessionId = $sessionId;
}
Expand Down
10 changes: 5 additions & 5 deletions src/SDK/Highlight.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public static function captureExceptionWithSessionAndRequest(
): void {
self::requireInitialization();

self::captureRecord(
self::$highlight->captureRecord(
HighlightRecord::error()
->throwable($throwable)
->requestId($requestId)
Expand All @@ -168,7 +168,7 @@ public static function captureExceptionWithHighlightHeader(
): void {
self::requireInitialization();

self::captureRecord(
self::$highlight->captureRecord(
HighlightRecord::error()
->throwable($throwable)
->requestHeader($header)
Expand Down Expand Up @@ -209,7 +209,7 @@ public static function captureLogWithSessionAndRequest(
): void {
self::requireInitialization();

self::captureRecord(
self::$highlight->captureRecord(
HighlightRecord::log()
->severity($severity)
->message($message)
Expand All @@ -222,7 +222,7 @@ public static function captureLogWithSessionAndRequest(
/**
* Captures a record using a record builder and sends it to Highlight.
*
* @param HighlightRecord\Builder $builder the builder to use for the record
* @param HighlightRecordBuilder $builder the builder to use for the record
*
* @throws HighlightIllegalStateException if Highlight is not initialized
* @throws HighlightInvalidRecordException if the record is invalid
Expand All @@ -231,7 +231,7 @@ public static function captureRecordFromBuilder(HighlightRecordBuilder $builder)
{
self::requireInitialization();

self::captureRecord($builder->build());
self::$highlight->captureRecord($builder->build());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/SDK/HighlightLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct(Highlight $highlight) {
$this->logger = $openTelemetry->getLogger("highlight-php");
}

public function process(HighlightLogRecord $record) {
public function process(HighlightLogRecord $record): void {
$severity = $record->getSeverity();
$logRecord = new LogRecord($record->getMessage());

Expand Down
2 changes: 1 addition & 1 deletion src/SDK/HighlightTracer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(Highlight $highlight)
$this->tracer = $highlightOpenTelemetry->getTracerProvider()->getTracer('highlight-php');
}

public function process(HighlightErrorRecord $record)
public function process(HighlightErrorRecord $record): void
{
$spanBuilder = $this->tracer->spanBuilder('highlight-ctx');

Expand Down