Code Monkey home page Code Monkey logo

instrumental_agent-php's Introduction

Instrumental PHP Agent

Instrumental is a application monitoring platform built for developers who want a better understanding of their production software. Powerful tools, like the Instrumental Query Language, combined with an exploration-focused interface allow you to get real answers to complex questions, in real-time.

This agent supports custom metric monitoring for PHP applications. It provides high-data reliability at high scale.

Composer Installation

composer require instrumental/instrumental_agent

Visit instrumentalapp.com and create an account, then initialize the agent with your API key, found in the Docs section.

Usage

$I = new \Instrumental\Agent();
$I->setApiKey("PROJECT_API_TOKEN");
$I->setEnabled($isProduction); // only send metrics in production

You'll probably want something like the above, using your project API token, only enabling the agent in production mode so you don't have development and production data writing to the same value. Or you can setup two projects, so that you can verify stats in one, and release them to production in another.

Now you can begin to use Instrumental to track your application.

$I->gauge('load', 1.23);                                # value at a point in time

$I->increment('signups');                               # increasing value, think "events"

$post = $I->time('query_time', function(){              # time a block of code
  return Post->find(1);
});
$post = $I->time_ms('query_time_in_ms', function(){     # prefer milliseconds?
  return Post->find(1);
});

Note: If it is unable to connect to the service, it will discard data after reaching a low memory threshold.

Want to track an event (like an application deploy, or downtime)? You can capture events that are instantaneous, or events that happen over a period of time.

$I->notice('Jeffy deployed rev ef3d6a'); # instantaneous event
$I->notice('Testing socket buffer increase', time() - (3*24*60*60), 20*60); # an event (three days ago) with a duration (20 minutes)

Agent Control

Need to quickly disable the agent? Use $I->setEnabled(FALSE); on initialization and you don't need to change any application code.

Symfony

For usage with Symfony applications, we recommend registering the agent as a Symfony service.

Troubleshooting & Help

We are here to help. Email us at [email protected].

Release Process

  1. Pull latest master
  2. Merge feature branch(es) into master
  3. script/test
  4. Increment version in code
  • lib/Agent.php
  1. Update CHANGELOG.md
  2. Commit "Release version vX.Y.Z"
  3. Push to GitHub
  4. Tag version: git tag 'vX.Y.Z' && git push --tags (GitHub webhook will tell packagist and release a new version)
  5. Verify update on https://packagist.org/packages/instrumental/instrumental_agent
  6. Refresh documentation on instrumentalapp.com

Version Policy

This library follows Semantic Versioning 2.0.0.

instrumental_agent-php's People

Contributors

esquivalient avatar jamespaden avatar jason-o-matic avatar mediocretes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

instrumental_agent-php's Issues

Invalid argument

I got this error when there is no access to the collector.instrumentalapp.com service.

FastCGI sent in stderr: "PHP message: [2018-04-02 10:52:30] instrumental.ERROR: Exception caught: Argument 2 passed to Monolog\Logger::warn() must be of the type array, string given, called in .../php/vendor/instrumental/instrumental_agent/lib/Agent.php on line 440 #0 .../php/vendor/instrumental/instrumental_agent/lib/Agent.php(440): Monolog\Logger->warn('Couldn't resolv...', 'warn') #1 ../php/vendor/instrumental/instrumental_agent/lib/Agent.php(64): Instrumental\Agent->ipv4_address_for_host('collector.instr...', 8000) #2 .../php/vendor/instrumental/instrumental_agent/lib/Agent.php(333): Instrumental\Agent->connect() #3 .../php/vendor/instrumental/instrumental_" while reading response header from upstream,...

instrumental.Error Broken Pipe

I'm using instrumental in a PHP based websocket server with infinite timeout. I realise that this probably isn't instrumental's intended use case but, after a few minutes I'll get the following error when trying to write to a metric:

[2018-10-27 12:34:18] instrumental.ERROR: Exception caught: fwrite(): send of 63 bytes failed with errno=32 Broken pipe #0 [internal fu...

Now, surprisingly, instrumental is able to recover from this and continues to write metrics the next time it's attempted until it falls over again and recovers again - the metrics we're recording through instrumental aren't mission critical and as such this behaviour is acceptable.

Is there any method to catch this exception in my code to prevent it being output to the log file?

Thank you

Unable to run setup

brew install php70 --with-thread-safety --with-phpdbg

Does not seem to find the right package, is there a different keg tap that needs to get brewed into the... I don't know what their terms mean.

Maybe there is a different command that needs to be in the script?

It does advise me to install hombrew/php/php70, should we make that the thing the script does instead? Perhaps our home-brews are different.

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.