Skip to content

Commit

Permalink
chore: fix conversation --> conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasgerstmayr committed Nov 23, 2020
1 parent 2945895 commit f07b767
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 31 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
- **redis**: send one instance labels request instead of one per instance
- **redis**: refresh instances only once per series
- **redis**: improved error messages
- **vector**: (internal) option to disable time utilization conversation
- **vector**: (internal) option to disable time utilization conversion
- **vector**: show error message when access mode is set to server & url override is set
- **vector**: disable redis backfill for now (pmseries and pmapi instance id's don't match)
- **bpftrace**: interpret all fields of CSV output as strings
Expand Down Expand Up @@ -148,7 +148,7 @@ Restart Grafana server, and check the logs if the plugin loaded successfully.

### Redis

- fix value transformations (e.g., rate conversation of counters)
- fix value transformations (e.g., rate conversion of counters)

### All

Expand Down Expand Up @@ -186,7 +186,7 @@ Restart Grafana server, and check the logs if the plugin loaded successfully.
### Features

- retrieval of Performance Co-Pilot metrics from pmseries (PCP Redis), pmproxy, and pmwebd (PCP Live)
- automatic rate conversation of counter metrics
- automatic rate conversion of counter metrics
- auto-completion of metric names <sup>1,2</sup>, qualifier keys, and values <sup>2</sup>
- display of semantics, units, and help texts of metrics <sup>1</sup>
- legend templating support with `$metric`, `$metric0`, `$instance`, `$some_label`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ It presents a unifying abstraction for all of the performance data in a system,
* support for [Grafana Alerting](https://grafana.com/docs/grafana/latest/alerting/create-alerts/) [1]
* support for [derived metrics](https://man7.org/linux/man-pages/man3/pmregisterderived.3.html#DESCRIPTION) (allows the usage of arithmetic operators and statistical functions inside a query) [2]
* automated configuration of metric units [1,2,3]
* automatic rate conversation and time utilization conversion
* automatic rate and time utilization conversion
* heatmap, table [2,3] and flame graph [3] support
* auto completion of metric names [1,2], qualifier keys and values [1], and bpftrace probes, builtin variables and functions [3]
* display of semantics, units and help texts of metrics [2] and bpftrace builtins [3]
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Features
* support for `Grafana Alerting <https://grafana.com/docs/grafana/latest/alerting/create-alerts/>`_ [1]
* support for `derived metrics <https://man7.org/linux/man-pages/man3/pmregisterderived.3.html#DESCRIPTION>`_ (allows the usage of arithmetic operators and statistical functions inside a query) [2]
* automated configuration of metric units [1,2,3]
* automatic rate conversation and time utilization conversion
* automatic rate and time utilization conversion
* heatmap, table [2,3] and flame graph [3] support
* auto-completion of metric names [1,2], qualifier keys and values [1], and bpftrace probes, builtin variables and functions [3]
* display of semantics, units and help texts of metrics [2] and bpftrace builtins [3]
Expand Down
2 changes: 1 addition & 1 deletion pkg/datasources/redis/data_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func createFieldVector(seriesType string) (interface{}, error) {
switch seriesType {
case "32", "u32", "64", "u64", "float", "double":
// most counters are integers, but once they got rate-converted they are floats
// and rate conversation happens inline
// and rate conversion happens inline
return []*float64{}, nil
case "string":
return []*string{}, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/datasources/redis/datasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestDatasource(t *testing.T) {
So(response.Responses["A"].Frames, ShouldBeEmpty)
})

Convey("query disk.dev.read{hostname==\"localhost\"}, perform rate conversation and return the result", t, func(c C) {
Convey("query disk.dev.read{hostname==\"localhost\"}, perform rate conversion and return the result", t, func(c C) {
handler := http.NewServeMux()
handler.HandleFunc("/series/query", func(writer http.ResponseWriter, request *http.Request) {
c.So(request.URL.Query().Get("expr"), ShouldEqual, `disk.dev.read{hostname=="localhost"}`)
Expand Down
10 changes: 5 additions & 5 deletions pkg/datasources/redis/field_transformations.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func fieldSetRate(field *data.Field, idx int, delta time.Duration) error {
return nil
}

func rateConversation(frame *data.Frame) error {
log.DefaultLogger.Debug("Performing Rate Conversation")
func rateConversion(frame *data.Frame) error {
log.DefaultLogger.Debug("Performing Rate Conversion")
var timeField *data.Field
for _, field := range frame.Fields {
if field.Type() == data.FieldTypeTime {
Expand Down Expand Up @@ -80,7 +80,7 @@ func fieldDivideBy(field *data.Field, idx int, divisor int) error {
return nil
}

func timeUtilizationConversation(frame *data.Frame, divisor int) error {
func timeUtilizationConversion(frame *data.Frame, divisor int) error {
log.DefaultLogger.Debug("Converting to Time Utilization", "frame", frame.Name)
for _, field := range frame.Fields {
if field.Type() == data.FieldTypeTime {
Expand All @@ -106,14 +106,14 @@ var pcpTimeUnits = map[string]int{

func applyFieldTransformations(redisQuery *Query, desc *series.Desc, frame *data.Frame) error {
if desc.Semantics == "counter" {
err := rateConversation(frame)
err := rateConversion(frame)
if err != nil {
return err
}

divisor, isTimeUtilization := pcpTimeUnits[desc.Units]
if isTimeUtilization {
err = timeUtilizationConversation(frame, divisor)
err = timeUtilizationConversion(frame, divisor)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/datasources/redis/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (ds *redisDatasourceInstance) executeTimeSeriesQuery(dataQuery *backend.Dat

interval := dataQuery.Interval.Seconds()
// request a bigger time frame to fill the chart (otherwise left and right border of chart is empty)
// because of the rate conversation of counters first datapoint my be "lost" -> expand timeframe at the beginning
// because of the rate conversion of counters first datapoint my be "lost" -> expand timeframe at the beginning
additionalTimeRange := int64(math.Max(interval, 60)) // 60s is the default sample interval of pmlogger
start := dataQuery.TimeRange.From.Unix() - 2*additionalTimeRange // seconds
finish := dataQuery.TimeRange.To.Unix() + additionalTimeRange // seconds
Expand Down
4 changes: 2 additions & 2 deletions src/datasources/bpftrace/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export const defaultBPFtraceQuery: BPFtraceQuery & Optional<PmapiQuery, 'url' |
expr: '',
format: TargetFormat.TimeSeries,
options: {
rateConversation: true,
timeUtilizationConversation: true,
rateConversion: true,
timeUtilizationConversion: true,
},
};

Expand Down
2 changes: 1 addition & 1 deletion src/datasources/lib/pmapi/data_processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ function createDataFrame(
let requestRangeFromMs = request.range.from.valueOf() - sampleIntervalSec * 1000;
let requestRangeToMs = request.range.to.valueOf() + sampleIntervalSec * 1000;

// the first value of a counter metric is lost due to rate conversation
// the first value of a counter metric is lost due to rate conversion
if (metric.metadata.sem === Semantics.Counter) {
requestRangeFromMs -= sampleIntervalSec * 1000;
}
Expand Down
6 changes: 3 additions & 3 deletions src/datasources/lib/pmapi/field_transformations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function rateConversion(frame: MutableDataFrame, discreteValues = false) {
// timeField.values.set(0, MISSING_VALUE);
}

function timeUtilizationConversation(frame: MutableDataFrame, divisor: number) {
function timeUtilizationConversion(frame: MutableDataFrame, divisor: number) {
for (const field of frame.fields) {
if (field.type !== FieldType.number) {
continue;
Expand All @@ -75,13 +75,13 @@ export function applyFieldTransformations(query: PmapiQuery, metadata: Metadata,
rateConversion(frame, discreteValues);

if (
query.options.timeUtilizationConversation &&
query.options.timeUtilizationConversion &&
query.format !== TargetFormat.Heatmap &&
metadata.units in PCP_TIME_UNITS
) {
// for time based counters, convert to time utilization
// but not for heatmaps, otherwise bcc.runq.latency would also get converted
timeUtilizationConversation(frame, PCP_TIME_UNITS[metadata.units]!);
timeUtilizationConversion(frame, PCP_TIME_UNITS[metadata.units]!);
}
}
}
4 changes: 2 additions & 2 deletions src/datasources/lib/pmapi/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export interface PmapiDefaultOptions {
}

export interface PmapiQueryOptions {
rateConversation: boolean;
timeUtilizationConversation: boolean;
rateConversion: boolean;
timeUtilizationConversion: boolean;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/datasources/lib/specs/fixtures/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export function pmapiQuery(props?: DeepPartial<PmapiQuery>): PmapiQuery {
url: '',
hostspec: '',
options: {
rateConversation: true,
timeUtilizationConversation: true,
rateConversion: true,
timeUtilizationConversion: true,
},
});
}
8 changes: 4 additions & 4 deletions src/datasources/vector/components/VectorQueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export class VectorQueryEditor extends PureComponent<Props, State> {
format: FORMAT_OPTIONS.find(option => option.value === query.format) ?? FORMAT_OPTIONS[0],
legendFormat: query.legendFormat,
options: {
rateConversation: query.options.rateConversation,
timeUtilizationConversation: query.options.rateConversation,
rateConversion: query.options.rateConversion,
timeUtilizationConversion: query.options.rateConversion,
},
url: query.url,
hostspec: query.hostspec,
Expand Down Expand Up @@ -78,8 +78,8 @@ export class VectorQueryEditor extends PureComponent<Props, State> {
format: this.state.format.value as TargetFormat,
legendFormat: this.state.legendFormat,
options: {
rateConversation: this.state.options.rateConversation,
timeUtilizationConversation: this.state.options.rateConversation,
rateConversion: this.state.options.rateConversion,
timeUtilizationConversion: this.state.options.rateConversion,
},
url: this.state.url,
hostspec: this.state.hostspec,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ grafana.dashboard.new(
datasource='$datasource',
)
.addTargets([
{ expr: 'mssql.os_wait_stats.wait_time', format: 'time_series', legendFormat: '$instance', options: { timeUtilizationConversation: false } },
{ expr: 'mssql.os_wait_stats.wait_time', format: 'time_series', legendFormat: '$instance', options: { timeUtilizationConversion: false } },
]), gridPos={
x: 12,
y: 88,
Expand Down
2 changes: 1 addition & 1 deletion src/datasources/vector/datasource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('PCP Vector', () => {
datasource = new PCPVectorDataSource(instanceSettings as any);
});

it('should poll disk.dev.read, perform rate conversation and return the result', async () => {
it('should poll disk.dev.read, perform rate conversion and return the result', async () => {
const queries = [ds.query()];
let response = await datasource.query(grafana.dataQueryRequest(queries));
expect(response).toEqual({ data: [] });
Expand Down
4 changes: 2 additions & 2 deletions src/datasources/vector/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export const defaultVectorQuery: VectorQuery & Optional<PmapiQuery, 'url' | 'hos
expr: '',
format: TargetFormat.TimeSeries,
options: {
rateConversation: true,
timeUtilizationConversation: true,
rateConversion: true,
timeUtilizationConversion: true,
},
};

Expand Down

0 comments on commit f07b767

Please sign in to comment.