コード例 #1
0
        /// <summary>
        /// Records the SQL information on the current subsegment,
        /// </summary>
        private static void CollectSqlInformation(DbCommand command, bool?collectSqlQueriesOverride)
        {
            // Get database type from DbCommand
            string databaseType = GetDataBaseType(command);

            _recorder.AddSqlInformation("database_type", databaseType);

            DbConnectionStringBuilder connectionStringBuilder = new DbConnectionStringBuilder
            {
                ConnectionString = command.Connection.ConnectionString
            };

            // Remove sensitive information from connection string
            connectionStringBuilder.Remove("Password");

            _recorder.AddSqlInformation("connection_string", connectionStringBuilder.ToString());

            // Do a pre-check for UserID since in the case of TrustedConnection, a UserID may not be available.
            var user_id = GetUserId(connectionStringBuilder);

            if (user_id != null)
            {
                _recorder.AddSqlInformation("user", user_id.ToString());
            }

            if (ShouldCollectSqlText(collectSqlQueriesOverride))
            {
                _recorder.AddSqlInformation("sanitized_query", command.CommandText);
            }

            _recorder.AddSqlInformation("database_version", command.Connection.ServerVersion);
        }
コード例 #2
0
        /// <summary>
        /// Records the SQL information on the current subsegment,
        /// </summary>
        protected virtual void CollectSqlInformation(CommandEventData eventData)
        {
            // Get database type from DbContext
            string databaseType = EFUtil.GetDataBaseType(eventData.Context);

            _recorder.AddSqlInformation("database_type", databaseType);

            _recorder.AddSqlInformation("database_version", eventData.Command.Connection.ServerVersion);

            DbConnectionStringBuilder connectionStringBuilder = new DbConnectionStringBuilder
            {
                ConnectionString = eventData.Command.Connection.ConnectionString
            };

            // Remove sensitive information from connection string
            connectionStringBuilder.Remove("Password");

            // Do a pre-check for UserID since in the case of TrustedConnection, a UserID may not be available.
            var user_id = EFUtil.GetUserId(connectionStringBuilder);

            if (user_id != null)
            {
                _recorder.AddSqlInformation("user", user_id.ToString());
            }

            _recorder.AddSqlInformation("connection_string", connectionStringBuilder.ToString());

            if (ShouldCollectSqlText())
            {
                _recorder.AddSqlInformation("sanitized_query", eventData.Command.CommandText);
            }
        }
コード例 #3
0
        private void CollectSqlInformation()
        {
            AWSXRayRecorder recorder = AWSXRayRecorder.Instance;

            recorder.AddSqlInformation("database_type", DataBaseTypeString);

            recorder.AddSqlInformation("database_version", Connection.ServerVersion);

            SqlConnectionStringBuilder connectionStringBuilder = new SqlConnectionStringBuilder(Connection.ConnectionString);

            // Remove sensitive information from connection string
            connectionStringBuilder.Remove("Password");

            recorder.AddSqlInformation("user", connectionStringBuilder.UserID);
            recorder.AddSqlInformation("connection_string", connectionStringBuilder.ToString());
        }
コード例 #4
0
        /// <summary>
        /// Records the SQL information on the current subsegment,
        /// </summary>
        protected virtual void CollectSqlInformation(DbCommand command)
        {
            _recorder.AddSqlInformation("database_type", DataBaseTypeString);

            _recorder.AddSqlInformation("database_version", command.Connection.ServerVersion);

            SqlConnectionStringBuilder connectionStringBuilder = new SqlConnectionStringBuilder(command.Connection.ConnectionString);

            // Remove sensitive information from connection string
            connectionStringBuilder.Remove("Password");

            // Do a pre-check for UserID since in the case of TrustedConnection, a UserID may not be available.
            if (!string.IsNullOrEmpty(connectionStringBuilder.UserID))
            {
                _recorder.AddSqlInformation("user", connectionStringBuilder.UserID);
            }

            _recorder.AddSqlInformation("connection_string", connectionStringBuilder.ToString());

            if (ShouldCollectSqlText())
            {
                _recorder.AddSqlInformation("sanitized_query", command.CommandText);
            }
        }
コード例 #5
0
        public void TestAdd()
        {
            _recorder.BeginSegment(GetType().Name, TraceId);
            _recorder.AddSqlInformation("key1", "value1");
            _recorder.AddSqlInformation("key2", "value2");

            var segment = AWSXRayRecorder.Instance.TraceContext.GetEntity();

            Assert.AreEqual(2, segment.Sql.Count);
            Assert.AreEqual("value1", segment.Sql["key1"]);
            Assert.AreEqual("value2", segment.Sql["key2"]);

            _recorder.EndSegment();
        }
コード例 #6
0
        public void TestLogErrorModeForContextMissingStrategy()
        {
            using (var recorder = new AWSXRayRecorder())
            {
                recorder.ContextMissingStrategy = ContextMissingStrategy.LOG_ERROR;

                recorder.EndSegment();
                recorder.BeginSubsegment("no segment");
                recorder.EndSubsegment();
                recorder.SetNamespace("dummy namespace");
                recorder.AddAnnotation("key", "value");
                recorder.AddHttpInformation("key", "value");
                recorder.MarkError();
                recorder.MarkFault();
                recorder.MarkThrottle();
                recorder.AddException(new ArgumentNullException());
                recorder.AddPrecursorId(Entity.GenerateId());
                recorder.AddSqlInformation("sqlKey", "value");
                recorder.AddMetadata("key", "value");
            }
        }