AppMetrics / Elasticsearch

App Metrics Extensions for Elasticsearch reporting
http://app-metrics.io/getting-started/reporting/index.html
Apache License 2.0
20 stars 20 forks source link

System.MissingMethodException on call to .Report.ToElasticSearch() #27

Open mleyb opened 6 years ago

mleyb commented 6 years ago

Hi - I'm trying to use version 2.0.0-alpha in my project, and am stumbling at the first hurdle with an exception being thrown from the call to .Report.ToElasticSearch() on startup

I'm using the overload which takes the string url and elasticsearchIndex arguments

System.MissingMethodException HResult=0x80131513 Message=Method not found: 'Void App.Metrics.GeneratedMetricNameMapping..ctor(System.Collections.Generic.IDictionary2<App.Metrics.HistogramValueDataKeys,System.String>, System.Collections.Generic.IDictionary2<App.Metrics.MeterValueDataKeys,System.String>, System.Collections.Generic.IDictionary2<App.Metrics.ApdexValueDataKeys,System.String>, System.Collections.Generic.IDictionary2<App.Metrics.CounterValueDataKeys,System.String>)'. Source=App.Metrics.Formatters.Elasticsearch StackTrace: at App.Metrics.Formatters.Elasticsearch.MetricsElasticsearchDocumentFormattingOptions..ctor() at App.Metrics.Formatters.Elasticsearch.MetricsElasticsearchOutputFormatter..ctor(String elasticsearchIndex) at App.Metrics.Reporting.Elasticsearch.ElasticsearchReporter..ctor(MetricsReportingElasticsearchOptions options, IElasticsearchClient elasticsearchClient) at App.Metrics.MetricsElasticsearchReporterBuilder.ToElasticsearch(IMetricsReportingBuilder metricReporterProviderBuilder, String url, String elasticsearchIndex) ..........

is this currently a known issue? Thanks

alhardy commented 6 years ago

The elasticsearch reporter is somewhat out of date, an update is coming soon.

Are you using the same version of the App.Metrics package?

mleyb commented 6 years ago

Updated to all latest alpha packages, and I no longer get the MissingMethodException on startup, so some progress

Unfortunately I now get this

System.TypeLoadException: 'Method 'get_MetricFields' in type 'App.Metrics.Formatters.Elasticsearch.MetricsElasticsearchOutputFormatter' from assembly 'App.Metrics.Formatters.Elasticsearch, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0d5193a913d1b812' does not have an implementation.'

Package depdendency versions are described here:

Include="App.Metrics" Version="3.0.0-alpha-0780" Include="App.Metrics.AspNetCore.Endpoints" Version="3.0.0-alpha-0098" Include="App.Metrics.AspNetCore.Health" Version="2.1.0-alpha-0071" Include="App.Metrics.AspNetCore.Health.Endpoints" Version="2.1.0-alpha-0071" Include="App.Metrics.Extensions.DependencyInjection" Version="3.0.0-alpha-0072" Include="App.Metrics.Formatters.ElasticSearch" Version="2.0.0-alpha" Include="App.Metrics.Health.Checks.Process" Version="2.1.0-alpha-0118" Include="App.Metrics.Reporting.Elasticsearch" Version="2.0.0-alpha"

foresightyj commented 6 years ago

Same Problem experienced here.

My package dependencies are:


  <package id="App.Metrics" version="2.1.0" targetFramework="net461" />
  <package id="App.Metrics.Abstractions" version="2.1.0" targetFramework="net461" />
  <package id="App.Metrics.Concurrency" version="2.0.1" targetFramework="net461" />
  <package id="App.Metrics.Core" version="2.1.0" targetFramework="net461" />
  <package id="App.Metrics.Extensions.Middleware" version="1.2.0" targetFramework="net461" />
  <package id="App.Metrics.Formatters.Ascii" version="2.1.0" targetFramework="net461" />
  <package id="App.Metrics.Formatters.ElasticSearch" version="2.0.0-alpha" targetFramework="net461" />
  <package id="App.Metrics.Formatters.Json" version="2.1.0" targetFramework="net461" />
  <package id="App.Metrics.Formatting.ElasticSearch" version="1.1.1" targetFramework="net461" />
  <package id="App.Metrics.Health" version="2.0.0" targetFramework="net461" />
  <package id="App.Metrics.Health.Abstractions" version="2.0.0" targetFramework="net461" />
  <package id="App.Metrics.Health.Checks.Http" version="2.0.0" targetFramework="net461" />
  <package id="App.Metrics.Health.Checks.Network" version="2.0.0" targetFramework="net461" />
  <package id="App.Metrics.Health.Checks.Process" version="2.0.0" targetFramework="net461" />
  <package id="App.Metrics.Health.Core" version="2.0.0" targetFramework="net461" />
  <package id="App.Metrics.Health.Formatters.Ascii" version="2.0.0" targetFramework="net461" />
  <package id="App.Metrics.Health.Formatters.Json" version="2.0.0" targetFramework="net461" />
  <package id="App.Metrics.Reporting.Console" version="2.0.0" targetFramework="net461" />
  <package id="App.Metrics.Reporting.Elasticsearch" version="2.0.0-alpha" targetFramework="net461" />

