Skip to content

feat(tracing): add baggage and correlation context API #8

@CalvinAllen

Description

@CalvinAllen

Summary

Add a simple API for managing OpenTelemetry Baggage - key-value pairs that propagate across span boundaries. Useful for correlation IDs, user sessions, and feature tracking.

Use Cases

  • Track user session across all operations
  • Correlate related operations with a request ID
  • Tag all spans with feature flag values
  • Pass context through async operations

Proposed API

// Set baggage that flows to all child spans
VsixTelemetry.SetBaggage("session.id", sessionId);
VsixTelemetry.SetBaggage("user.tier", "premium");

// Get baggage value
var sessionId = VsixTelemetry.GetBaggage("session.id");

// Get all baggage
var allBaggage = VsixTelemetry.GetAllBaggage();

// Scoped baggage (auto-removes on dispose)
using (VsixTelemetry.WithBaggage("operation.id", operationId))
{
    // All spans created here will have this baggage
}

// Clear specific baggage
VsixTelemetry.RemoveBaggage("session.id");

Implementation Notes

  • Wrap System.Diagnostics.Baggage API
  • Ensure baggage propagates correctly with context
  • Consider adding automatic baggage-to-tag conversion option

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions