logo

Vedatrace

Php sdk

Configuration

Configure the VedaTrace PHP SDK with options and environment variables.

Configure VedaTrace to suit your application's environment. You can pass options directly or use environment variables.

Configuration Options

OptionEnvironment VariableDefaultDescription
apiKeyVEDATRACE_API_KEY''Your VedaTrace API key.
serviceVEDATRACE_SERVICE'default-php-service'Name of your service as it appears in VedaTrace.
environmentVEDATRACE_ENVIRONMENT'production'The environment (local, staging, etc.).
endpointVEDATRACE_ENDPOINThttps://ingest.vedatrace.dev/v1/logsThe VedaTrace ingestion endpoint.
batchSizeVEDATRACE_BATCH_SIZE100Maximum number of logs per batch.
flushIntervalVEDATRACE_FLUSH_INTERVAL5000Time between batches (milliseconds).
maxRetriesVEDATRACE_MAX_RETRIES3Number of retry attempts for failed requests.
retryDelayVEDATRACE_RETRY_DELAY1000Delay between retries (milliseconds).

Redaction

VedaTrace automatically redacts sensitive data from your logs. You can customize the fields to mask:

$logger = vedatrace([
    'redaction' => [
        'paths' => ['user.token', 'credit_card.number', 'password'],
        'mask' => '[REDACTED]',
    ],
]);

$logger->info('User login', [
    'user' => ['token' => '123456'], // Token will be masked
    'password' => 'secret',          // Password will be masked
]);

By default, the following keys are redacted:

  • password
  • token
  • secret
  • authorization

Batching and Performance

VedaTrace buffers logs in memory and sends them in batches to improve application performance.

  • batchSize: Limits the number of logs sent in a single request.
  • flushInterval: Determines how often logs are flushed if the batch size is not reached.
  • dispose(): In standalone scripts, ensure you call $logger->dispose() to flush any remaining logs before the script exits.

On this page