<commit_before><?php
namespace LightStepBase\Client;

use LightStepBase\Span;

require_once(dirname(__FILE__) . "/../api.php");
require_once(dirname(__FILE__) . "/ClientSpan.php");
require_once(dirname(__FILE__) . "/NoOpSpan.php");
require_once(dirname(__FILE__) . "/Util.php");
require_once(dirname(__FILE__) . "/Transports/TransportUDP.php");
require_once(dirname(__FILE__) . "/Transports/TransportHTTPJSON.php");
require_once(dirname(__FILE__) . "/Transports/TransportHTTPPROTO.php");
require_once(dirname(__FILE__) . "/Version.php");
require_once(dirname(__FILE__) . "/Auth.php");
require_once(dirname(__FILE__) . "/Runtime.php");
require_once(dirname(__FILE__) . "/KeyValue.php");
require_once(dirname(__FILE__) . "/ReportRequest.php");
require_once(dirname(__FILE__) . "/LogRecord.php");

define('CARRIER_TRACER_STATE_PREFIX', 'ot-tracer-');
define('CARRIER_BAGGAGE_PREFIX', 'ot-baggage-');

/**
 * Main implementation of the Tracer interface
 */
class ClientTracer implements \LightStepBase\Tracer {

    protected $_util = NULL;
    protected $_options = [];
    protected $_enabled = true;
    protected $_debug = false;

    protected $_guid = "";
    protected $_startTime = 0;
    protected $_auth = NULL;
    protected $_runtime = NULL;
    protected $_transport = NULL;

    protected $_reportStartTime = 0;
    protected $_spanRecords = [];
    protected $_counters = [
        'dropped_counters' => 0,
    ];

    protected $_lastFlushMicros = 0;
    protected $_minFlushPeriodMicros = 0;
    protected $_maxFlushPeriodMicros = 0;

