Search by

pushinbr / pam-native-observability

DavidWilliamBalbino

Vendor-neutral telemetry and a native Sentry exporter (crashes, ANRs, NDK, PHP errors) for PAM Native.

Package info

github.com/push-in/pam-native-observability

Type:pam-native-plugin

pkg:composer/pushinbr/pam-native-observability

Statistics

Installs: 48

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.5.5 2026-11-18 04:37 UTC

README

pam-native-observability: Vendor-neutral traces, metrics and logs plus a native Sentry exporter for crashes and PHP errors.

Traces, metrics, logs and crash context without vendor lock-in.
Instrument PHP, Rust and native boundaries with redacted, bounded telemetry exported over OTLP to the backend of your choice, or report crashes, ANRs and PHP errors through the native Sentry SDK.

Packagist Latest release PHP 8.5 CI License

Install · Quick example · Platforms · Permissions · Docs · Issues

Install

Inside a PAM Native project, add only this capability:

pam composer require pushinbr/pam-native-observability
pam doctor --fix

The package is a PAM Native plugin (module observability); nothing is added to pam-native.json. The pure-PHP telemetry pipeline (Observability instances, encoders, transports) also works outside PAM Native. Use pam packages to inspect availability. New to PAM? Follow the five-minute PAM Native setup once (pam init my-app --template native).

Quick example

use Pam\Native\Observability\{CurlTelemetryTransport, Observability, ObservabilityConfig};
use Pam\Native\Observability\{SentryExporter, SpanStatus, WireProtocol};

// Vendor-neutral pipeline (OTLP/HTTP JSON to your collector)
$config = new ObservabilityConfig(
    endpoint: 'https://collector.example',
    serviceName: 'showcase-mobile',
    serviceVersion: '1.0.0',
    wireProtocol: WireProtocol::OtlpHttpJson,
);
$telemetry = new Observability($config, new CurlTelemetryTransport());
$span = $telemetry->span('feed.load');
try { loadFeed(); $span->status(SpanStatus::Ok); }
catch (Throwable $e) { $span->exception($e); throw $e; }
finally { $span->end(); $telemetry->flush(); }

// Native Sentry exporter: once, at boot
Observability::exporter(
    SentryExporter::dsn('https://public@o1.ingest.sentry.io/42')
        ->environment('production')
        ->release('chat@2.4.0+118')
        ->tracesSampleRate(0.25),
);
Observability::capture($error, tags: ['screen' => 'chat']); // handled throwable

The queue is bounded and drops the oldest signals under backpressure; failed exports are restored to the front of the queue. Secrets and personal data are never collected automatically. Walk-throughs: telemetry pipeline (W3C traceparent continuation, custom transports), Sentry exporter (what is captured, App::onError(), iOS), certified OTLP export.

Platform support

Platform Support Notes
Android API 24+ Sentry Android core + NDK 8.50.1
iOS 15.0+ Sentry Cocoa 8.x Swift package (from 8.40.0); not yet validated on a device
PAM Native 1.53.1 to < 2.0.0 composer.json requires ^1.53.1 (Android 7.0/7.1 hosts); PHP 8.5+

Permissions and requirements

Platform Declared by the plugin
Android android.permission.INTERNET, android.permission.ACCESS_NETWORK_STATE
iOS No Info.plist keys
  • Android: dependencies io.sentry:sentry-android-core and sentry-android-ndk 8.50.1. The manifest disables Sentry's auto-init (io.sentry.auto-init=false, SentryInitProvider removed) and adds the SentryBootstrap content provider that restores the persisted exporter before PHP boots.
  • iOS: Swift package getsentry/sentry-cocoa from 8.40.0 (up to next major), product Sentry. Upload dSYMs to Sentry for symbolicated native frames.
  • CurlTelemetryTransport needs the PHP curl extension; implement TelemetryTransport when it is not available.

What you can build

  • Cross-layer performance tracing
  • Crash and error correlation
  • Production health dashboards and SLO evidence
Best for A focused capability you can add to any PAM Native application
Native path OpenTelemetry-compatible pipeline · Sentry Android/Cocoa SDKs
Application model Composer package + generated native integration
Design rule Independent module; no feed, vertical or application template bundled

The default HTTPS transport works with a collector or ingestion gateway; use Observability::exporter(SentryExporter::dsn(...)) for Sentry, or implement TelemetryTransport for Datadog, Honeycomb, New Relic or an offline spool.

Production checklist

  • Send remote telemetry only to HTTPS endpoints you control or explicitly trust.
  • Define an attribute allowlist and never attach secrets or personal data by default.
  • Keep captureExceptionDetails disabled unless users consent to messages, source paths, line numbers and stack traces leaving the device.
  • Flush on lifecycle transitions without blocking the UI indefinitely.
  • Monitor dropped-signal counters and tune bounded queues from evidence.
  • Run pam doctor, pam test and a signed release build on every supported platform.
  • Exercise denial, cancellation, backgrounding, process restart and offline behavior before release.

Troubleshooting

  • Nothing is exported: verify endpoint, sampling decision and explicit flush().
  • Batches retry forever: make the transport surface permanent versus transient failures.
  • Signals disappear under load: inspect queue capacity and dropped-signal diagnostics.
  • Native integration is stale: run pam doctor --fix, rebuild the native host and inspect the first reported diagnostic.

Compatibility

pushinbr/pam-native-observability pushinbr/pam-native Android iOS
0.5.4+ >=1.53.1 <2.0.0 API 24+ (Android 7.0), Sentry Android 8.50.1 15+, Sentry Cocoa 8.x
0.5.0 to 0.5.3 >=1.7.0 <2.0.0 (tested with 1.7.0 and 1.46.x; App::onError() and Diagnostics\ErrorReporter need 1.7+) API 26+, Sentry Android 8.50.1 15+, Sentry Cocoa 8.x
0.4.x >=1.0.35 <2.0.0 API 26+ 15+
0.3.x >=1.0.35 <2.0.0 API 26+ Telemetry pipeline only

Platform SDKs, credentials, entitlements, physical hardware and store configuration remain application responsibilities.

Docs

Part of the PAM ecosystem

PAM

PAM runs PHP natively on servers, desktops and phones. This repository is one piece of it.

PAM PAM Desktop PAM Native Ecosystem
the runtime and CLI native desktop apps in PHP native Android and iOS apps in PHP every official package and plugin

Docs: push-in.github.io/pam-docs · Issues

Apache License 2.0 · Made in Brazil by Pushin