Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elastic search report gets broken if the elastic search server is offline during the first init of the report #1

Open
maxcherednik opened this issue Aug 14, 2017 · 0 comments

Comments

@maxcherednik
Copy link

maxcherednik commented Aug 14, 2017

The elastic search report is getting the version of the elastic search server during the construction:

public ElasticSearchReport(ElasticReportsConfig reportConfig)
        {
            var uri = new Uri($"http://{reportConfig.Host}:{reportConfig.Port}/_bulk");
            var nodeInfoUri = new Uri($"http://{reportConfig.Host}:{reportConfig.Port}");

            _reportConfig = reportConfig;
            this.elasticSearchUri = uri;

            using (var client = new WebClient())
            {
                try
                {
                    var json = client.DownloadString(nodeInfoUri);
                    var deserializer = new DataContractJsonSerializer(typeof(ElasticSearchNodeInfo));
                    using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(json)))
                    {
                        var nodeInfo = (ElasticSearchNodeInfo)deserializer.ReadObject(stream);
                        replaceDotsOnFieldNames = nodeInfo.MajorVersionNumber >= 2;
                    }

                }
                catch (Exception ex)
                {
                    log.WarnException("Unable to get ElasticSearch version. Field names with dots won't be replaced.", ex);
                    replaceDotsOnFieldNames = false;
                }
            }
        }

So in case of any exception here all the following report attempts are broken.

Possible solutions:

  1. Have the version of the elastic search configurable
  2. Make the init lazy by moving to the actual reporting reporting and keep trying to init until it's initialized with every report attempt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant