public void ShouldRecordMetricsWithSuffixesByDefault() { var settings = PcfMetricForwarderSettings.FromEnvironment(); var counterActor = Sys.ActorOf(Props.Create(() => new CounterAggregator(TestActor, settings.TimeProvider)), "counter"); var pcfRecorder = new PcfMetricRecorder(settings, TestActor, counterActor); pcfRecorder.RecordGauge("foo", 1.0d); // gauges never have suffixes ExpectMsg <PcfMetricRecording>().Name.Should().Be("foo"); // timings do pcfRecorder.RecordTiming("foo", 1000); ExpectMsg <PcfMetricRecording>().Name.Should().Be("foo.duration"); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } system = ActorSystem.Create("pb", ConfigurationFactory.ParseString(@"akka.loglevel = DEBUG")); var cmd = PetabridgeCmd.Get(system); cmd.Start(); var metrics = PcfMetricRecorder.Create(system); app.Run(async context => { var start = metrics.TimeProvider.NowUnixEpoch; metrics.IncrementCounter("http.serv"); var environment = PcfEnvironment.Instance.Value.ToString() + Environment.NewLine + Environment.GetEnvironmentVariable("VCAP_SERVICES"); await context.Response.WriteAsync(environment); metrics.RecordTiming("http.serv", metrics.TimeProvider.NowUnixEpoch - start); }); }