signal_analog
signal_analog copied to clipboard
Usability: It would be nice if the PublishLabelOptions could be folded into the Plot class
PublishLabelOptions
would make more sense as part of the Plot
class. It would make the API more closely model the SignalFx UI (vs. modeling the less user friendly Sfx REST API).
Currently, PublishLabelOptions
looks like this but all of those options are more related to the Plot
they are modifying.
TimeSeriesChart() \
.with_name("Lambda " + function_name + " Invocations") \
.with_description(description)
.with_default_plot_type(PlotType.column_chart) \
.with_chart_legend_options("sf_metric", show_legend=True)
.with_publish_label_options(
PublishLabelOptions(
label='Invocations',
palette_index=PaletteColor.green
),
PublishLabelOptions(
label='Duration',
palette_index=PaletteColor.gray,
y_axis=1,
plot_type=PlotType.line_chart,
value_unit='Millisecond'
)
)
.with_axes([AxisOption(label="Count", min=0), AxisOption(label="Latency", min=0)])
.with_program(
Program(
Plot(
assigned_name="A",
signal_name="Invocations",
filter=And(
Filter("FunctionName", function_name),
Filter("namespace", "AWS/Lambda"),
Filter("stat", "sum")
),
rollup=RollupType.sum,
fx=[Sum(by=["aws_account_id", "FunctionName"])],
label="Invocations"),
Plot(
assigned_name="B",
signal_name="Duration",
filter=And(
Filter("FunctionName", function_name),
Filter("namespace", "AWS/Lambda"),
Filter("stat", "mean")
),
rollup=RollupType.max,
fx=[Sum(by=["aws_account_id", "FunctionName"])],
label="Duration")
)
)