Skip to content

Add optional app option sent with every log and metric - #5

Merged
szymeo merged 2 commits into
mainfrom
malini/01J6C51B4D8E9FB47E88EC82CA
Oct 24, 2026
Merged

szymeo merged 2 commits into
mainfrom
malini/01J6C51B4D8E9FB47E88EC82CA

Conversation

@szymeo

@szymeo szymeo commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Merge only after the backend change is deployed

The production API rejects unknown body fields with HTTP 400 until the backend change in logdash-io/logdash.io (branch malini/01J81668FC698FE4F1F86F87AA) is live.
Until then, every log and metric sent with app set is rejected, and the SDK drops it silently.
Instances without app send exactly the same payloads as before.
Do not merge, tag or release to Packagist before that deploy.

What

New optional app option on Logdash::create().
A domain key is shared by all apps of a domain, and app names the app sending the data, so the dashboard can filter by it.

  • app set: every POST /logs and PUT /metrics body carries "app": "<value>", trimmed.
  • app unset, empty or blank: the key is left out, no null and no empty string.
  • Older service keys ignore app. The server cuts it to 64 characters.
  • This SDK has no child or namespaced loggers and sends no namespace with metrics, so the backend's new namespace field on PUT /metrics does not affect it.

Interaction with #4

#4 moves logs to POST /logs/batch and queues metrics.
Whichever PR merges second adds the app line to the two queue->add([...]) arrays, so every batch entry and every metric carries it, and calls flush() in the new tests before reading the bodies.

Tests

New tests run the SDK against PHP's built-in server and check the bodies it receives for logs and metrics, with and without app.
They fail on main and catch dropping, nulling or not trimming app.
composer qa (PHPCS, parallel-lint, PHPStan, PHPUnit) passes in the repo's PHP 8.1 Docker image, 25 of 25 test runs green.

CI

The test job now runs composer run-script test, so PHPUnit runs on every pull request; before, CI ran only PHPStan and PHPCS.
Also fixes what actionlint reports on the workflow: actions/cache@v3 is bumped to v4, and $GITHUB_OUTPUT is quoted in the tag step.

@szymeo
szymeo marked this pull request as ready for review October 24, 2026 11:48
@szymeo
szymeo merged commit 02e1ac3 into main Oct 24, 2026
2 checks passed
@szymeo
szymeo deleted the malini/01J6C51B4D8E9FB47E88EC82CA branch October 24, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant