PHPackages                             a1comms/opencensus - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. a1comms/opencensus

AbandonedLibrary[Logging &amp; Monitoring](/categories/logging)

a1comms/opencensus
==================

OpenCensus Trace Client for PHP

v8.0.1(3y ago)07.8k2Apache-2.0PHPPHP &gt;=7.4

Since May 14Pushed 2y agoCompare

[ Source](https://github.com/a1comms/opencensus-php)[ Packagist](https://packagist.org/packages/a1comms/opencensus)[ RSS](/packages/a1comms-opencensus/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (10)Used By (2)

OpenCensus for PHP - A stats collection and distributed tracing framework
=========================================================================

[](#opencensus-for-php---a-stats-collection-and-distributed-tracing-framework)

> [Census](https://github.com/census-instrumentation) for PHP. Census provides a framework to measure a server's resource usage and collect performance stats. This repository contains PHP related utilities and supporting software needed by Census.

[![CircleCI](https://camo.githubusercontent.com/35bb2f61826429ff7e88e20492e3bf93446210323c01acc46d7f5f2e2ed26970/68747470733a2f2f636972636c6563692e636f6d2f67682f63656e7375732d696e737472756d656e746174696f6e2f6f70656e63656e7375732d7068702e7376673f7374796c653d737667)](https://circleci.com/gh/census-instrumentation/opencensus-php)[![Packagist](https://camo.githubusercontent.com/59c777e12c394bcb451e66ed0d59dc6573bd6418502b56934e22271bcfd049f2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f70656e63656e7375732f6f70656e63656e7375732e737667)](https://packagist.org/packages/opencensus/opencensus)[![PHP-Version](https://camo.githubusercontent.com/e8d5ec76f43d2d428012cea5eba73d42968b57051288b1122fb9e0945af4a1f5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6f70656e63656e7375732f6f70656e63656e7375732e737667)](https://camo.githubusercontent.com/e8d5ec76f43d2d428012cea5eba73d42968b57051288b1122fb9e0945af4a1f5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6f70656e63656e7375732f6f70656e63656e7375732e737667)

- [API Documentation](https://opencensus.io/api/php/api/master/)
- [Integration Documentation](https://opencensus.io/api/php)

Installation &amp; basic usage
------------------------------

[](#installation--basic-usage)

1. Install the `opencensus/opencensus` package using [composer](https://getcomposer.org/):

    ```
    $ composer require opencensus/opencensus:~0.2
    ```

    **IMPORTANT: Please ensure your version is &gt;= 0.2.0**. There is a potential security vulnerability in &lt; 0.2.0.
2. \[Optional\]: Install the `opencensus` extension from [PECL](https://pecl.php.net/):

    ```
    $ pecl install opencensus-alpha
    ```

    Enable the extension in your `php.ini`:

    ```
    extension=opencensus.so
    ```
3. Initialize a tracer for your application:

    ```
    use OpenCensus\Trace\Tracer;
    use OpenCensus\Trace\Exporter\EchoExporter;

    Tracer::start(new EchoExporter());
    ```

Usage
-----

[](#usage)

To add tracing to a block of code, you can use the closure/callable form or explicitly open and close spans yourself.

### Closure/Callable (preferred)

[](#closurecallable-preferred)

```
$pi = Tracer::inSpan(['name' => 'expensive-operation'], function() {
    // some expensive operation
    return calculatePi(1000);
});

$pi = Tracer::inSpan(['name' => 'expensive-operation'], 'calculatePi', [1000]);
```

### Explicit Span Management

[](#explicit-span-management)

```
// Creates a detached span
$span = Tracer::startSpan(['name' => 'expensive-operation']);

// Opens a scope that attaches the span to the current context
$scope = Tracer::withSpan($span);
try {
    $pi = calculatePi(1000);
} finally {
    // Closes the scope (ends the span)
    $scope->close();
}
```

Customization
-------------

[](#customization)

### Samplers

[](#samplers)

You can specify different samplers when initializing a tracer. The default sampler is the `AlwaysSampleSampler` which will attempt to trace all requests.

The provided samplers are:

ClassDescription[NeverSampleSampler](https://opencensus.io/api/php/api/master/OpenCensus/Trace/Sampler/NeverSampleSampler.html)Never trace any requests[AlwaysSampleSampler](https://opencensus.io/api/php/api/master/OpenCensus/Trace/Sampler/NeverSampleSampler.html)Trace all requests[MultiSampler](https://opencensus.io/api/php/api/master/OpenCensus/Trace/Sampler/MultiSampler.html)Check multiple samplers[QpsSampler](https://opencensus.io/api/php/api/master/OpenCensus/Trace/Sampler/NeverSampleSampler.html)Trace X requests per second. Requires a PSR-6 cache implementation[ProbabilitySampler](https://opencensus.io/api/php/api/master/OpenCensus/Trace/Sampler/NeverSampleSampler.html)Trace X percent of requests.If you would like to provide your own sampler, create a class that implements `SamplerInterface`.

### Exporters

[](#exporters)

You can choose different exporters to send the collected traces to.

The provided exporters are:

ClassDescriptionDependency[EchoExporter](https://opencensus.io/api/php/api/master/OpenCensus/Trace/Exporter/EchoExporter.html)Output the collected spans to stdout[FileExporter](https://opencensus.io/api/php/api/master/OpenCensus/Trace/Exporter/FileExporter.html)Output JSON encoded spans to a file[JaegerExporter](https://github.com/census-ecosystem/opencensus-php-exporter-jaeger)Report traces to Jaeger server via Thrift over UDP[opencensus/opencensus-exporter-jaeger](https://packagist.org/packages/opencensus/opencensus-exporter-jaeger)[LoggerExporter](https://opencensus.io/api/php/api/master/OpenCensus/Trace/Exporter/LoggerExporter.html)Exporter JSON encoded spans to a PSR-3 logger[NullExporter](https://opencensus.io/api/php/api/master/OpenCensus/Trace/Exporter/NullExporter.html)No-op[OneLineEchoExporter](https://opencensus.io/api/php/api/master/OpenCensus/Trace/Exporter/OneLineEchoExporter.html)Output the collected spans to stdout with one-line[StackdriverExporter](https://github.com/census-ecosystem/opencensus-php-exporter-stackdriver)Report traces to Google Cloud Stackdriver Trace[opencensus/opencensus-exporter-stackdriver](https://packagist.org/packages/opencensus/opencensus-exporter-stackdriver)[ZipkinExporter](https://github.com/census-ecosystem/opencensus-php-exporter-zipkin)Report collected spans to a Zipkin server[opencensus/opencensus-exporter-zipkin](https://packagist.org/packages/opencensus/opencensus-exporter-zipkin)If you would like to provide your own reporter, create a class that implements `ExporterInterface`.

Versioning
----------

[](#versioning)

[![Packagist](https://camo.githubusercontent.com/59c777e12c394bcb451e66ed0d59dc6573bd6418502b56934e22271bcfd049f2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f70656e63656e7375732f6f70656e63656e7375732e737667)](https://packagist.org/packages/opencensus/opencensus)

This library follows [Semantic Versioning](http://semver.org/).

Please note it is currently under active development. Any release versioned 0.x.y is subject to backwards incompatible changes at any time.

**GA**: Libraries defined at a GA quality level are stable, and will not introduce backwards-incompatible changes in any minor or patch releases. We will address issues and requests with the highest priority.

**Beta**: Libraries defined at a Beta quality level are expected to be mostly stable and we're working towards their release candidate. We will address issues and requests with a higher priority.

**Alpha**: Libraries defined at an Alpha quality level are still a work-in-progress and are more likely to get backwards-incompatible updates.

**Current Status:** Alpha

Contributing
------------

[](#contributing)

Contributions to this library are always welcome and highly encouraged.

See [CONTRIBUTING](CONTRIBUTING.md) for more information on how to get started.

Releasing
---------

[](#releasing)

See [RELEASING](RELEASING.md) for more information on releasing new versions.

License
-------

[](#license)

Apache 2.0 - See [LICENSE](LICENSE) for more information.

Disclaimer
----------

[](#disclaimer)

This is not an official Google product.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 79.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~187 days

Total

3

Last Release

808d ago

Major Versions

v0.8.3 → v8.0.12023-02-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/b7f82764dbcd478679a400621c6a94ca45c6a4bad04bd6aae24fe4a68eabb68c?d=identicon)[iamacarpet](/maintainers/iamacarpet)

---

Top Contributors

[![chingor13](https://avatars.githubusercontent.com/u/32483?v=4)](https://github.com/chingor13 "chingor13 (116 commits)")[![iamacarpet](https://avatars.githubusercontent.com/u/1333857?v=4)](https://github.com/iamacarpet "iamacarpet (8 commits)")[![bpot](https://avatars.githubusercontent.com/u/8415?v=4)](https://github.com/bpot "bpot (4 commits)")[![MrMage](https://avatars.githubusercontent.com/u/117466?v=4)](https://github.com/MrMage "MrMage (3 commits)")[![jcchavezs](https://avatars.githubusercontent.com/u/3075074?v=4)](https://github.com/jcchavezs "jcchavezs (3 commits)")[![Stantheman](https://avatars.githubusercontent.com/u/394611?v=4)](https://github.com/Stantheman "Stantheman (2 commits)")[![basvanbeek](https://avatars.githubusercontent.com/u/7205296?v=4)](https://github.com/basvanbeek "basvanbeek (2 commits)")[![hectorj](https://avatars.githubusercontent.com/u/2427959?v=4)](https://github.com/hectorj "hectorj (2 commits)")[![ericnorris](https://avatars.githubusercontent.com/u/1906605?v=4)](https://github.com/ericnorris "ericnorris (1 commits)")[![bshaffer](https://avatars.githubusercontent.com/u/103941?v=4)](https://github.com/bshaffer "bshaffer (1 commits)")[![castaneai](https://avatars.githubusercontent.com/u/562795?v=4)](https://github.com/castaneai "castaneai (1 commits)")[![draffensperger](https://avatars.githubusercontent.com/u/2855507?v=4)](https://github.com/draffensperger "draffensperger (1 commits)")[![albertojgomez](https://avatars.githubusercontent.com/u/6017906?v=4)](https://github.com/albertojgomez "albertojgomez (1 commits)")[![klibbbs](https://avatars.githubusercontent.com/u/3475490?v=4)](https://github.com/klibbbs "klibbbs (1 commits)")

### Embed Badge

![Health badge](/badges/a1comms-opencensus/health.svg)

```
[![Health](https://phpackages.com/badges/a1comms-opencensus/health.svg)](https://phpackages.com/packages/a1comms-opencensus)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2322.9M248](/packages/open-telemetry-sdk)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)[neos/flow-development-collection

Flow packages in a joined repository for pull requests.

144179.3k3](/packages/neos-flow-development-collection)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
