public void AfterSending(IEnumerable <RequestMessage> messages, ConnectionId connectionId) { foreach (var message in messages) { CommandState state; if (_state.TryGetValue(message.RequestId, out state) && state.ExpectedResponseType == ExpectedResponseType.None) { state.Stopwatch.Stop(); if (_succeededEvent != null) { var @event = new CommandSucceededEvent( state.CommandName, state.NoResponseResponse ?? new BsonDocument("ok", 1), state.OperationId, message.RequestId, connectionId, state.Stopwatch.Elapsed); _succeededEvent(@event); } _state.TryRemove(message.RequestId, out state); } } }
public void Handle(CommandSucceededEvent @event) { if (MongoLogger.IsEnabled(Constants.Events.CommandEnd)) { MongoLogger.Write(Constants.Events.CommandEnd, new EventPayload <CommandSucceededEvent>(@event)); } }
private void VerifyCommandSucceededEvent(CommandSucceededEvent actual, BsonDocument expected, string databaseName, string collectionName) { actual.CommandName.Should().Be(expected["command_name"].ToString()); var expectedReply = (BsonDocument)expected["reply"]; var reply = MassageReply(actual.CommandName, actual.Reply, expectedReply); reply.Should().BeEquivalentTo(expectedReply); }
public void AfterExecuteCommand([Object] CommandSucceededEvent @event) { var context = _contextAccessor.Context; context?.Span.AddTag(Common.Tags.STATUS_CODE, "ok"); _tracingContext.Release(context); }
private static void OnCommandSucceeded(CommandSucceededEvent @event) { if (@event.CommandName == FindCommandName) { Console.WriteLine("Returned document:"); PrintDocument(@event.Reply); } }
public void AfterExecuteCommand([Object] CommandSucceededEvent @event) { if (_contextMap.TryRemove(@event.RequestId, out var context)) { context?.Span.AddTag(Common.Tags.STATUS_CODE, "ok"); _tracingContext.Release(context); } }
internal void OnCommandSucceeded(CommandSucceededEvent evt) { if (!_queryCache.TryRemove(evt.RequestId, out CachedQuery query)) { return; } query.Telemetry.Duration = evt.Duration; _telemetryClient.TrackDependency(query.Telemetry); }
private void Handle(CommandSucceededEvent @event) { if (_activityMap.TryRemove(@event.RequestId, out var activity)) { WithReplacedActivityCurrent(activity, () => { diagnosticSource.StopActivity(activity, @event); }); } }
public void Handle(CommandSucceededEvent @event) { @event = new CommandSucceededEvent( @event.CommandName, RecursivelyMaterialize(@event.Reply), @event.OperationId, @event.RequestId, @event.ConnectionId, @event.Duration); _parent.Capture(@event); }
private void Handle(CommandSucceededEvent @event) { if (_traceSource.Switch.ShouldTrace(TraceEventType.Verbose)) { Debug(TraceSourceEventHelper.CommandIdBase + 1, "{0}-{1}: {2} succeeded: {3}.", TraceSourceEventHelper.Label(@event.ConnectionId), @event.RequestId, @event.CommandName, @event.Reply); } else { Info(TraceSourceEventHelper.CommandIdBase + 1, "{0}-{1}: {2} succeeded.", TraceSourceEventHelper.Label(@event.ConnectionId), @event.RequestId, @event.CommandName); } }
public void Handle(CommandSucceededEvent @event) { @event = new CommandSucceededEvent( @event.CommandName, @event.Reply == null ? null : (BsonDocument)@event.Reply.DeepClone(), @event.OperationId, @event.RequestId, @event.ConnectionId, @event.Duration); _parent.Capture(@event); }
public void AfterExecuteCommand([Object] CommandSucceededEvent @event) { var context = _contextAccessor.Context; if (context == null) { _segmentContextMap.TryRemove((@event.OperationId ?? 0) + @event.RequestId, out context); } context?.Span.AddTag(Common.Tags.STATUS_CODE, "ok"); _tracingContext.Release(context); }
public void SuccessEventHandler(CommandSucceededEvent @event) { if (!_eventFilter.IsOnEventList(@event.CommandName, _events)) { return; } if (!_spanCache.TryRemove(@event.RequestId, out ISpan span)) { return; } span.SetTag($"{CallistoConstants.TracerPrefix}.reply.duration.milliseconds", @event.Duration.TotalMilliseconds); span.Finish(); }
void TraceResponse(CommandSucceededEvent command) { if (new List <string> { "isMaster", "buildInfo", "saslStart", "saslContinue", "getLastError" }.Contains(command.CommandName)) { return; } Debug.WriteLine("**********************************************"); Debug.WriteLine($"{command.CommandName}"); Debug.WriteLine($"{command.Reply.ToJson()}"); }
public void SuccessEventHandler(CommandSucceededEvent @event) { if (!_eventFilter.IsApproved(@event.CommandName)) { return; } if (_spanCache.TryRemove(@event.RequestId, out var activeScope)) { activeScope.SetTag($"{MongoDbPrefix}reply", @event.Reply.ToString()); activeScope.Finish(); } }
public void Handle(CommandSucceededEvent succeededEvent) { var commandName = succeededEvent.CommandName; if (commandName != "insert" || !this.scopes.ContainsKey(succeededEvent.RequestId)) { return; } // close the scope and finish the span this.scopes[succeededEvent.RequestId].Dispose(); this.scopes.Remove(succeededEvent.RequestId); }
private void Handle(CommandSucceededEvent @event) { if (_activityMap.TryRemove(@event.RequestId, out var activity)) { if (_diagnosticListener.IsEnabled(ActivityStopEventName, @event)) { _diagnosticListener.StopActivity(activity, @event); } else { activity.Stop(); } } }
private void HandleCommandSucceededEvent(CommandSucceededEvent @event) { try { if (!_processingQueries.TryRemove(@event.RequestId, out var span)) { return; } span.Duration = @event.Duration.TotalMilliseconds; span.End(); } catch (Exception ex) { // ignore _logger?.Log(LogLevel.Error, "Exception was thrown while handling 'command succeeded event'", ex, null); } }
/// <summary> /// Command Succeeded Event interceptor /// </summary> /// <param name="command"> /// Command Succeeded event /// </param> /// <param name="serviceProvider"> /// IServiceProvider /// </param> public static void InitilazeSucceededEvent(this CommandSucceededEvent command, IServiceProvider serviceProvider) { var cacheService = serviceProvider.GetService <ICacheService>(); var mongoService = serviceProvider.GetService <IMongoService>(); var httpContext = serviceProvider.GetService <IHttpContextAccessor>(); var data = cacheService.Get <string>(command.OperationId + command.CommandName); if (data != null) { mongoService.InsertAsync(new Models.Profiler() { Duration = command.Duration.Ticks, Query = data.ToString(), QueryType = command.CommandName.FindQueryType(), RequestUrl = httpContext?.HttpContext?.Request?.Path.Value }); } }
/// <summary> /// Command Succeeded Event interceptor /// </summary> /// <param name="command"> /// Command Succeeded event /// </param> /// <param name="serviceProvider"> /// IServiceProvider /// </param> public static void InitilazeSucceededEvent(this CommandSucceededEvent command, IServiceProvider serviceProvider) { var cacheService = serviceProvider.GetService <IMemoryCache>(); var httpContext = serviceProvider.GetService <IHttpContextAccessor>(); var data = cacheService.Get <string>(command.OperationId + command.CommandName); cacheService.Remove(command.OperationId + command.CommandName); if (data != null) { MongoValues.Profilers.Add(new Models.Profiler { Duration = command.Duration.Ticks, Query = data.ToString(), QueryType = command.CommandName.FindQueryType(), RequestUrl = httpContext?.HttpContext?.Request?.Path.Value, EndDate = DateTime.UtcNow, StartDate = DateTime.UtcNow - command.Duration }); } }
private void HandleCommandSucceededEvent(CommandSucceededEvent @event) { try { Logger.Trace()?.Log(nameof(HandleCommandSucceededEvent)); if (!_processingQueries.TryRemove(@event.RequestId, out var span)) { Logger.Trace()?.Log("Failed removing item from _processingQueries for RequestId: {RequestId}", @event.RequestId); return; } span.Duration = @event.Duration.TotalMilliseconds; span.End(); } catch (Exception ex) { // ignore Logger.Log(LogLevel.Error, "Exception was thrown while handling 'command succeeded event'", ex, null); } }
public void Handle(CommandSucceededEvent succeeded) { }
public void Handle(CommandSucceededEvent startedEvent) { Console.WriteLine("============================================"); Console.WriteLine("Event Name: " + startedEvent.CommandName); Console.WriteLine("============================================"); }
public void ExecuteSuccessInterception(CommandSucceededEvent e) { //Console.WriteLine($"Query Interpretation: {e.CommandName}"); //Console.WriteLine(e.ToJson() ); }
public void Handle(CommandSucceededEvent commandSucceededEvent) { }