Coder Social home page Coder Social logo

ajunlonglive / scout-apm-php-ext Goto Github PK

View Code? Open in Web Editor NEW

This project forked from scoutapp/scout-apm-php-ext

0.0 1.0 0.0 466 KB

Native Extension Component for ScoutAPM's PHP Agent

License: MIT License

Shell 1.44% JavaScript 0.87% C 60.32% PHP 30.49% CMake 0.94% Batchfile 0.22% M4 5.43% Dockerfile 0.28%

scout-apm-php-ext's Introduction

Scout APM PHP Extension

CI Build

The Scout APM PHP extension allows instrumentation of internal PHP functions that can't be done in regular PHP. The scout-apm-php package detects if the scoutapm extension is loaded and will automatically send this data if available.

This extension allows instrumentation of:

  • Core functions: file_get_contents, file_put_contents, fread, fwrite
  • Curl functions: curl_exec
  • PDO methods: PDO->exec, PDO->query, PDOStatement->execute
  • Predis PHP library methods
  • phpredis PHP extension methods
  • Memcached PHP extension methods
  • Elasticsearch PHP library methods

If you would like another function instrumented, please let us know on our issues.

The following functions are exposed when the extension is enabled:

  • scoutapm_enable_instrumentation(bool $enabled): void
    • Enable or disable instrumentation by ScoutAPM at runtime. Instrumentation is disabled by default, so this must be called with $enabled to true.
  • scoutapm_get_calls(): array
    • Returns a list of any instrumented function calls since scoutapm_get_calls() was last called. The list is cleared each time the function is called.
  • scoutapm_list_instrumented_functions(): array
    • Returns a list of the functions the extension will instrument if called.

Installing from PECL

The Scout APM extension is available to install using PECL.

$ sudo pecl install scoutapm

You may need to add zend_extension=scoutapm.so into your php.ini to enable the extension.

Building

$ phpize
$ ./configure --enable-scoutapm
$ make test

Run tests with installed PHP (avoids skipped tests):

make && php run-tests.php -d zend_extension=$(pwd)/modules/scoutapm.so --show-diff -q

Note: whilst a CMakeLists.txt exists, this project does NOT use CMake. The CMakeLists.txt exists so this project can be worked on in CLion. See https://dev.to/jasny/developing-a-php-extension-in-clion-3oo1.

Building with specific PHP build

$ /path/to/bin/phpize
$ ./configure --with-php-config=/path/to/bin/php-config --enable-scoutapm
$ make test

Building with Docker

@todo: make docker build configurable...

docker build .
docker run -v $PWD/modules:/v <hash_from_build>

Debugging

Use gdb (e.g. in CLion) to debug. Once running, php-src has a GDB helper:

source /path/to/php-src/.gdbinit
printzv <thing>
print_ht <thing>
zbacktrace
print_cvs

Windows builds

Release Procedure

  • Open package.xml
  • Copy the current release into a new changelog.release element
  • Update the current release section (date/time/version/stability/notes)
  • pecl package-validate to check everything looks good
  • Increase/verify PHP_SCOUTAPM_VERSION version listed in zend_scoutapm.h
  • Commit update to package.xml
  • Rebuild from scratch (full-clean.sh, then build as above)
  • make test to ensure everything passes locally
  • Push the branch (optionally, make a PR to GitHub) to trigger CI to build
  • Once merged, close the milestone to automatically release & generate the TGZ asset
  • Go to the latest release just created
  • Download the TGZ asset and upload it to pecl.php.net

scout-apm-php-ext's People

Contributors

asgrim avatar remicollet avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.