Skip to content

feat(export): add offline buffering with retry #14

@CalvinAllen

Description

@CalvinAllen

Summary

Buffer telemetry data locally when the OTLP endpoint is unreachable and retry sending when connectivity is restored. Prevents data loss during network issues or collector outages.

Problem

Currently, if the OTLP endpoint is unavailable:

  • Telemetry data is lost
  • No indication to the extension that export failed
  • No retry mechanism

Proposed Solution

var config = new TelemetryConfiguration
{
    // Enable offline buffering
    EnableOfflineBuffering = true,
    
    // Buffer configuration
    OfflineBufferPath = Path.Combine(
        Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
        "MyExtension", "telemetry-buffer"),
    MaxBufferSizeMb = 50,
    MaxBufferAgeHours = 24,
    
    // Retry configuration  
    RetryInitialDelayMs = 1000,
    RetryMaxDelayMs = 60000,
    RetryMaxAttempts = 10
};

Behavior

  1. Normal operation: Telemetry sent directly to OTLP endpoint
  2. Export failure: Data written to local buffer file
  3. Background retry: Periodically attempt to send buffered data
  4. Exponential backoff: Retry delay increases on consecutive failures
  5. Buffer management: Old data pruned when limits exceeded (FIFO)
  6. Recovery: Buffered data sent (oldest first) when endpoint recovers

Events/Metrics

  • vs.extension.telemetry.buffered (counter) - Items written to buffer
  • vs.extension.telemetry.buffer.size (gauge) - Current buffer size
  • vs.extension.telemetry.retry.success (counter) - Successful retries
  • vs.extension.telemetry.retry.failure (counter) - Failed retries

Implementation Notes

  • Use memory-mapped files or SQLite for buffer storage
  • Implement as custom SpanProcessor/MetricReader
  • Handle VS shutdown gracefully (flush to buffer)
  • Consider compression for buffer files

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions