コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
 public void Handle(CommandSucceededEvent @event)
 {
     if (MongoLogger.IsEnabled(Constants.Events.CommandEnd))
     {
         MongoLogger.Write(Constants.Events.CommandEnd, new EventPayload <CommandSucceededEvent>(@event));
     }
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        public void AfterExecuteCommand([Object] CommandSucceededEvent @event)
        {
            var context = _contextAccessor.Context;

            context?.Span.AddTag(Common.Tags.STATUS_CODE, "ok");

            _tracingContext.Release(context);
        }
コード例 #5
0
 private static void OnCommandSucceeded(CommandSucceededEvent @event)
 {
     if (@event.CommandName == FindCommandName)
     {
         Console.WriteLine("Returned document:");
         PrintDocument(@event.Reply);
     }
 }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
 internal void OnCommandSucceeded(CommandSucceededEvent evt)
 {
     if (!_queryCache.TryRemove(evt.RequestId, out CachedQuery query))
     {
         return;
     }
     query.Telemetry.Duration = evt.Duration;
     _telemetryClient.TrackDependency(query.Telemetry);
 }
コード例 #8
0
 private void Handle(CommandSucceededEvent @event)
 {
     if (_activityMap.TryRemove(@event.RequestId, out var activity))
     {
         WithReplacedActivityCurrent(activity, () =>
         {
             diagnosticSource.StopActivity(activity, @event);
         });
     }
 }
コード例 #9
0
 public void Handle(CommandSucceededEvent @event)
 {
     @event = new CommandSucceededEvent(
         @event.CommandName,
         RecursivelyMaterialize(@event.Reply),
         @event.OperationId,
         @event.RequestId,
         @event.ConnectionId,
         @event.Duration);
     _parent.Capture(@event);
 }
コード例 #10
0
 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);
 }
コード例 #12
0
        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);
        }
コード例 #13
0
 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();
 }
コード例 #14
0
        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()}");
        }
コード例 #15
0
        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();
            }
        }
コード例 #16
0
        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();
         }
     }
 }
コード例 #18
0
 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);
     }
 }
コード例 #19
0
        /// <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
                });
            }
        }
コード例 #20
0
        /// <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
                });
            }
        }
コード例 #21
0
        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);
            }
        }
コード例 #22
0
 public void Handle(CommandSucceededEvent succeeded)
 {
 }
コード例 #23
0
 public void Handle(CommandSucceededEvent startedEvent)
 {
     Console.WriteLine("============================================");
     Console.WriteLine("Event Name: " + startedEvent.CommandName);
     Console.WriteLine("============================================");
 }
コード例 #24
0
 public void ExecuteSuccessInterception(CommandSucceededEvent e)
 {
     //Console.WriteLine($"Query Interpretation: {e.CommandName}");
     //Console.WriteLine(e.ToJson() );
 }
コード例 #25
0
 public void Handle(CommandSucceededEvent commandSucceededEvent)
 {
 }