GithubHelp home page GithubHelp logo

leocavalcante / newrelic-telemetry-sdk-php Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 0.0 134 KB

Unofficial PHP library for sending telemetry data to New Relic.

Home Page: https://docs.newrelic.com/docs/telemetry-data-platform/ingest-manage-data/ingest-apis

License: Apache License 2.0

PHP 100.00%
newrelic telemetry sdk monitoring observability metrics tracing events

newrelic-telemetry-sdk-php's Introduction

New Relic Telemetry SDK for PHP CI

Unofficial PHP library for sending telemetry data to New Relic.

Status API Description
Trace API Used to send distributed tracing data to New Relic (New Relic's format).
Metric API Used to send metric data to New Relic.
Event API Is one way to report custom events to New Relic.
- Log API Not planned.
  • ⚠️ Heavily under development, but open-sourced seeking for contributions.
  • It is not an agent wrapper, it calls the New Relic Ingest APIs.

Usage

Example

Sending a Gauge metric.

use NewRelic\Adapter;
use NewRelic\Metric;

$metric_api = new Metric\API(new Adapter\Curl(getenv('NR_API_KEY')));
$metric_api->setCommonAttrs(['service.name' => 'PHP-SDK']);
$metric_api->send(new Metric\Gauge('memory.heap', 2.3));

$response = $metric_api->commit();

if ($response->isOk()) {
    echo sprintf("Request ID: %s\n", $response->getId());
} else {
    echo sprintf("Metric send error: %s\n", $response->getMessage());
}

Companion resources

Tips

Why

Main reasons includes:

  • Too many segfaults with the regular agent.
  • Even for simple use cases the regular agent doesn't play well with Swoole. This small snippet is enough to throw a segfault:
    Co\run(static function () {
      go(static function () {
        (new Co\Http\Client('swoole.co.uk'))->get('/');
      });
    });
  • There are other SDKs for other languages, this is an unofficial PHP version.
  • Could be used to build a New Relic exporter for the upcoming OpenTelemetry PHP library.

newrelic-telemetry-sdk-php's People

Contributors

leocavalcante avatar

Stargazers

Everton Catto Heckler avatar Dario Rigolin avatar Kennedy Tedesco avatar Hicaro Alfonso Rios avatar Victor Gazotti avatar  avatar Fabrício Pinto Ferreira avatar

Watchers

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