image

henkosch commented 6 years ago

Is this project abandoned? Nothing seems to work.

alhardy commented 6 years ago

It's not abandoned I just haven't had capacity. I'll try getting to it this weekend.

I don't have plans in the short term though to update supporting the lasted version of Elasticsearch.

foresightyj commented 6 years ago

To the rest who are concerned, what I did is downloading the entire program, recompiling the source code, fixing wherever necessary and packaging it into a new nuget package for my own need. It worked really well.

siberianguy commented 6 years ago

@foresightyj Could you please push your changes to a GitHub fork?

siberianguy commented 6 years ago

@alhardy We're trying to decide whether to use InfluxDb or wait for Elastic Search fix. Could you please give a rough estimate on an Elastic Search fix?

alhardy commented 6 years ago

@siberianguy trying to get to it, a lot in at the moment. I am assuming this is just a version dependency issue. Have you tried keeping all AppMetrics packages on 2.0.0-alpha?

mleyb commented 6 years ago

To the rest who are concerned, what I did is downloading the entire program, recompiling the source code, fixing wherever necessary and packaging it into a new nuget package for my own need. It worked really well.

care to share?

still waiting on a decent solution to this.

foresightyj commented 6 years ago

FHT.App.Metrics.Elasticsearch.zip

FHT.App.Metrics.Elasticsearch.1.0.1.nupkg.zip

@mleyb @siberianguy Here are the zipped code and nuget package. I forgot what I did to the code since it is not version controlled.

using it:

    private IMetricsRoot _metrics;
    private CounterOptions _successCounter;
    private CounterOptions _errorCounter;
    private TimerOptions _requestTimer;

    private void ConfigureMetrics()
    {
        _metrics = new MetricsBuilder()
            .Configuration.Configure(options =>
            {
                options.DefaultContextLabel = "noti";
                options.GlobalTags.Add("AppEnv", ApplicationEnvironment.CurrentEnvironmentTag);
                options.Enabled = true;
                options.ReportingEnabled = true;
            })
            //.OutputMetrics.AsPlainText()
            //.OutputMetrics.AsJson()
            .Report.ToElasticsearch(options =>
            {
                options.Elasticsearch.Index = "metrics_noti_" + ApplicationEnvironment.CurrentEnvironment.ToLower();
                options.Elasticsearch.BaseUri = new Uri("http://192.168.0.112:9200");
                options.HttpPolicy.BackoffPeriod = TimeSpan.FromSeconds(30);
                options.HttpPolicy.FailuresBeforeBackoff = 5;
                options.HttpPolicy.Timeout = TimeSpan.FromSeconds(10);
                //options.MetricsOutputFormatter = new MetricsJsonOutputFormatter();
                //options.Filter = new MetricsFilter().WhereType(MetricType.Counter);
                options.FlushInterval = TimeSpan.FromSeconds(20);
            })
            .Build();
        _successCounter = new CounterOptions { Name = "Success", MeasurementUnit = Unit.Calls };
        _errorCounter = new CounterOptions { Name = "Error", MeasurementUnit = Unit.Errors };
        _requestTimer = new TimerOptions
        {
            Name = "Consume",
            MeasurementUnit = Unit.Requests,
            DurationUnit = TimeUnit.Milliseconds,
            RateUnit = TimeUnit.Milliseconds
        };

        var scheduler = new AppMetricsTaskScheduler(
            TimeSpan.FromSeconds(5),
            async () =>
            {
                await Task.WhenAll(_metrics.ReportRunner.RunAllAsync());
                _metrics.Provider.Timer.Instance(_requestTimer).Reset();
                _metrics.Provider.Counter.Instance(_successCounter).Reset();
                var errorCount = _metrics.Provider.Counter.Instance(_errorCounter).GetValueOrDefault().Count;
                if (errorCount > 0)
                {
                    _metrics.Provider.Counter.Instance(_errorCounter).Reset();
                }
            });

        scheduler.Start();
    }