コード例 #1
0
        /// <summary>
        /// Trace before executing Sql command
        /// </summary>
        private void OnEventStart(EventWrittenEventArgs sqlEventData)
        {
            if (sqlEventData.Payload.Count != 4)
            {
                return;
            }

            // Skip EF request
            if (SqlRequestUtil.IsTraceable())
            {
                SqlRequestUtil.ProcessEventData(sqlEventData);

                try
                {
                    var currentSubsegment = _recorder.GetEntity() as Subsegment;
                    int id = Convert.ToInt32(sqlEventData.Payload[0], CultureInfo.InvariantCulture);
                    if (currentSubsegment != null)
                    {
                        CurrentSqlEvents.TryAdd(id, currentSubsegment);
                    }
                }
                catch (EntityNotAvailableException e)
                {
                    AWSXRayRecorder.Instance.TraceContext.HandleEntityMissing(AWSXRayRecorder.Instance, e, "Subsegment is not available in trace context.");
                }
            }
        }
コード例 #2
0
        private void OnCommandStop(Exception exception)
        {
            if (exception != null)
            {
                SqlRequestUtil.ProcessException(exception);
            }

            SqlRequestUtil.EndSubsegment();
        }
        private void OnEventStop(object value)
        {
            var command = ((CommandExecutedEventData)value).Command;

            if (command is DbCommand dbCommand)
            {
                SqlRequestUtil.EndSubsegment();
            }
        }
        private void OnEventException(object value)
        {
            var exc = ((CommandErrorEventData)value).Exception;

            if (exc is Exception exception)
            {
                SqlRequestUtil.ProcessException(exception);
                SqlRequestUtil.EndSubsegment();
            }
        }
        private void OnEventStart(object value)
        {
            var command = ((CommandEventData)value).Command;

            if (command is DbCommand dbCommand)
            {
                SqlRequestUtil.BeginSubsegment(dbCommand);
                SqlRequestUtil.ProcessCommand(dbCommand);
            }
        }
コード例 #6
0
        private void OnEventStop(object value)
        {
            // This class serves for tracing Sql command from both System.Data.SqlClient and Microsoft.Data.SqlClient and using fetch property works
            // fot both of these two cases
            var command = AgentUtil.FetchPropertyUsingReflection(value, "Command");

            if (command is DbCommand dbcommand)
            {
                if (CurrentDbCommands.TryRemove(dbcommand, out _))
                {
                    SqlRequestUtil.EndSubsegment();
                }
            }
        }
コード例 #7
0
        private void OnEventStart(object value)
        {
            // This class serves for tracing Sql command from both System.Data.SqlClient and Microsoft.Data.SqlClient and using fetch property works
            // fot both of these two cases
            var command = AgentUtil.FetchPropertyUsingReflection(value, "Command");

            if (command is DbCommand dbcommand)
            {
                // Skip processing EntityFramework Core request
                if (SqlRequestUtil.IsTraceable() && CurrentDbCommands.TryAdd(dbcommand, null))
                {
                    SqlRequestUtil.BeginSubsegment(dbcommand);
                    SqlRequestUtil.ProcessCommand(dbcommand);
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Trace after executing Sql command
        /// </summary>
        private void OnEventStop(EventWrittenEventArgs sqlEventData)
        {
            if (sqlEventData.Payload.Count != 3)
            {
                return;
            }

            int id              = Convert.ToInt32(sqlEventData.Payload[0], CultureInfo.InvariantCulture);
            int state           = Convert.ToInt32(sqlEventData.Payload[1], CultureInfo.InvariantCulture);
            int exceptionNumber = Convert.ToInt32(sqlEventData.Payload[2], CultureInfo.InvariantCulture);

            if (CurrentSqlEvents.TryRemove(id, out var currentSubsegment))
            {
                if ((state & 2) == 2)
                {
                    currentSubsegment.HasFault = true;
                }
                SqlRequestUtil.EndSubsegment(currentSubsegment);
            }
        }
コード例 #9
0
 private void OnCommandStart(DbCommand command)
 {
     SqlRequestUtil.BeginSubsegment(command);
     SqlRequestUtil.ProcessCommand(command);
 }