Exemplo n.º 1
0
        /// <summary>
        /// Executes a Control command in Kusto.
        /// </summary>
        /// <param name="command">The command to execute.</param>
        /// <param name="requestContext">An object that represents properties of the entire request process.</param>
        /// <returns>A data reader with a result.</returns>
        public async Task <IDataReader> ExecuteControlCommandAsync(string command, RequestContext requestContext)
        {
            // TODO: When a single K2 flow will generate multiple requests to Kusto - find a way to differentiate them using different ClientRequestIds
            var clientRequestProperties = ClientRequestPropertiesExtensions.ConstructClientRequestPropertiesFromRequestContext(KustoApplicationNameForTracing, ControlCommandActivityName, requestContext);

            Logger.LogDebug("Calling adminClient.ExecuteControlCommand with the command: {@command}", command.ToSensitiveData());
            var result = await adminClient.ExecuteControlCommandAsync(string.Empty, command, clientRequestProperties);

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes a Monitored Query in Kusto.
        /// </summary>
        /// <param name="queryData">A Query data.</param>
        /// <param name="requestContext">An object that represents properties of the entire request process.</param>
        /// <returns>A data reader with response and time taken.</returns>
        /// <exception cref="QueryException">Throws a QueryException on error.</exception>
        public async Task <(TimeSpan timeTaken, IDataReader reader)> ExecuteQueryAsync(QueryData queryData, RequestContext requestContext)
        {
            try
            {
                // TODO: When a single K2 flow will generate multiple requests to Kusto - find a way to differentiate them using different ClientRequestIds
                var clientRequestProperties = ClientRequestPropertiesExtensions.ConstructClientRequestPropertiesFromRequestContext(KustoApplicationNameForTracing, QueryActivityName, requestContext);

                // Use the kusto client to execute the query
                var(timeTaken, dataReader) = await queryClient.ExecuteMonitoredQueryAsync(queryData.QueryCommandText, clientRequestProperties, metricsHistograms);

                Logger.LogDebug("Calling queryClient.ExecuteMonitoredQuery with query data: {@queryData}", queryData.ToSensitiveData());

                var fieldCount = dataReader.FieldCount;
                Logger.LogDebug("FieldCount: {@fieldCount}", fieldCount);
                Logger.LogDebug("[metric] backend query total (sdk) duration: {timeTaken}", timeTaken);
                return(timeTaken, dataReader);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, "Failed to execute query.");
                throw new QueryException("Failed executing azure data explorer query", ex);
            }
        }