- Location:
src/lib/tracing.ts,src/config/tracingConfig.ts - Implementation:
- Uses
@opentelemetry/sdk-nodewith proper configuration - Auto-instrumentation enabled for HTTP and Express
- Initialized in
src/index.tswith graceful shutdown - Supports multiple exporters (Jaeger, Honeycomb, Console)
- Uses
- Location:
src/config/tracingConfig.ts - Implementation:
- Jaeger exporter support with configurable endpoint
- Honeycomb exporter support with API key and dataset
- Console exporter for development
- Environment-based configuration with validation
- Location:
src/lib/tracing.ts(enhanced) - Implementation:
- ✅ ENHANCED: Explicit traceparent header injection in
setupAxiosTracing() - ✅ W3C trace context propagation using OpenTelemetry API
- ✅ Automatic injection for all axios requests
- ✅ Development logging for trace headers
- ✅ ENHANCED: Explicit traceparent header injection in
- API Provider Tracing: ✅ Available via
TracingService.traceApiProviderRequest() - Relayer Tracing: ✅ Available via
TracingService.traceRelayerRequest() - On-Chain Submission: ✅ Enhanced with
StellarProvider.executeWithTracing()
// Key features:
- NodeSDK initialization with resource configuration
- Multiple exporter support (Jaeger, Honeycomb, Console)
- W3C trace context propagation
- Axios interceptors for automatic header injection
- Backward compatible API with legacy support// Environment variables:
TRACING_ENABLED=true
TRACING_SERVICE_NAME=stellarflow-backend
TRACING_JAEGER_ENDPOINT=http://localhost:14268/api/traces
TRACING_HONEYCOMB_ENDPOINT=https://api.honeycomb.io/v1/events
TRACING_HONEYCOMB_API_KEY=your-api-key
TRACING_CONSOLE_EXPORTER=true// Features:
- Automatic request span creation
- W3C trace context extraction/injection
- HTTP attribute tagging
- Response status tracking
- Child span creation utilities// Available tracing methods:
- traceRelayerRequest()
- traceApiProviderRequest()
- traceOnChainSubmission()
- traceMultiSigOperation()
- tracePriceValidation()
- traceDatabaseOperation()
- traceCacheOperation()
- traceWebhookDelivery()
- traceErrorHandling()// Enhanced with:
- executeWithTracing() method for Stellar operations
- Automatic span creation for Horizon API calls
- Error tracking and failover tracing
- Network and endpoint attributes- ✅ Traced via auto-instrumentation
- ✅ Custom tracing available via
traceApiProviderRequest() - ✅ traceparent headers propagated
- ✅ Traced via auto-instrumentation
- ✅ Custom tracing available via
traceRelayerRequest() - ✅ traceparent headers injected automatically
- ✅ Enhanced tracing via
StellarProvider.executeWithTracing() - ✅ Horizon API calls traced
- ✅ Failover operations tracked
// Automatic via middleware
app.use(tracingMiddleware); // Creates spans for all HTTP requests
// Manual tracing in controllers
const span = TracingService.traceApiProviderRequest(req, 'coinbase', '/prices');
// ... perform API call
TracingService.finishSpan(span);// Enhanced Stellar provider
const result = await stellarProvider.executeWithTracing(
'submit_transaction',
() => server.submitTransaction(transaction),
{ 'transaction.id': txHash, 'operation.type': 'price_update' }
);// Automatic traceparent injection
setupAxiosTracing(); // Called in index.ts
// All axios requests now include:
// traceparent: 00-traceId-spanId-flags
// tracestate: key=valueTRACING_ENABLED=true
TRACING_CONSOLE_EXPORTER=true
TRACING_SERVICE_NAME=stellarflow-devTRACING_ENABLED=true
TRACING_JAEGER_ENDPOINT=http://jaeger-collector:14268/api/traces
TRACING_SERVICE_NAME=stellarflow-backendTRACING_ENABLED=true
TRACING_HONEYCOMB_ENDPOINT=https://api.honeycomb.io/v1/events
TRACING_HONEYCOMB_API_KEY=your-api-key
TRACING_HONEYCOMB_DATASET=stellarflow
TRACING_SERVICE_NAME=stellarflow-backend- Currently uses default sampling (100%)
- Could add configurable sampling rates
- Could add OpenTelemetry metrics for business KPIs
- Could add custom baggage for business context
- Could add automatic resource detection
npm run build # Should pass without tracing errors# Development with console exporter
TRACING_ENABLED=true TRACING_CONSOLE_EXPORTER=true npm run dev
# Check logs for trace output
[Tracing] HTTP GET /api/v1/market-rates/rates (trace: abc123)
[Tracing] Injected trace headers: [ 'traceparent', 'tracestate' ]- Configure Jaeger or Honeycomb endpoint
- View traces in respective UI
- Verify end-to-end trace continuity
✅ ALL REQUIREMENTS MET
The implementation provides comprehensive end-to-end tracing that covers:
- ✅ OpenTelemetry SDK integration
- ✅ Centralized trace export (Jaeger/Honeycomb/Console)
- ✅ Automatic traceparent header injection
- ✅ Complete data flow coverage (API → Relayers → On-chain)
- ✅ Production-ready configuration
- ✅ Development-friendly debugging
The implementation exceeds requirements with additional features like:
- Multiple exporter support
- Configuration validation
- Graceful shutdown handling
- Business-level tracing utilities
- Stellar-specific operation tracing