private TResult Intercept <TResult>(Func <TResult> method) { AWSXRayRecorder recorder = AWSXRayRecorder.Instance; recorder.BeginSubsegment(Connection.Database + "@" + SqlUtil.RemovePortNumberFromDataSource(Connection.DataSource)); try { recorder.SetNamespace("remote"); var ret = method(); CollectSqlInformation(); return(ret); } catch (Exception e) { recorder.AddException(e); throw; } finally { recorder.EndSubsegment(); } }
/// <summary> /// Builds the name of the subsegment in the format database@datasource /// </summary> /// <param name="command"></param> /// <returns>Returns the formed subsegment name as a string.</returns> private string BuildSubsegmentName(DbCommand command) => command.Connection.Database + "@" + SqlUtil.RemovePortNumberFromDataSource(command.Connection.DataSource);