Remove fire text in Phlare ds (#59484)

* Renames

* Rename to phlareql

* Go renames
pull/59604/head
Joey Tawadrous 3 years ago committed by GitHub
parent bba42b113c
commit b12b5ed92f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      pkg/tsdb/parca/query.go
  2. 2
      pkg/tsdb/parca/service.go
  3. 6
      pkg/tsdb/phlare/query.go
  4. 2
      pkg/tsdb/phlare/service.go
  5. 6
      public/app/plugins/datasource/phlare/ConfigEditor.tsx
  6. 17
      public/app/plugins/datasource/phlare/QueryEditor/LabelsEditor.tsx
  7. 4
      public/app/plugins/datasource/phlare/QueryEditor/QueryEditor.test.tsx
  8. 8
      public/app/plugins/datasource/phlare/QueryEditor/QueryEditor.tsx
  9. 4
      public/app/plugins/datasource/phlare/QueryEditor/autocomplete.ts
  10. 6
      public/app/plugins/datasource/phlare/datasource.ts
  11. 12
      public/app/plugins/datasource/phlare/fireql/index.ts
  12. 6
      public/app/plugins/datasource/phlare/module.ts
  13. 12
      public/app/plugins/datasource/phlare/phlareql/index.ts
  14. 2
      public/app/plugins/datasource/phlare/phlareql/phlareql.ts
  15. 2
      public/app/plugins/datasource/phlare/types.ts

@ -24,7 +24,7 @@ const queryTypeProfile = "profile"
const queryTypeMetrics = "metrics" const queryTypeMetrics = "metrics"
const queryTypeBoth = "both" const queryTypeBoth = "both"
// query processes single Fire query transforming the response to data.Frame packaged in DataResponse // query processes single Parca query transforming the response to data.Frame packaged in DataResponse
func (d *ParcaDatasource) query(ctx context.Context, pCtx backend.PluginContext, query backend.DataQuery) backend.DataResponse { func (d *ParcaDatasource) query(ctx context.Context, pCtx backend.PluginContext, query backend.DataQuery) backend.DataResponse {
var qm queryModel var qm queryModel
response := backend.DataResponse{} response := backend.DataResponse{}
@ -97,7 +97,7 @@ type CustomMeta struct {
ProfileTypeID string ProfileTypeID string
} }
// responseToDataFrames turns fire response to data.Frame. We encode the data into a nested set format where we have // responseToDataFrames turns Parca response to data.Frame. We encode the data into a nested set format where we have
// [level, value, label] columns and by ordering the items in a depth first traversal order we can recreate the whole // [level, value, label] columns and by ordering the items in a depth first traversal order we can recreate the whole
// tree back. // tree back.
func responseToDataFrames(resp *connect.Response[v1alpha1.QueryResponse]) *data.Frame { func responseToDataFrames(resp *connect.Response[v1alpha1.QueryResponse]) *data.Frame {

@ -10,7 +10,7 @@ import (
"github.com/grafana/grafana/pkg/infra/log" "github.com/grafana/grafana/pkg/infra/log"
) )
// Make sure FireDatasource implements required interfaces. This is important to do // Make sure ParcaDatasource implements required interfaces. This is important to do
// since otherwise we will only get a not implemented error response from plugin in // since otherwise we will only get a not implemented error response from plugin in
// runtime. In this example datasource instance implements backend.QueryDataHandler, // runtime. In this example datasource instance implements backend.QueryDataHandler,
// backend.CheckHealthHandler, backend.StreamHandler interfaces. Plugin should not // backend.CheckHealthHandler, backend.StreamHandler interfaces. Plugin should not

@ -35,7 +35,7 @@ const (
queryTypeBoth = "both" queryTypeBoth = "both"
) )
// query processes single Fire query transforming the response to data.Frame packaged in DataResponse // query processes single Phlare query transforming the response to data.Frame packaged in DataResponse
func (d *PhlareDatasource) query(ctx context.Context, pCtx backend.PluginContext, query backend.DataQuery) backend.DataResponse { func (d *PhlareDatasource) query(ctx context.Context, pCtx backend.PluginContext, query backend.DataQuery) backend.DataResponse {
var qm queryModel var qm queryModel
response := backend.DataResponse{} response := backend.DataResponse{}
@ -121,7 +121,7 @@ func makeRequest(qm queryModel, query backend.DataQuery) *connect.Request[querie
} }
} }
// responseToDataFrames turns fire response to data.Frame. We encode the data into a nested set format where we have // responseToDataFrames turns Phlare response to data.Frame. We encode the data into a nested set format where we have
// [level, value, label] columns and by ordering the items in a depth first traversal order we can recreate the whole // [level, value, label] columns and by ordering the items in a depth first traversal order we can recreate the whole
// tree back. // tree back.
func responseToDataFrames(resp *connect.Response[querierv1.SelectMergeStacktracesResponse], profileTypeID string) *data.Frame { func responseToDataFrames(resp *connect.Response[querierv1.SelectMergeStacktracesResponse], profileTypeID string) *data.Frame {
@ -154,7 +154,7 @@ type ProfileTree struct {
} }
// levelsToTree converts flamebearer format into a tree. This is needed to then convert it into nested set format // levelsToTree converts flamebearer format into a tree. This is needed to then convert it into nested set format
// dataframe. This should be temporary, and ideally we should get some sort of tree struct directly from Fire API. // dataframe. This should be temporary, and ideally we should get some sort of tree struct directly from Phlare API.
func levelsToTree(levels []*querierv1.Level, names []string) *ProfileTree { func levelsToTree(levels []*querierv1.Level, names []string) *ProfileTree {
tree := &ProfileTree{ tree := &ProfileTree{
Start: 0, Start: 0,

@ -10,7 +10,7 @@ import (
"github.com/grafana/grafana/pkg/infra/log" "github.com/grafana/grafana/pkg/infra/log"
) )
// Make sure FireDatasource implements required interfaces. This is important to do // Make sure PhlareDatasource implements required interfaces. This is important to do
// since otherwise we will only get a not implemented error response from plugin in // since otherwise we will only get a not implemented error response from plugin in
// runtime. In this example datasource instance implements backend.QueryDataHandler, // runtime. In this example datasource instance implements backend.QueryDataHandler,
// backend.CheckHealthHandler, backend.StreamHandler interfaces. Plugin should not // backend.CheckHealthHandler, backend.StreamHandler interfaces. Plugin should not

@ -3,9 +3,9 @@ import React from 'react';
import { DataSourcePluginOptionsEditorProps } from '@grafana/data'; import { DataSourcePluginOptionsEditorProps } from '@grafana/data';
import { DataSourceHttpSettings, EventsWithValidation, LegacyForms, regexValidation } from '@grafana/ui'; import { DataSourceHttpSettings, EventsWithValidation, LegacyForms, regexValidation } from '@grafana/ui';
import { FireDataSourceOptions } from './types'; import { PhlareDataSourceOptions } from './types';
interface Props extends DataSourcePluginOptionsEditorProps<FireDataSourceOptions> {} interface Props extends DataSourcePluginOptionsEditorProps<PhlareDataSourceOptions> {}
export const ConfigEditor = (props: Props) => { export const ConfigEditor = (props: Props) => {
const { options, onOptionsChange } = props; const { options, onOptionsChange } = props;
@ -51,7 +51,7 @@ export const ConfigEditor = (props: Props) => {
}} }}
/> />
} }
tooltip="Minimal step used for metric query. Should be the same or higher as the scrape interval setting in the Fire database." tooltip="Minimal step used for metric query. Should be the same or higher as the scrape interval setting in the Phlare database."
/> />
</div> </div>
</div> </div>

@ -2,10 +2,9 @@ import { css } from '@emotion/css';
import React, { useEffect, useRef } from 'react'; import React, { useEffect, useRef } from 'react';
import { useLatest } from 'react-use'; import { useLatest } from 'react-use';
import { GrafanaTheme2 } from '@grafana/data';
import { CodeEditor, Monaco, useStyles2, monacoTypes } from '@grafana/ui'; import { CodeEditor, Monaco, useStyles2, monacoTypes } from '@grafana/ui';
import { languageDefinition } from '../fireql'; import { languageDefinition } from '../phlareql';
import { SeriesMessage } from '../types'; import { SeriesMessage } from '../types';
import { CompletionProvider } from './autocomplete'; import { CompletionProvider } from './autocomplete';
@ -54,7 +53,7 @@ export function LabelsEditor(props: Props) {
bottom: 6, bottom: 6,
}, },
}} }}
onBeforeEditorMount={ensureFireQL} onBeforeEditorMount={ensurePhlareQL}
onEditorDidMount={(editor, monaco) => { onEditorDidMount={(editor, monaco) => {
setupAutocompleteFn(editor, monaco); setupAutocompleteFn(editor, monaco);
@ -122,12 +121,12 @@ function useAutocomplete(series?: SeriesMessage) {
} }
// we must only run the setup code once // we must only run the setup code once
let fireqlSetupDone = false; let phlareqlSetupDone = false;
const langId = 'fireql'; const langId = 'phlareql';
function ensureFireQL(monaco: Monaco) { function ensurePhlareQL(monaco: Monaco) {
if (fireqlSetupDone === false) { if (phlareqlSetupDone === false) {
fireqlSetupDone = true; phlareqlSetupDone = true;
const { aliases, extensions, mimetypes, def } = languageDefinition; const { aliases, extensions, mimetypes, def } = languageDefinition;
monaco.languages.register({ id: langId, aliases, extensions, mimetypes }); monaco.languages.register({ id: langId, aliases, extensions, mimetypes });
monaco.languages.setMonarchTokensProvider(langId, def.language); monaco.languages.setMonarchTokensProvider(langId, def.language);
@ -135,7 +134,7 @@ function ensureFireQL(monaco: Monaco) {
} }
} }
const getStyles = (theme: GrafanaTheme2) => { const getStyles = () => {
return { return {
queryField: css` queryField: css`
flex: 1; flex: 1;

@ -5,7 +5,7 @@ import React from 'react';
import { CoreApp, PluginType } from '@grafana/data'; import { CoreApp, PluginType } from '@grafana/data';
import { FireDataSource } from '../datasource'; import { PhlareDataSource } from '../datasource';
import { ProfileTypeMessage } from '../types'; import { ProfileTypeMessage } from '../types';
import { Props, QueryEditor } from './QueryEditor'; import { Props, QueryEditor } from './QueryEditor';
@ -44,7 +44,7 @@ async function openOptions() {
function setup(options: { props: Partial<Props> } = { props: {} }) { function setup(options: { props: Partial<Props> } = { props: {} }) {
const onChange = jest.fn(); const onChange = jest.fn();
const ds = new FireDataSource({ const ds = new PhlareDataSource({
name: 'test', name: 'test',
uid: 'test', uid: 'test',
type: PluginType.datasource, type: PluginType.datasource,

@ -5,15 +5,15 @@ import { useAsync } from 'react-use';
import { CoreApp, QueryEditorProps } from '@grafana/data'; import { CoreApp, QueryEditorProps } from '@grafana/data';
import { ButtonCascader, CascaderOption } from '@grafana/ui'; import { ButtonCascader, CascaderOption } from '@grafana/ui';
import { FireDataSource } from '../datasource'; import { PhlareDataSource } from '../datasource';
import { defaultQuery, FireDataSourceOptions, ProfileTypeMessage, Query } from '../types'; import { defaultQuery, PhlareDataSourceOptions, ProfileTypeMessage, Query } from '../types';
import { EditorRow } from './EditorRow'; import { EditorRow } from './EditorRow';
import { EditorRows } from './EditorRows'; import { EditorRows } from './EditorRows';
import { LabelsEditor } from './LabelsEditor'; import { LabelsEditor } from './LabelsEditor';
import { QueryOptions } from './QueryOptions'; import { QueryOptions } from './QueryOptions';
export type Props = QueryEditorProps<FireDataSource, Query, FireDataSourceOptions>; export type Props = QueryEditorProps<PhlareDataSource, Query, PhlareDataSourceOptions>;
export function QueryEditor(props: Props) { export function QueryEditor(props: Props) {
const profileTypes = useProfileTypes(props.datasource); const profileTypes = useProfileTypes(props.datasource);
@ -91,7 +91,7 @@ function useCascaderOptions(profileTypes: ProfileTypeMessage[]) {
}, [profileTypes]); }, [profileTypes]);
} }
function useProfileTypes(datasource: FireDataSource) { function useProfileTypes(datasource: PhlareDataSource) {
const [profileTypes, setProfileTypes] = useState<ProfileTypeMessage[]>([]); const [profileTypes, setProfileTypes] = useState<ProfileTypeMessage[]>([]);
useEffect(() => { useEffect(() => {
(async () => { (async () => {

@ -6,7 +6,7 @@ import { SeriesMessage } from '../types';
* Class that implements CompletionItemProvider interface and allows us to provide suggestion for the Monaco * Class that implements CompletionItemProvider interface and allows us to provide suggestion for the Monaco
* autocomplete system. * autocomplete system.
* *
* At this moment we just pass it all the labels/values we get from Fire backend later on we may do something a bit * At this moment we just pass it all the labels/values we get from Phlare backend later on we may do something a bit
* smarter if there will be lots of labels. * smarter if there will be lots of labels.
*/ */
export class CompletionProvider implements monacoTypes.languages.CompletionItemProvider { export class CompletionProvider implements monacoTypes.languages.CompletionItemProvider {
@ -169,7 +169,7 @@ const inLabelNameRegex = new RegExp(/[{,]\s*[a-zA-Z0-9_]*$/);
/** /**
* Figure out where is the cursor and what kind of suggestions are appropriate. * Figure out where is the cursor and what kind of suggestions are appropriate.
* As currently Fire handles just a simple {foo="bar", baz="zyx"} kind of values we can do with simple regex to figure * As currently Phlare handles just a simple {foo="bar", baz="zyx"} kind of values we can do with simple regex to figure
* out where we are with the cursor. * out where we are with the cursor.
* @param text * @param text
* @param offset * @param offset

@ -4,10 +4,10 @@ import { DataQueryRequest, DataQueryResponse, DataSourceInstanceSettings } from
import { DataSourceWithBackend } from '@grafana/runtime'; import { DataSourceWithBackend } from '@grafana/runtime';
import { normalizeQuery } from './QueryEditor/QueryEditor'; import { normalizeQuery } from './QueryEditor/QueryEditor';
import { FireDataSourceOptions, Query, ProfileTypeMessage, SeriesMessage } from './types'; import { PhlareDataSourceOptions, Query, ProfileTypeMessage, SeriesMessage } from './types';
export class FireDataSource extends DataSourceWithBackend<Query, FireDataSourceOptions> { export class PhlareDataSource extends DataSourceWithBackend<Query, PhlareDataSourceOptions> {
constructor(instanceSettings: DataSourceInstanceSettings<FireDataSourceOptions>) { constructor(instanceSettings: DataSourceInstanceSettings<PhlareDataSourceOptions>) {
super(instanceSettings); super(instanceSettings);
} }

@ -1,12 +0,0 @@
import { language, languageConfiguration } from './fireql';
export const languageDefinition = {
id: 'fireql',
extensions: ['.fireql'],
aliases: ['fire', 'fireql'],
mimetypes: [],
def: {
language,
languageConfiguration,
},
};

@ -2,9 +2,9 @@ import { DataSourcePlugin } from '@grafana/data';
import { ConfigEditor } from './ConfigEditor'; import { ConfigEditor } from './ConfigEditor';
import { QueryEditor } from './QueryEditor/QueryEditor'; import { QueryEditor } from './QueryEditor/QueryEditor';
import { FireDataSource } from './datasource'; import { PhlareDataSource } from './datasource';
import { Query, FireDataSourceOptions } from './types'; import { Query, PhlareDataSourceOptions } from './types';
export const plugin = new DataSourcePlugin<FireDataSource, Query, FireDataSourceOptions>(FireDataSource) export const plugin = new DataSourcePlugin<PhlareDataSource, Query, PhlareDataSourceOptions>(PhlareDataSource)
.setConfigEditor(ConfigEditor) .setConfigEditor(ConfigEditor)
.setQueryEditor(QueryEditor); .setQueryEditor(QueryEditor);

@ -0,0 +1,12 @@
import { language, languageConfiguration } from './phlareql';
export const languageDefinition = {
id: 'phlareql',
extensions: ['.phlareql'],
aliases: ['phlare', 'phlareql'],
mimetypes: [],
def: {
language,
languageConfiguration,
},
};

@ -20,7 +20,7 @@ export const languageConfiguration: languages.LanguageConfiguration = {
export const language: languages.IMonarchLanguage = { export const language: languages.IMonarchLanguage = {
ignoreCase: false, ignoreCase: false,
defaultToken: '', defaultToken: '',
tokenPostfix: '.fireql', tokenPostfix: '.phlareql',
keywords: [], keywords: [],
operators: [], operators: [],

@ -27,6 +27,6 @@ export const defaultQuery: Partial<Query> = {
/** /**
* These are options configured for each DataSource instance. * These are options configured for each DataSource instance.
*/ */
export interface FireDataSourceOptions extends DataSourceJsonData { export interface PhlareDataSourceOptions extends DataSourceJsonData {
minStep?: string; minStep?: string;
} }

Loading…
Cancel
Save