Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

A stats collection and distributed tracing framework

License

NotificationsYou must be signed in to change notification settings

census-instrumentation/opencensus-php

Warning

OpenCensus and OpenTracing have merged to formOpenTelemetry, which serves as the next major version of OpenCensus and OpenTracing.

OpenTelemetry has now reached feature parity with OpenCensus, with tracing and metrics SDKs available in .NET, Golang, Java, NodeJS, and Python.All OpenCensus Github repositories, exceptcensus-instrumentation/opencensus-python, will be archived on July 31st, 2023. We encourage users to migrate to OpenTelemetry by this date.

To help you gradually migrate your instrumentation to OpenTelemetry, bridges are available in Java, Go, Python, and JS.Read the full blog post to learn more.

OpenCensus for PHP - A stats collection and distributed tracing framework

Census for PHP. Census provides a framework to measure aserver's resource usage and collect performance stats. This repository containsPHP related utilities and supporting software needed by Census.

CircleCIPackagistPHP-Version

Installation & basic usage

  1. Install theopencensus/opencensus package usingcomposer:

    $ composer require opencensus/opencensus:~0.2

    IMPORTANT: Please ensure your version is >= 0.2.0. There is a potential securityvulnerability in < 0.2.0.

  2. [Optional]: Install theopencensus extension fromPECL:

    $ pecl install opencensus-alpha

    Enable the extension in yourphp.ini:

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

    useOpenCensus\Trace\Tracer;useOpenCensus\Trace\Exporter\EchoExporter;Tracer::start(newEchoExporter());

Usage

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

Closure/Callable (preferred)

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

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

Samplers

You can specify different samplers when initializing a tracer. The defaultsampler is theAlwaysSampleSampler which will attempt to trace all requests.

The provided samplers are:

ClassDescription
NeverSampleSamplerNever trace any requests
AlwaysSampleSamplerTrace all requests
MultiSamplerCheck multiple samplers
QpsSamplerTrace X requests per second. Requires a PSR-6 cache implementation
ProbabilitySamplerTrace X percent of requests.

If you would like to provide your own sampler, create a class that implementsSamplerInterface.

Exporters

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

The provided exporters are:

ClassDescriptionDependency
EchoExporterOutput the collected spans to stdout
FileExporterOutput JSON encoded spans to a file
JaegerExporterReport traces to Jaeger server via Thrift over UDPopencensus/opencensus-exporter-jaeger
LoggerExporterExporter JSON encoded spans to a PSR-3 logger
NullExporterNo-op
OneLineEchoExporterOutput the collected spans to stdout with one-line
StackdriverExporterReport traces to Google Cloud Stackdriver Traceopencensus/opencensus-exporter-stackdriver
ZipkinExporterReport collected spans to a Zipkin serveropencensus/opencensus-exporter-zipkin

If you would like to provide your own reporter, create a class that implementsExporterInterface.

Versioning

Packagist

This library followsSemantic Versioning.

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

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

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

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

Current Status: Alpha

Contributing

Contributions to this library are always welcome and highly encouraged.

SeeCONTRIBUTING for more information on how to get started.

Releasing

SeeRELEASING for more information on releasing new versions.

License

Apache 2.0 - SeeLICENSE for more information.

Disclaimer

This is not an official Google product.

About

A stats collection and distributed tracing framework

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors16


[8]ページ先頭

©2009-2026 Movatter.jp