Пример #1
0
 public AsyncEnumerator(DocumentAsyncEnumerable documentEnumerable, CancellationToken cancellationToken)
 {
     _cosmosClient      = documentEnumerable._cosmosClient;
     _containerId       = documentEnumerable._containerId;
     _cosmosSqlQuery    = documentEnumerable._cosmosSqlQuery;
     _cancellationToken = cancellationToken;
 }
 public Enumerator(DocumentEnumerable documentEnumerable)
 {
     _cosmosClient   = documentEnumerable._cosmosClient;
     _containerId    = documentEnumerable._containerId;
     _partitionKey   = documentEnumerable._partitionKey;
     _cosmosSqlQuery = documentEnumerable._cosmosSqlQuery;
 }
Пример #3
0
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public static void ExecutingSqlQuery(
            this IDiagnosticsLogger <DbLoggerCategory.Database.Command> diagnostics,
            string containerId,
            string?partitionKey,
            CosmosSqlQuery cosmosSqlQuery)
        {
            var definition = CosmosResources.LogExecutingSqlQuery(diagnostics);

            if (diagnostics.ShouldLog(definition))
            {
                var logSensitiveData = diagnostics.ShouldLogSensitiveData();

                definition.Log(
                    diagnostics,
                    containerId,
                    logSensitiveData ? partitionKey : "?",
                    FormatParameters(cosmosSqlQuery.Parameters, logSensitiveData && cosmosSqlQuery.Parameters.Count > 0),
                    Environment.NewLine,
                    cosmosSqlQuery.Query);
            }

            if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled))
            {
                var eventData = new CosmosQueryEventData(
                    definition,
                    ExecutingSqlQuery,
                    containerId,
                    partitionKey,
                    cosmosSqlQuery.Parameters.Select(p => (p.Name, p.Value)).ToList(),
                    cosmosSqlQuery.Query,
                    diagnostics.ShouldLogSensitiveData());

                diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled);
            }
        }
Пример #4
0
 public DocumentAsyncEnumerable(
     CosmosClientWrapper cosmosClient,
     string containerId,
     CosmosSqlQuery cosmosSqlQuery)
 {
     _cosmosClient   = cosmosClient;
     _containerId    = containerId;
     _cosmosSqlQuery = cosmosSqlQuery;
 }
 public DocumentAsyncEnumerable(
     CosmosClientWrapper cosmosClient,
     string containerId,
     string partitionKey,
     CosmosSqlQuery cosmosSqlQuery)
 {
     _cosmosClient   = cosmosClient;
     _containerId    = containerId;
     _patitionKey    = partitionKey;
     _cosmosSqlQuery = cosmosSqlQuery;
 }
Пример #6
0
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public static void ExecutedReadNext(
            this IDiagnosticsLogger <DbLoggerCategory.Database.Command> diagnostics,
            TimeSpan elapsed,
            double requestCharge,
            string activityId,
            string containerId,
            string?partitionKey,
            CosmosSqlQuery cosmosSqlQuery)
        {
            var definition = CosmosResources.LogExecutedReadNext(diagnostics);

            if (diagnostics.ShouldLog(definition))
            {
                var logSensitiveData = diagnostics.ShouldLogSensitiveData();

                definition.Log(
                    diagnostics,
                    l => l.Log(
                        definition.Level,
                        definition.EventId,
                        definition.MessageFormat,
                        elapsed.TotalMilliseconds,
                        requestCharge,
                        activityId,
                        containerId,
                        logSensitiveData ? partitionKey : "?",
                        FormatParameters(cosmosSqlQuery.Parameters, logSensitiveData && cosmosSqlQuery.Parameters.Count > 0),
                        Environment.NewLine,
                        cosmosSqlQuery.Query));
            }

            if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled))
            {
                var eventData = new CosmosQueryExecutedEventData(
                    definition,
                    ExecutedReadNext,
                    elapsed,
                    requestCharge,
                    activityId,
                    containerId,
                    partitionKey,
                    cosmosSqlQuery.Parameters.Select(p => (p.Name, p.Value)).ToList(),
                    cosmosSqlQuery.Query,
                    diagnostics.ShouldLogSensitiveData());

                diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled);
            }
        }
Пример #7
0
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public static void ExecutingSqlQuery(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Database.Command> diagnosticsLogger,
            [NotNull] CosmosSqlQuery cosmosSqlQuery)
        {
            var definition = new EventDefinition <string, string, string>(
                diagnosticsLogger.Options,
                CosmosEventId.ExecutingSqlQuery,
                LogLevel.Debug,
                "CosmosEventId.ExecutingSqlQuery",
                level => LoggerMessage.Define <string, string, string>(
                    level,
                    CosmosEventId.ExecutingSqlQuery,
                    "Executing Sql Query [Parameters=[{parameters}]]{newLine}{commandText}"));

            definition.Log(
                diagnosticsLogger,
                FormatParameters(cosmosSqlQuery.Parameters, ShouldLogParameterValues(diagnosticsLogger, cosmosSqlQuery)),
                Environment.NewLine,
                cosmosSqlQuery.Query);
        }
Пример #8
0
        public static void ExecutingSqlQuery(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Database.Command> diagnosticsLogger,
            CosmosSqlQuery cosmosSqlQuery)
        {
            var definition = new EventDefinition <string, string, string>(
                CoreEventId.ProviderBaseId,
                LogLevel.Debug,
                LoggerMessage.Define <string, string, string>(
                    LogLevel.Debug,
                    CoreEventId.ProviderBaseId,
                    "Executing Sql Query [Parameters=[{parameters}]]{newLine}{commandText}"));

            var warningBehavior = definition.GetLogBehavior(diagnosticsLogger);

            definition.Log(
                diagnosticsLogger,
                warningBehavior,
                FormatParameters(cosmosSqlQuery.Parameters),
                Environment.NewLine,
                cosmosSqlQuery.Query);
        }
Пример #9
0
 private static bool ShouldLogParameterValues(
     IDiagnosticsLogger <DbLoggerCategory.Database.Command> diagnostics,
     CosmosSqlQuery cosmosSqlQuery)
 => cosmosSqlQuery.Parameters.Count > 0 &&
 diagnostics.ShouldLogSensitiveData();
Пример #10
0
 public AsyncEnumerator(DocumentAsyncEnumerable documentEnumerable)
 {
     _cosmosClient   = documentEnumerable._cosmosClient;
     _containerId    = documentEnumerable._containerId;
     _cosmosSqlQuery = documentEnumerable._cosmosSqlQuery;
 }