예제 #1
0
        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);
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
 public void Event(string name, IWorkSession session, IDictionary <string, string> extras = null)
 {
     Trace.TraceInformation("[{0}] Event '{0}'.", session?.GetSessionId(), name);
 }
예제 #4
0
 public void Exception(Exception exception, IWorkSession session, IDictionary <string, string> extras = null)
 {
     Trace.TraceError("[{0}] Exception: {0}.", session?.GetSessionId(), exception);
 }