Coder Social home page Coder Social logo

newrelic's Introduction

New Relic Libraries

Build Status Code Coverage

New Relic Transaction Library

Use this library to report background jobs or long running scripts to New Relic APM.

<?php

namespace EmailConsumer;

class EmailConsumer
{
    public function sendEmail($recipient, $body, $header)
    {
        //Send email
    }
}

namespace A\B;

use EasyTaxi\NewRelic;
use EmailConsumer;

$consumer = new EmailConsumer();

while (true) {
    $transactionConfig = new NewRelic\Config\TransactionConfig();
    $transactionConfig->applicationName = 'Background Jobs';
    $transactionConfig->transactionName = 'consumer::sendEmail';
    $consumerMonitored = new NewRelic\Transaction($consumer, $transactionConfig);
    $consumerMonitored->sendEmail('Spock', 'James', 'Tiberius');
}

You MUST have an agent configured and running on the server

New Relic Insights Library

Use this library to easily post custom events to New Relic Insights.

<?php

use EasyTaxi\NewRelic\Insights;

$client = new Client([
    #You need to change it to your account number
    'base_uri' => 'https://insights-collector.newrelic.com/v1/accounts/99999/'
]);
$this->newRelicInsights = new EasyTaxi\NewRelic\Insights($client, 'YOUR_KEY_HERE');

$events = new Insights\EventCollection();

$event = new Insights\Event();
$event->eventType = "Purchase";
$event->account = 3;
$event->amount = 259.54;
$events->add($event);

$event2 = new Insights\Event();
$event2->eventType = "Purchase";
$event2->account = 4;
$events->add($event2);

$promise = $this->newRelicInsights->sendEvent($events);
$promise->wait();

You can find your key at Insights https://insights.newrelic.com/accounts/99999/manage/add_data

Configuring

  • Your base_uri MUST end with trailing slash /
  • You MUST replace 99999 with your account number

Installing

The recommended way to install is through Composer.

# Install Composer
curl -sS https://getcomposer.org/installer | php

Next, run the Composer command to install the latest stable version:

composer.phar require easytaxibr/newrelic

newrelic's People

Contributors

filhodanuvem avatar nathanielks avatar

Watchers

 avatar James Cloos 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.