marotpam/zipkin-instrumentation-stripe-php

PHP Stripe HTTP 客户端的 Zipkin 仪表化

v0.1 2018-11-20 08:34 UTC

This package is not auto-updated.

Last update: 2024-09-19 13:05:41 UTC


README

带有 Zipkin 仪表化的 Stripe PHP 客户端

安装

composer require marotpam/zipkin-instrumentation-stripe-php

用法

您需要覆盖 stripe-php 默认使用的 HttpClient,使用一个包含您应用程序共享的 Zipkin Tracer 的 HttpClient。有关如何在 PHP 应用程序中使用 Zipkin 的更多详细信息,请参阅 Zipkin 官方 PHP 库

use Stripe\ApiRequestor;
use Stripe\HttpClient\CurlClient;
use Stripe\Stripe;
use Zipkin\Tracer;
use ZipkinStripe\HttpClient;

/**
 * @param string $stripeSecretKey Stripe API key
 * @param Tracer $tracer Zipkin tracer used across your application
 */
public function initialiseStripeClient(string $stripeSecretKey, Tracer $tracer)
{
    Stripe::setApiKey($stripeSecretKey);

    $instrumentedStripeClient = new HttpClient(CurlClient::instance(), $tracer);

    ApiRequestor::setHttpClient($instrumentedStripeClient);
}