    public function __construct($options = []) {
        $this->_util = new Util();

        $defaults = [
            'collector_host'            => 'collector.lightstep.com',
            'collector_port'            => 80,
            'collector_secure'          => false,

            'transport'                 => 'http_json',
            'max_log_records'           => 1000,
            'max_span_records'          => 1000,
            'min_reporting_period_secs' => 0.1,
            'max_reporting_period_secs' => 5.0,

            // PHP-specific configuration
            //
            // TODO: right now any payload with depth greater than this is simply
            // rejected; it is not trimmed.
            'max_payload_depth'     => 10,

            // Internal debugging flag that enables additional logging and
            // tracer checks. Not intended to run in production as it may add
            // logging "noise" to the calling code.
            'verbose'               => 0,

            // Flag intended solely to unit testing convenience
            'debug_disable_flush'   => false,
        ];

        // Modify some of the interdependent defaults based on what the user-specified
        if (isset($options['collector_secure'])) {
            $defaults['collector_port'] = $options['collector_secure'] ? 443 : 80;
        }

        // UDP has significantly lower size contraints
        if (isset($options['transport']) && $options['transport'] == 'udp') {
            $defaults['max_log_records'] = 16;
            $defaults['max_span_records'] = 16;
        }

        // Set the options, merged with the defaults
        $this->options(array_merge($defaults, $options));

        if ($this->_options['transport'] == 'udp') {
            $this->_transport = new Transports\TransportUDP();
        } if ($this->_options['transport'] == 'http_proto') {
            $this->_transport = new Transports\TransportHTTPPROTO();
        } else {
            $this->_transport = new Transports\TransportHTTPJSON();
        }

        // Note: the GUID is not generated until the library is initialized
        // as it depends on the access token
        $this->_startTime = $this->_util->nowMicros();
        $this->_reportStartTime = $this->_startTime;
        $this->_lastFlushMicros = $this->_startTime;<commit_msg>fixed missing else prefix on else if branch<commit_after><?php
namespace LightStepBase\Client;

use LightStepBase\Span;

require_once(dirname(__FILE__) . "/../api.php");
require_once(dirname(__FILE__) . "/ClientSpan.php");
require_once(dirname(__FILE__) . "/NoOpSpan.php");
require_once(dirname(__FILE__) . "/Util.php");
require_once(dirname(__FILE__) . "/Transports/TransportUDP.php");
require_once(dirname(__FILE__) . "/Transports/TransportHTTPJSON.php");
require_once(dirname(__FILE__) . "/Transports/TransportHTTPPROTO.php");
require_once(dirname(__FILE__) . "/Version.php");
require_once(dirname(__FILE__) . "/Auth.php");
require_once(dirname(__FILE__) . "/Runtime.php");
require_once(dirname(__FILE__) . "/KeyValue.php");
require_once(dirname(__FILE__) . "/ReportRequest.php");
require_once(dirname(__FILE__) . "/LogRecord.php");

define('CARRIER_TRACER_STATE_PREFIX', 'ot-tracer-');
define('CARRIER_BAGGAGE_PREFIX', 'ot-baggage-');

/**
 * Main implementation of the Tracer interface
 */
class ClientTracer implements \LightStepBase\Tracer {

    protected $_util = NULL;
    protected $_options = [];
    protected $_enabled = true;
    protected $_debug = false;

    protected $_guid = "";
    protected $_startTime = 0;
    protected $_auth = NULL;
    protected $_runtime = NULL;
    protected $_transport = NULL;

    protected $_reportStartTime = 0;
    protected $_spanRecords = [];
    protected $_counters = [
        'dropped_counters' => 0,
    ];

    protected $_lastFlushMicros = 0;
    protected $_minFlushPeriodMicros = 0;
    protected $_maxFlushPeriodMicros = 0;

    public function __construct($options = []) {
        $this->_util = new Util();

        $defaults = [
            'collector_host'            => 'collector.lightstep.com',
            'collector_port'            => 80,
            'collector_secure'          => false,

            'transport'                 => 'http_json',
            'max_log_records'           => 1000,
            'max_span_records'          => 1000,
            'min_reporting_period_secs' => 0.1,
            'max_reporting_period_secs' => 5.0,

            // PHP-specific configuration
            //
            // TODO: right now any payload with depth greater than this is simply
            // rejected; it is not trimmed.
            'max_payload_depth'     => 10,

            // Internal debugging flag that enables additional logging and
            // tracer checks. Not intended to run in production as it may add
            // logging "noise" to the calling code.
            'verbose'               => 0,

            // Flag intended solely to unit testing convenience
            'debug_disable_flush'   => false,
        ];

        // Modify some of the interdependent defaults based on what the user-specified
        if (isset($options['collector_secure'])) {
            $defaults['collector_port'] = $options['collector_secure'] ? 443 : 80;
        }

        // UDP has significantly lower size contraints
        if (isset($options['transport']) && $options['transport'] == 'udp') {
            $defaults['max_log_records'] = 16;
            $defaults['max_span_records'] = 16;
        }

        // Set the options, merged with the defaults
        $this->options(array_merge($defaults, $options));

        if ($this->_options['transport'] == 'udp') {
            $this->_transport = new Transports\TransportUDP();
        } else if ($this->_options['transport'] == 'http_proto') {
            $this->_transport = new Transports\TransportHTTPPROTO();
        } else {
            $this->_transport = new Transports\TransportHTTPJSON();
        }

        // Note: the GUID is not generated until the library is initialized
        // as it depends on the access token
        $this->_startTime = $this->_util->nowMicros();
        $this->_reportStartTime = $this->_startTime;
        $this->_lastFlushMicros = $this->_startTime;
{'fraction_non_alphanumeric': 0.12975047984644913, 'fraction_numerical': 0.00818937939859245, 'mean_word_length': 2.5640674874601004, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5600799', 'n_tokens_mistral': 2207, 'n_tokens_neox': 2101, 'n_words': 505}