Package: wavefront-pyformance
wavefront-pyformanceThis is a plugin forpyformancewhich adds VMware Aria Operations™ for Applications (formerly known as Wavefront) reporters (via proxy or direct ingestion) and an abstraction that supports tagging at the host level. It also includes support for Wavefront delta counters.Note: We're in the process of updating the product name to Operations for Applications, but in many places we still refer to it as Wavefront.RequirementsPython 3.x are supported.pip install wavefront-pyformanceUsageWavefront ReporterThe Wavefront Reporters support tagging at the host level. If you pass a tag through a reporter, the reporter tags the metrics before sending the metrics to our service.Create a ReporterYou can create aWavefrontProxyReporterorWavefrontDirectReporteras follows:importpyformancefromwavefront_pyformanceimportwavefront_reporterreg=pyformance.MetricsRegistry()# report metrics to a Wavefront proxy every 60swf_proxy_reporter=wavefront_reporter.WavefrontProxyReporter(host=host,# requiredport=2878,# default: 2878source='wavefront-pyformance-example',# default: 'wavefront-pyformance'registry=reg,# default: Nonereporting_interval=60,# default: 60prefix='python.proxy.',# default: 'proxy.'tags={'key1':'val1','key2':'val2'},enable_runtime_metrics:False,# default: Falseenable_internal_metrics:True)# default: Truewf_proxy_reporter.start()# report metrics directly to a Wavefront server every 60swf_direct_reporter=wavefront_reporter.WavefrontDirectReporter(server=server,# requiredtoken=token,# requiredsource='wavefront-pyformance-example',# default: 'wavefront-pyformance'registry=reg,# default: Nonereporting_interval=60,# default: 60clock=None,# default: Noneprefix='python.direct.',# default: 'direct.'tags={'key1':'val1','key2':'val2'},# default: Noneenable_runtime_metrics=False,# default: Falseenable_internal_metrics=False)# default: Falsewf_direct_reporter.start()Flush and stop Wavefront ReporterAfter create Wavefront Reporter,start()will make the reporter automatically reporting everyreporting_intervalseconds.
Besides that, you can also callreport_now()to perform reporting immediately.# Report immediatelywf_reporter.report_now()# Stop Wavefront Reporterwf_reporter.stop()Delta CounterTo create a Wavefront delta counter:importpyformancefromwavefront_pyformanceimportdeltareg=pyformance.MetricsRegistry()d_0=delta.delta_counter(reg,'requests_delta')d_0.inc(10)Note: Having the same metric name for any two types of metrics will result in only one time series at the server and thus cause collisions.
In general, all metric names should be different. In case you have metrics that you want to track as both a Counter and Delta Counter, consider adding a relevant suffix to one of the metrics to differentiate one metric name from another.Wavefront HistogramTo create aWavefront Histogram:importpyformancefromwavefront_pyformanceimportwavefront_histogramreg=pyformance.MetricsRegistry()h_0=wavefront_histogram.wavefront_histogram(reg,'requests_duration')h_0.add(10)Python Runtime MetricsTo enable Python runtime metrics reporting,
set theenable_runtime_metricsflag toTrue:wf_proxy_reporter=wavefront_reporter.WavefrontProxyReporter(host=host,port=2878,registry=reg,source='runtime-metric-test',tags={'global_tag1':'val1','global_tag2':'val2'},prefix='python.proxy.',enable_runtime_metrics=True).report_minute_distribution()wf_direct_reporter=wavefront_reporter.WavefrontDirectReporter(server=server,token=token,registry=reg,source='runtime-metric-test',tags={'global_tag1':'val1','global_tag2':'val2'},prefix='python.direct.',enable_runtime_metrics=True).report_minute_distribution()