public async Task <string> ExecuteAsync(CompilationStreamPair streams, IWorkSession session, CancellationToken cancellationToken) { var includePerformance = session.ShouldReportPerformance(); var rewriteStopwatch = includePerformance ? Stopwatch.StartNew() : null; var readerParameters = new ReaderParameters { ReadSymbols = streams.SymbolStream != null, SymbolStream = streams.SymbolStream, AssemblyResolver = _assemblyResolver, SymbolReaderProvider = streams.SymbolStream != null ? _symbolReaderProvider : null }; using var definition = AssemblyDefinition.ReadAssembly(streams.AssemblyStream, readerParameters); foreach (var rewriter in _rewriters) { rewriter.Rewrite(definition, session); } using var rewrittenStream = _memoryStreamManager.GetStream(); definition.Write(rewrittenStream); rewrittenStream.Seek(0, SeekOrigin.Begin); rewriteStopwatch?.Stop(); var executeStopwatch = includePerformance ? Stopwatch.StartNew() : null; var output = await _client.ExecuteAsync(session.GetSessionId(), rewrittenStream, includePerformance, cancellationToken); if (rewriteStopwatch != null && executeStopwatch != null) { // TODO: Prettify output += $"\n REWRITERS: {rewriteStopwatch.ElapsedMilliseconds,17}ms\n CONTAINER EXECUTOR: {executeStopwatch.ElapsedMilliseconds,8}ms"; } return(output); }
private static void AddDefaultDetails <TTelemetry>(TTelemetry telemetry, IWorkSession session, IDictionary <string, string> extras) where TTelemetry : ITelemetry, ISupportProperties { telemetry.Context.Session.Id = session?.GetSessionId(); if (extras == null) { return; } foreach (var pair in extras) { telemetry.Properties.Add(pair.Key, pair.Value); } }
public void Event(string name, IWorkSession session, IDictionary <string, string> extras = null) { Trace.TraceInformation("[{0}] Event '{0}'.", session?.GetSessionId(), name); }
public void Exception(Exception exception, IWorkSession session, IDictionary <string, string> extras = null) { Trace.TraceError("[{0}] Exception: {0}.", session?.GetSessionId(), exception); }