public function send($path, $value, $timestamp = null)
    {
        $result    = false;
        $exception = null;

        set_error_handler(function ($code, $message, $file = null, $line = 0) {
            throw new ErrorException($message, $code, null, $file, $line);
        });

        try {
            if (!is_string($path) || empty($path)) {
                throw new InvalidArgumentException('$path must be a non-empty string');
            }

            if (!is_numeric($value)) {
                throw new InvalidArgumentException(
                    sprintf('$value must be of type int|float, %s given.', gettype($value))
                );
            }

            $value     = (float) $value;
            $timestamp = is_numeric($timestamp) ? (int) $timestamp : time();
            $full_path = $this->sanitizePath(
                sprintf('%s.%s', $this->getNamespace(), $path)
            );

            $data   = sprintf("%s %f %d\n", $full_path, $value, $timestamp);
            $sent   = fwrite($this->stream, $data);
            $result = is_int($sent) && $sent === strlen($data);
        } catch (Exception $e) {
            $exception = $e;
        }
        restore_error_handler();

        if (!empty($exception) && $this->throw_exceptions) {
            throw $exception;
        }

        return $result;
    }
public function send($path, $value, $timestamp = null)
    {
        $result    = false;
        $exception = null;

        set_error_handler(function ($code, $message, $file = null, $line = 0) {
            throw new ErrorException($message, $code, null, $file, $line);
        });

        try {
            if (!is_string($path) || empty($path)) {
                throw new InvalidArgumentException('$path must be a non-empty string');
            }

            if (!is_numeric($value)) {
                throw new InvalidArgumentException(
                    sprintf('$value must be of type int|float, %s given.', gettype($value))
                );
            }

            $value     = (float) $value;
            $timestamp = is_numeric($timestamp) ? (int) $timestamp : time();
            $full_path = $this->sanitizePath(
                sprintf('%s.%s', $this->getNamespace(), $path)
            );

            $data   = sprintf("%s %f %d\n", $full_path, $value, $timestamp);
            $sent   = fwrite($this->stream, $data);
            $result = is_int($sent) && $sent === strlen($data);
        } catch (Exception $e) {
            $exception = $e;
        }
        restore_error_handler();

        if (!empty($exception) && $this->throw_exceptions) {
            throw $exception;
        }

        return $result;
    }
public function send ( $ path , $ value , $ timestamp = null ) { $ result = false ; $ exception = null ; set_error_handler ( function ( $ code , $ message , $ file = null , $ line = 0 ) { throw new ErrorException ( $ message , $ code , null , $ file , $ line ) ; } ) ; try { if ( ! is_string ( $ path ) || empty ( $ path ) ) { throw new InvalidArgumentException ( '$path must be a non-empty string' ) ; } if ( ! is_numeric ( $ value ) ) { throw new InvalidArgumentException ( sprintf ( '$value must be of type int|float, %s given.' , gettype ( $ value ) ) ) ; } $ value = ( float ) $ value ; $ timestamp = is_numeric ( $ timestamp ) ? ( int ) $ timestamp : time ( ) ; $ full_path = $ this -> sanitizePath ( sprintf ( '%s.%s' , $ this -> getNamespace ( ) , $ path ) ) ; $ data = sprintf ( "%s %f %d\n" , $ full_path , $ value , $ timestamp ) ; $ sent = fwrite ( $ this -> stream , $ data ) ; $ result = is_int ( $ sent ) && $ sent === strlen ( $ data ) ; } catch ( Exception $ e ) { $ exception = $ e ; } restore_error_handler ( ) ; if ( ! empty ( $ exception ) && $ this -> throw_exceptions ) { throw $ exception ; } return $ result ; }
Sends a metric to Carbon.

@see http://graphite.readthedocs.org/en/latest/feeding-carbon.html

@param string    $path      Metric Path
@param int|float $value     Metric Value
@param int|null  $timestamp Metric Timestamp

@throws ErrorException If $this->throw_exceptions is true
@return bool
Sends a metric to Carbon .