currentWithBaggage static method

Context currentWithBaggage()

Returns the current context with Baggage, creating empty Baggage if needed.

If the current context has no Baggage, this creates a new context with empty Baggage, sets it as the current context, and returns it.

Implementation

static Context currentWithBaggage() {
  _getAndCacheOTelFactory();
  final current = Context.current;
  if (current.baggage != null) return current;
  return current.copyWithBaggage(OTelFactory.otelFactory!.baggage({}));
}