runSyncWithCorrelation<T> static method

T runSyncWithCorrelation<T>(
  1. T fn(), {
  2. String? correlationId,
})

Runs the given synchronous function with a new correlation ID.

Similar to runWithCorrelation, but for synchronous code.

Implementation

static T runSyncWithCorrelation<T>(T Function() fn, {String? correlationId}) {
  final id = correlationId ?? _generateId();

  return runZoned(fn, zoneValues: {_correlationIdKey: id});
}