# Statsig

### Supported Telemetry Types

| Telemetry Type | Supported |
| -------------- | --------- |
| Traces         |           |
| Metrics        | ✓         |
| Logs           | ✓         |

### Prerequisites

Before configuring the Statsig destination, ensure you have:

* A Statsig account with OTLP receiver configured
* Your Statsig API Key (from Settings > Keys & Environments in your Statsig Console)
* The Statsig OTLP endpoint URL
* Network connectivity from your Bindplane agent to Statsig's OTLP receiver
* At least logs or metrics enabled in your telemetry pipeline

For help with Statsig setup and OTLP configuration, see the [Statsig documentation](https://docs.statsig.com/).

### Configuration

#### Basic Configuration

The minimum configuration requires the endpoint URL and API Key for authentication.

**Parameters:**

| Parameter    | Type   | Default                        | Description                             | Required |
| ------------ | ------ | ------------------------------ | --------------------------------------- | -------- |
| Endpoint URL | String | `https://api.statsig.com/otlp` | OTLP endpoint URL for Statsig ingestion | Yes      |
| API Key      | String | -                              | API Key for authenticating with Statsig | Yes      |

***

### Advanced Configuration

#### Compression

Control how telemetry is compressed before transmission.

| Parameter   | Type     | Default | Description                                                         | Required |
| ----------- | -------- | ------- | ------------------------------------------------------------------- | -------- |
| Compression | Selector | `gzip`  | Compression algorithm to use for telemetry batches (`none`, `gzip`) | Yes      |

#### General Settings

Settings for controlling log processing and timeout behavior.

| Parameter     | Type    | Default | Description                                                         | Required |
| ------------- | ------- | ------- | ------------------------------------------------------------------- | -------- |
| Drop Raw Copy | Boolean | `true`  | Drop the raw copy of the log record stored in `log.record.original` | No       |
| Timeout       | Integer | `30`    | Timeout in seconds for sending batches to Statsig                   | Yes      |

#### Retry and Queuing

This destination supports the [retry settings](https://docs.bindplane.com/configuration/bindplane-otel-collector/retry-on-failure), the [sending queue settings](https://docs.bindplane.com/configuration/bindplane-otel-collector/sending-queue), and the [persistent queue settings.](https://docs.bindplane.com/configuration/bindplane-otel-collector/persistent-queue)

| Sending Queue | Persistent Queue | Retry on Failure |
| ------------- | ---------------- | ---------------- |
| ✓             | ✓                | ✓                |

### Examples

#### Basic Configuration (Logs and Metrics)

This example configures the destination to send logs and metrics to Statsig.

```yaml
apiVersion: bindplane.observiq.com/v1
kind: Destination
metadata:
  id: statsig
  name: Statsig
spec:
  type: statsig
  parameters:
    - name: endpoint_url
      value: 'https://api.statsig.com/otlp'
    - name: api_key
      value: 'your-api-key-here'
```

#### Metrics Only with Compression

This example configures the destination to send only metrics with optimized compression.

```yaml
apiVersion: bindplane.observiq.com/v1
kind: Destination
metadata:
  id: statsig-metrics
  name: Statsig (Metrics)
spec:
  type: statsig
  parameters:
    - name: endpoint_url
      value: 'https://api.statsig.com/otlp'
    - name: api_key
      value: 'your-api-key-here'
    - name: compression
      value: 'gzip'
    - name: drop_raw_copy
      value: true
    - name: timeout
      value: 30
```

#### High-Volume Configuration with Persistent Queuing

This example demonstrates a configuration optimized for high-volume telemetry with data durability.

```yaml
apiVersion: bindplane.observiq.com/v1
kind: Destination
metadata:
  id: statsig-production
  name: Statsig (Production)
spec:
  type: statsig
  parameters:
    - name: endpoint_url
      value: 'https://api.statsig.com/otlp'
    - name: api_key
      value: 'your-api-key-here'
    - name: compression
      value: 'gzip'
    - name: drop_raw_copy
      value: true
    - name: timeout
      value: 30
    - name: retry_on_failure_enabled
      value: true
    - name: retry_on_failure_initial_interval
      value: 5
    - name: retry_on_failure_max_interval
      value: 30
    - name: retry_on_failure_max_elapsed_time
      value: 300
    - name: sending_queue_enabled
      value: true
    - name: sending_queue_num_consumers
      value: 10
    - name: sending_queue_queue_size
      value: 5000
    - name: persistent_queue_enabled
      value: true
    - name: persistent_queue_storage_extension
      value: 
        type: file_storage_persistent_queue
        parameters:
          - name: persistent_queue_directory
            value: ${OIQ_OTEL_COLLECTOR_HOME}/storage
          - name: timeout
            value: 1
          - name: persistent_queue_fsync
            value: true
```

#### Low-Latency Configuration

This example demonstrates a configuration optimized for low-latency telemetry delivery without compression overhead.

```yaml
apiVersion: bindplane.observiq.com/v1
kind: Destination
metadata:
  id: statsig-low-latency
  name: Statsig (Low Latency)
spec:
  type: statsig
  parameters:
    - name: endpoint_url
      value: 'https://api.statsig.com/otlp'
    - name: api_key
      value: 'your-api-key-here'
    - name: compression
      value: 'none'
    - name: timeout
      value: 15
    - name: sending_queue_enabled
      value: true
    - name: sending_queue_queue_size
      value: 2000
    - name: sending_queue_num_consumers
      value: 5
    - name: persistent_queue_enabled
      value: false
```

### Configuration Tips

#### API Key Management

* API keys are found in your Statsig Console under Settings > Keys & Environments
* Keep API keys secure; use environment variables or secret management systems
* Store credentials in a secure location and never commit them to version control
* Rotate API keys periodically according to your security policy
* Use key restrictions and permissions to limit access to only necessary resources

#### Endpoint Configuration

* Default endpoint: `https://api.statsig.com/otlp`
* Use the correct endpoint for your Statsig deployment (cloud, on-premises, or custom)
* Verify endpoint URL is accessible from your Bindplane agent
* Test connectivity before production deployment

#### Compression Selection

* Use **gzip** (default) for most deployments to reduce bandwidth usage
* Use **none** only if you have specific low-latency requirements
* Compression reduces network bandwidth at the cost of CPU usage on the collector
* Monitor network metrics to determine optimal compression settings

#### Feature Flag Correlation

* Correlate metrics and logs with Statsig feature flags using attribute mapping
* Include feature flag state in log records using processors
* Tag metrics with feature flag dimensions for advanced analysis in Statsig

#### Monitoring Telemetry Flow

* View logs and metrics in Statsig Console under Logs Explorer and Metrics Explorer
* Monitor telemetry ingestion rates to track collection health
* Set up alerts for telemetry ingestion failures or anomalies
* Use Statsig's built-in dashboards to visualize observability data

#### Security Best Practices

* Store API keys securely using environment variables or secret management systems
* Regularly rotate API keys per your security policy
* Use Statsig's principle of least privilege for key permissions
* Monitor key usage for suspicious activity
* Never share API keys outside your organization
* Use TLS for all connections to Statsig endpoints

#### Performance Tuning

* Increase Queue Size for high-volume telemetry collection
* Adjust Number of Consumers based on available CPU and network bandwidth
* Enable Persistent Queuing for mission-critical telemetry
* Enable Synchronize Persistent Queue to Disk in critical environments for data durability
* Monitor queue depth to identify capacity issues before they occur

***

### Troubleshooting

#### Connection Refused or Timeout

**Symptoms**: Telemetry is not being sent; connection timeout errors in logs.

**Solutions**:

1. Verify the endpoint URL is correct and accessible
2. Test network connectivity: `curl -I https://api.statsig.com/otlp`
3. Verify firewall rules allow outbound HTTPS traffic to Statsig
4. Check DNS resolution for Statsig endpoint
5. Verify internet connectivity from your Bindplane agent

#### Authentication Failures

**Symptoms**: "401 Unauthorized" or authentication errors in logs.

**Solutions**:

1. Verify the API key is correct and valid
2. Check that the API key hasn't been revoked or expired
3. Ensure the API key has appropriate permissions for OTLP ingestion
4. Verify the API key is correctly configured in the destination parameters
5. Check Statsig Console for API key status and permissions
6. Try regenerating the API key in Statsig Console if issues persist

#### Telemetry Not Appearing

**Symptoms**: Telemetry is sent but doesn't appear in Statsig or queries fail.

**Solutions**:

1. Verify logs and metrics are being generated by your sources
2. Check that telemetry is being routed to the Statsig destination
3. Verify both logs and metrics are configured for ingestion in Statsig
4. Check Statsig Console > Logs Explorer and Metrics Explorer for data arrival
5. Ensure telemetry contains required fields and proper formatting
6. Review Statsig ingestion logs for parsing or validation errors

#### High Queue Depth

**Symptoms**: Sending queue is consistently full; telemetry may be dropped if persistent queuing is disabled.

**Solutions**:

1. Verify Statsig endpoint is accessible and responding
2. Check network latency and bandwidth to Statsig
3. Increase Queue Size to buffer more telemetry
4. Increase Number of Consumers to process batches faster
5. Enable Persistent Queuing to prevent data loss during outages
6. Monitor telemetry volume and consider sampling if consistently over capacity

#### Performance Issues

**Symptoms**: High CPU or memory usage; slow telemetry ingestion; delays in data arrival.

**Solutions**:

1. Monitor Bindplane agent CPU and memory usage
2. Consider reducing telemetry volume at the source (sampling, filtering)
3. Disable compression (set to `none`) if CPU is the bottleneck
4. Verify network connectivity and bandwidth to Statsig
5. Adjust Number of Consumers based on available resources
6. Disable Synchronize Persistent Queue to Disk if enabled (unless data integrity is critical)

#### Data Loss

**Symptoms**: Telemetry is dropped after restarts or network outages.

**Solutions**:

1. Enable Persistent Queuing to survive service restarts
2. Verify persistent queue directory exists and has write permissions
3. Monitor queue size to ensure it's not overflowing
4. Enable Retry on Failure to handle transient failures
5. Check available disk space for persistent queue storage
6. For critical environments, enable Synchronize Persistent Queue to Disk
7. Review Bindplane logs for exporter errors or capacity issues

#### API Key Issues

**Symptoms**: Frequent authentication failures or unpredictable failures.

**Solutions**:

1. Regenerate the API key in Statsig Console
2. Update the destination configuration with the new API key
3. Verify the new API key immediately after creation
4. Check API key rotation policies and schedule regular updates
5. Review Statsig Console audit logs for key usage and changes
6. Ensure no rate limiting issues from API key

***

### Related Resources

* [Statsig Documentation](https://docs.statsig.com/)
* [Statsig OTLP Integration](https://docs.statsig.com/server/concepts/open_telemetry)
* [Statsig Console Settings](https://docs.statsig.com/console-ui/organization-settings)
* [OpenTelemetry Protocol Specification](https://opentelemetry.io/docs/specs/otel/protocol/)
* [Bindplane Destinations Overview](https://docs.bindplane.com/resources/destinations/)
* [Retry and Queuing Configuration](https://docs.bindplane.com/configuration/bindplane-otel-collector/retry-and-queueing)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bindplane.com/integrations/destinations/statsig.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
