-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added script switch button to the query panel. #41
Conversation
Signed-off-by: Taras Priadka <tpriadka@pixielabs.ai>
src/pxl_scripts.tsx
Outdated
}; | ||
|
||
export const options = [ | ||
{ label: 'scratch-pad' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would Custom Query
be more descriptive than Scratch Pad
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going with the same name as on Pixie UI
. Can change to Custom Query
if that is more descriptive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make it Custom Query, I think that is more clear to the Grafana audience
Signed-off-by: Taras Priadka <tpriadka@pixielabs.ai>
src/pxl_scripts.tsx
Outdated
px.display(per_ns_df['time_', 'service', 'request_throughput']) | ||
`, | ||
|
||
'http-data-filtered': String.raw`# Copyright 2018- The Pixie Authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove the copyright in these
src/pxl_scripts.tsx
Outdated
}; | ||
|
||
export const options = [ | ||
{ label: 'scratch-pad' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make it Custom Query, I think that is more clear to the Grafana audience
src/pxl_scripts.tsx
Outdated
'scratch-pad': '', | ||
example: String.raw` | ||
# Import Pixie's module for querying data. | ||
import px |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put some links to docs.px.dev in the comments at the top of this script, perhaps links to the Grafana tutorial and also how to write your own PxL script
src/pxl_scripts.tsx
Outdated
px.display(per_ns_df['time_', 'service', 'request_throughput']) | ||
`, | ||
|
||
'http-data-filtered': String.raw`# Copyright 2018- The Pixie Authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's have the title of this one be
Raw HTTP Events (Long Format)
So it's clear that it shouldn't be used with a timeseries and more clear about what the datasource is
src/pxl_scripts.tsx
Outdated
#df = df[px.contains(df.pod, 'catalogue')] | ||
#df = df[df.req_path == '/healthz'] | ||
|
||
# Avoid conversion to long format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this isn't your comment, but I believe this is actually avoiding the conversion to wide format, not the other way around: https://grafana.com/docs/grafana/latest/developers/plugins/data-frames/
src/pxl_scripts.tsx
Outdated
# Output the DataFrame | ||
px.display(df) | ||
`, | ||
'http-errors-per-service': String.raw` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename this to
HTTP Error Rate by Service (Wide Format)
Signed-off-by: Taras Priadka <tpriadka@pixielabs.ai>
Signed-off-by: Taras Priadka <tpriadka@pixielabs.ai>
src/query_editor.tsx
Outdated
@@ -33,12 +34,26 @@ export class QueryEditor extends PureComponent<Props> { | |||
onRunQuery(); | |||
} | |||
|
|||
onSelect(option: SelectableValue<number>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kartik is working on adding some more dropdowns (for example, for column selection, groupbys). Let's name this onSelect
something more specific to avoid confusion. Something like: onScriptSelect
.
src/pxl_scripts.tsx
Outdated
export const options = scriptsRaw.map((script: Script) => { | ||
return { | ||
label: script.name, | ||
description: script.description, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a nice, small follow-up PR is to figure out how to incorporate/show this description when you're looking through scripts in the dropdown. This is just a UI improvement thing though, so just a nice-to-have (and shouldn't be done in this PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already done through Grafana UI component. Additionally it can display images near the selections, but I don't think we need that.
src/pxl_scripts.tsx
Outdated
); | ||
|
||
// Construct options list which is injested by Select component in | ||
export const options = scriptsRaw.map((script: Script) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
options
is pretty vague here, so when it gets imported into query_editor.tsx
, it can be unclear what options
means, especially if there are potentially other dropdowns. Let's just rename this to scriptOptions
.
src/pxl_scripts.tsx
Outdated
const scriptsRaw: Script[] = [customQuery, exampleQuery, httpDataFiltered, httpErrorsPerService]; | ||
|
||
// Make a map for easier access of scripts | ||
export const scripts = new Map( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a general rule (only writing it once since it's the same thing elsewhere):
Even though TypeScript can often figure out the type of something for you, it's still a good idea to specify it explicitly when:
- The symbol is exported and isn't a primitive or otherwise trivial type
- The type may not be instantly obvious to the reader even if TypeScript inferred it correctly (this is clearly a
Map
, but I have to read surrounding code to realize it's actually aMap<string, Script>
and not aMap<string, string>
) - The contents of the object might be complex, and specifying the type will let the compiler tell you if you didn't fill it out properly.
In this specific case, export const scripts = new Map<string, Script>(...)
would make it nice and clear.
src/pxl_scripts.tsx
Outdated
export const scripts = new Map( | ||
scriptsRaw.map((script) => { | ||
return [script.name, script]; | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this is a good candidate for shorthand syntax.
scriptsRaw.map((script) => [script.name, script]);
src/pxl_scripts.tsx
Outdated
|
||
// Construct options list which is injested by Select component in | ||
export const options = scriptsRaw.map((script: Script) => { | ||
return { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: shorthand syntax also works for objects if you wrap them in parentheses, like this:
export const scriptOptions: Array<{ label: string, description: string }> = scriptsRaw.map((script) => ({
label: script.name,
description: script.description,
}));
Signed-off-by: Taras Priadka <tpriadka@pixielabs.ai>
Added a dropdown menu with some predefined scripts to choose from.
Signed-off-by: Taras Priadka tpriadka@pixielabs.ai