Talaria

Docs / SDKs / Silverstripe

Silverstripe

Monolog on Injector LoggerInterface, optional browser SDK wiring, and request tracing.

Built on the PHP SDK. One Composer package installs both the core client and this Silverstripe module. Full package guide: docs/silverstripe.md.

Install and configure

Set environment variables with a project client key (tal_live_…), then flush config. Missing DSN or key disables the client safely. YAML minLevel (default warning) applies to both the Monolog handler and the shared client. Set enableTracing and tracesSampleRate to capture request transactions, DB, and outbound HTTP spans.

bash
composer require newtalaria/logging
.envbash
TALARIA_DSN="https://api.newtalaria.com"
TALARIA_API_KEY="tal_live_…"
TALARIA_ENVIRONMENT="production"
TALARIA_RELEASE="1.2.3"
# Optional when PHP DSN is not browser-reachable:
# TALARIA_BROWSER_DSN="https://api.newtalaria.com"
bash
vendor/bin/sake dev/build flush=1
_config/talaria.ymlyaml
---
Name: app-talaria
After:
  - '#talaria-logging'
  - '#talaria-logging-browser'
---
Talaria\SilverStripe\Config:
  minLevel: warning
  service: 'my-site'
  tags:
    team: 'platform'
  enableBrowserCms: true
  enableBrowserFrontend: true
  browserSdkVersion: '0.1.21'
  browserReplaysSessionSampleRate: 0
  browserReplaysOnErrorSampleRate: 1.0
  enableTracing: true
  tracesSampleRate: 0.1

Approach A — Monolog / LoggerInterface

Recommended default. The module pushes a Talaria handler onto Silverstripe's Injector Psr\Log\LoggerInterface. Type-hint that interface — not TalariaClient — so call sites stay vendor-agnostic. Pass throwables under exception for a proper stack.

php
use Psr\Log\LoggerInterface;

final class CheckoutService
{
    public function __construct(
        private readonly LoggerInterface $logger,
    ) {
    }

    public function pay(string $orderId): void
    {
        $this->logger->warning('Payment method missing', [
            'tags' => ['feature' => 'checkout', 'operation' => 'pay'],
            'order_id' => $orderId,
        ]);

        try {
            $this->charge($orderId);
        } catch (Throwable $e) {
            // exception key → captureException with a real stack
            $this->logger->error('Checkout failed', [
                'exception' => $e,
                'tags' => ['feature' => 'checkout', 'component' => 'stripe'],
                'order_id' => $orderId,
            ]);
            throw $e;
        }
    }
}

Approach B — Talaria Logger

Use when you want scoped tags, child / withMinLevel, isLevelEnabled, and captureException — the same model as the browser SDK. Wrap the Injector TalariaClient; do not call Talaria::init() again.

php
use SilverStripe\Core\Injector\Injector;
use Talaria\Logger;
use Talaria\TalariaClient;

// Wrap the shared Injector client — do not call Talaria::init() again.
$logger = new Logger(Injector::inst()->get(TalariaClient::class), [
    'tags' => ['feature' => 'checkout', 'operation' => 'pay'],
]);

$logger->warn('Payment method missing');

$payments = $logger->child([
    'tags' => ['component' => 'payments'],
    'minLevel' => 'error', // can only raise the YAML/global floor
]);

try {
    charge();
} catch (Throwable $e) {
    $payments->captureException($e, [
        'extra' => ['cart_id' => 'abc123'],
    ]);
    throw $e;
}

Hybrid works well in practice: keep Monolog for CMS/module logs, and use Talaria Logger in your checkout, billing, and other product services.

Performance tracing

Tracing is off until YAML enableTracing is true or tracesSampleRate is greater than 0. Head-based sampling: 100% of error transactions; default 10% of successful requests. The module instruments incoming HTTP, database queries, and outbound HTTP. Inspect waterfalls and RED in Performance. Child spans are not billed — only sampled root transactions. Same options as the PHP SDK.

Already running an OpenTelemetry Collector? That is an advanced path — export OTLP/HTTP JSON to POST /otlp/v1/traces. Prefer the native SDK unless you already operate a Collector. See the API overview.

Browser JS (CMS + frontend)

With the same env vars, the module can load @newtalaria/browser from jsDelivr on CMS admin (LeftAndMain) and public pages (ContentController). Pin with browserSdkVersion (default 0.1.21). Session replay sampling defaults to off for continuous sessions.

After config changes, run vendor/bin/sake dev/build flush=1 again. If public pages do not use ContentController, apply Talaria\SilverStripe\FrontendExtension on your page controller.

Example harness

Prefer a runnable Silverstripe site over snippets? Clone the talaria-silverstripe-harness — a blank Silverstripe 5 app wired for newtalaria/logging and @newtalaria/browser. It includes product demos (Bookstore with Talaria\Logger, checkout with direct TalariaClient), button harnesses for Monolog / client / CDN inject, and a Vite blog that uses the npm browser SDK. Point TALARIA_DSN / TALARIA_API_KEY at your project and explore events in the dashboard.

Setup uses DDEV; see the harness README for env vars, seed tasks, and the demo catalogue.

Troubleshooting

  • 401/403 — check API key and that it belongs to the target project.
  • No issue appears — confirm environment filter in the dashboard.
  • Rejected events — validate JSON shape against the API overview.
  • info missing — YAML minLevel defaults to warning.
  • Double-init warning — do not call Talaria::init() when using the Injector client.

Need the lower-level client API? See the PHP SDK or send events over HTTP via the API overview.