SentryObservabilityAdapter - viames/pair GitHub Wiki

Pair framework: SentryObservabilityAdapter

Pair\Services\SentryObservabilityAdapter forwards Pair observability spans and events to Sentry without requiring the Sentry PHP SDK.

It implements ObservabilityAdapter and ObservabilityEventAdapter:

  • completed spans are sent as Sentry transaction envelopes
  • warning/error log events are sent as Sentry event envelopes
  • adapter failures are swallowed by Observability, so telemetry cannot break application flow

For projects that already use the official Sentry SDK, prefer the SDK. This adapter exists as a dependency-free bridge for Pair projects that want basic error and tracing export with minimal setup.

Configuration

SENTRY_DSN=
SENTRY_ENVIRONMENT=
SENTRY_RELEASE=
SENTRY_TRACES_SAMPLE_RATE=1.0
SENTRY_ERROR_SAMPLE_RATE=1.0
SENTRY_TIMEOUT=10
SENTRY_CONNECT_TIMEOUT=3

Notes:

  • SENTRY_DSN controls where events are sent.
  • SENTRY_ENVIRONMENT falls back to APP_ENV.
  • SENTRY_RELEASE falls back to APP_VERSION.
  • SENTRY_TRACES_SAMPLE_RATE controls transaction export.
  • SENTRY_ERROR_SAMPLE_RATE controls warning/error event export.

Register the adapter

use Pair\Core\AdapterKeys;
use Pair\Core\Application;
use Pair\Services\SentryObservabilityAdapter;

$app = Application::getInstance();
$app->setAdapter(AdapterKeys::OBSERVABILITY, new SentryObservabilityAdapter());

Using AdapterKeys::OBSERVABILITY also activates the Observability facade for the current process.

Operational notes

  • Keep SENTRY_DSN in .env, not in Git.
  • Start with low SENTRY_TRACES_SAMPLE_RATE in high-traffic production systems.
  • Leave SENTRY_ERROR_SAMPLE_RATE=1.0 unless the project has very high error volume.
  • Pair redacts common sensitive attribute names before telemetry leaves the process.
  • Do not attach request bodies or raw SQL through custom attributes.

Sentry references

See also: Observability, ObservabilityEvent, OpenTelemetryHttpExporter, Configuration file.