vanta/temporal-sentry

集成 Temporal 与 Sentry

0.1.1 2024-02-21 05:41 UTC

This package is auto-updated.

Last update: 2024-09-21 07:01:47 UTC


README

Temporal 是一种简单、可扩展的开源方式,用于编写和运行可靠的云应用。

简介

Sentry SDK for temporalio/sdk-php

安装

composer require vanta/temporal-sentry

使用

<?php

declare(strict_types=1);

use Sentry\SentrySdk;
use Temporal\Interceptor\SimplePipelineProvider;
use Temporal\WorkerFactory;
use Vanta\Integration\Temporal\Sentry\SentryActivityInboundInterceptor;
use Vanta\Integration\Temporal\Sentry\SentryWorkflowOutboundCallsInterceptor;
use function Sentry\init;

require_once __DIR__ . '/vendor/autoload.php';

init(['dsn' => 'https://1a36864711324ed8a04ba0fa2c89ac5a@sentry.temporal.local/52']);

$hub     = SentrySdk::getCurrentHub();
$client  = $hub->getClient() ?? throw new \RuntimeException('Not Found client');
$factory = WorkerFactory::create();

$worker = $factory->newWorker(
    interceptorProvider: new SimplePipelineProvider([
        new SentryActivityInboundInterceptor($hub, $client->getStacktraceBuilder()),
        new SentryWorkflowOutboundCallsInterceptor($hub, $client->getStacktraceBuilder()),
    ])
);