Skip to content

Conversation

@stevensJourney
Copy link
Collaborator

Overview

This allows connecting clients to specify additional metadata to be included in the PowerSync service logs. Typical use cases might be to log the client's application version or other device metadata.

A new optional app_metadata field is now accepted for the HTTP and WebSocket /sync/stream endpoint. This can contain a Record<string,string> map of values.

The service will now log the metadata when a client's sync stream starts and stops. This metadata is not currently added to all logs, the request rid can be used to correlate metadata with other logs.

The service limits the amount of logged/stored data. We currently only log a maximum of 10 keys in the provided app_metadata. Each string is capped to 50 characters in length. These values might be configurable in future.

A JSON sample for a log

{
  "container": "default",
  "level": "info",
  "message": "Sync stream started",
  "namespace": "anamespace",
  "node": "anode",
  "pod": "apod",
  "timestamp": "2025-11-24T12:13:45.647Z",
  "_entry": "{\"app_metadata\":{\"appVersion\":\"1.0.0\"},\"client_id\":\"2788c57b-1cf4-41a0-bc0f-a46c5\",\"client_params\":{},\"level\":\"info\",\"message\":\"Sync stream started\",\"rid\":\"s/019ac8-c6a0-7455-93c2-c41f83963d50\",\"timestamp\":\"2025-11-24T12:13:45.647Z\",\"user_agent\":\"powersync-js/1.43.0 powersync-web Chromium/142 macos\",\"user_id\":\"123\"}"
}

This also adds logging client_params to sync stream requests. This could be used to aid with debugging.

@changeset-bot
Copy link

changeset-bot bot commented Nov 24, 2025

🦋 Changeset detected

Latest commit: df088e1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@powersync/service-core Minor
@powersync/service-core-tests Patch
@powersync/service-module-core Patch
@powersync/service-module-mongodb-storage Patch
@powersync/service-module-mongodb Patch
@powersync/service-module-mysql Patch
@powersync/service-module-postgres-storage Patch
@powersync/service-module-postgres Patch
@powersync/service-image Minor
test-client Patch
@powersync/service-schema Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@rkistner rkistner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend tweaking the limits a bit, but happy with the rest.

@stevensJourney stevensJourney merged commit 6eee0b3 into main Nov 28, 2025
37 of 38 checks passed
@stevensJourney stevensJourney deleted the metadata-logs branch November 28, 2025 13:48
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.

3 participants