Example #1
0
 /// <summary>
 /// Adds fact about ES call into exception
 /// </summary>
 public static Exception AndFactIs(this Exception exception, IApiCallDetails apiCallDetails)
 {
     return(exception.AndFactIs("es-call-details",
                                apiCallDetails != null
             ? ApiCallDumper.ApiCallToDump(apiCallDetails)
             : "[null]"));
 }
Example #2
0
 /// <summary>
 /// Adds fact about ES call into log
 /// </summary>
 public static DslExpression AndFactIs(this DslExpression logger, IApiCallDetails apiCallDetails)
 {
     return(logger.AndFactIs("es-call-details",
                             apiCallDetails != null
             ? ApiCallDumper.ApiCallToDump(apiCallDetails)
             : "[null]"));
 }
Example #3
0
        /// <summary>
        /// Initializes a new instance of <see cref="IEsClientProvider"/>
        /// </summary>
        public EsClientProvider(
            ElasticsearchOptions options,
            ILogger <EsClientProvider> logger = null)
        {
            _connectionPool = new SingleNodeConnectionPool(new Uri(options.Url));

            var settings = new ConnectionSettings(_connectionPool);

            if (logger != null)
            {
                var log = logger.Dsl();

                settings.DisableDirectStreaming();
                settings.OnRequestCompleted(details =>
                {
                    log.Debug("ElasticSearch request completed")
                    .AndFactIs("dump", ApiCallDumper.ApiCallToDump(details))
                    .Write();
                });
            }

            _client = new ElasticClient(settings);
        }