private async Task ProcessLimeTraceAsync(Node node, InputTrace trace, CancellationToken cancellationToken) { await _sender.SendMessageAsync(new Message { To = node, Content = trace }, cancellationToken); }
private async Task ProcessHttpTraceAsync(Uri uri, InputTrace trace, CancellationToken cancellationToken) { using (var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, uri)) { var json = JsonConvert.SerializeObject(trace, JsonSerializerSettingsContainer.Settings); httpRequestMessage.Content = new StringContent( json, Encoding.UTF8, "application/json"); using (var httpResponseMessage = await _httpClient.SendAsync(httpRequestMessage, cancellationToken).ConfigureAwait(false)) { httpResponseMessage.EnsureSuccessStatusCode(); } } }
public (StateTrace, Stopwatch) CreateStateTrace(InputTrace inputTrace, State state, StateTrace stateTrace = null, Stopwatch stateStopwatch = null) { stateStopwatch?.Stop(); if (inputTrace != null && stateTrace != null && stateStopwatch != null) { stateTrace.ElapsedMilliseconds = stateStopwatch.ElapsedMilliseconds; inputTrace.States.Add(stateTrace); } if (state != null && inputTrace != null) { (stateTrace, stateStopwatch) = (state.ToTrace(), Stopwatch.StartNew()); } else { (stateTrace, stateStopwatch) = (null, null); } return(stateTrace, stateStopwatch); }
public async Task ProcessTraceAsync(InputTrace inputTrace, TraceSettings traceSettings, Stopwatch inputStopwatch, CancellationToken cancellationToken) { inputStopwatch?.Stop(); // Check if we should trace the request if (inputTrace != null && traceSettings != null && inputStopwatch != null && ( traceSettings.Mode == TraceMode.All || (traceSettings.Mode.IsSlow() && inputStopwatch.ElapsedMilliseconds >= (traceSettings.SlowThreshold ?? 5000)) || (traceSettings.Mode.IsError() && inputTrace.Error != null) )) { inputTrace.ElapsedMilliseconds = inputStopwatch.ElapsedMilliseconds; await _traceActionBlock.SendAsync( new TraceEvent { Trace = inputTrace, Settings = traceSettings }, cancellationToken); } }