def test_find_label_published(): data = Data('cpu.utilization', filter=Filter('app', 'test-app'))\ .publish(label='A') program = Program(data) assert program.find_label('A') == data
#!/usr/bin/env python """Examples of how to use the `signal_analog.flow` module. Some basic understanding of SignalFx is assumed. """ from signal_analog.flow import Data, Filter, Program # A program is a convenient wrapper around SignalFlow statements with a few # utilities like `find_label` that returns a SignalFlow statement based on it's # label. program = Program() # A timeseries representing the 'cpu.utilization' metric that is filtered # down to just the 'shoeadmin' application. Also analyze the mean over the # previous minute and compare it to the data from last week. data = Data('cpu.utilization', filter=Filter('app', 'shoeadmin'))\ .mean(over='1m')\ .timeshift('1w')\ .publish('A') program.add_statements(data) print('{0}\n\t{1}'.format(program, str(program) == str(program.find_label('A'))))
def test_find_label_unpublished(): data = Data('cpu.utilization', filter=Filter('app', 'test-app')) program = Program(data) assert program.find_label('A') is None