mirror of
https://github.com/grafana/grafana.git
synced 2024-11-24 09:50:29 -06:00
Remove fire text in Phlare ds (#59484)
* Renames * Rename to phlareql * Go renames
This commit is contained in:
parent
bba42b113c
commit
b12b5ed92f
@ -24,7 +24,7 @@ const queryTypeProfile = "profile"
|
||||
const queryTypeMetrics = "metrics"
|
||||
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 {
|
||||
var qm queryModel
|
||||
response := backend.DataResponse{}
|
||||
@ -97,7 +97,7 @@ type CustomMeta struct {
|
||||
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
|
||||
// tree back.
|
||||
func responseToDataFrames(resp *connect.Response[v1alpha1.QueryResponse]) *data.Frame {
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
"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
|
||||
// runtime. In this example datasource instance implements backend.QueryDataHandler,
|
||||
// backend.CheckHealthHandler, backend.StreamHandler interfaces. Plugin should not
|
||||
|
@ -35,7 +35,7 @@ const (
|
||||
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 {
|
||||
var qm queryModel
|
||||
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
|
||||
// tree back.
|
||||
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
|
||||
// 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 {
|
||||
tree := &ProfileTree{
|
||||
Start: 0,
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
"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
|
||||
// runtime. In this example datasource instance implements backend.QueryDataHandler,
|
||||
// backend.CheckHealthHandler, backend.StreamHandler interfaces. Plugin should not
|
||||
|
@ -3,9 +3,9 @@ import React from 'react';
|
||||
import { DataSourcePluginOptionsEditorProps } from '@grafana/data';
|
||||
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) => {
|
||||
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>
|
||||
|
@ -2,10 +2,9 @@ import { css } from '@emotion/css';
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { useLatest } from 'react-use';
|
||||
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { CodeEditor, Monaco, useStyles2, monacoTypes } from '@grafana/ui';
|
||||
|
||||
import { languageDefinition } from '../fireql';
|
||||
import { languageDefinition } from '../phlareql';
|
||||
import { SeriesMessage } from '../types';
|
||||
|
||||
import { CompletionProvider } from './autocomplete';
|
||||
@ -54,7 +53,7 @@ export function LabelsEditor(props: Props) {
|
||||
bottom: 6,
|
||||
},
|
||||
}}
|
||||
onBeforeEditorMount={ensureFireQL}
|
||||
onBeforeEditorMount={ensurePhlareQL}
|
||||
onEditorDidMount={(editor, monaco) => {
|
||||
setupAutocompleteFn(editor, monaco);
|
||||
|
||||
@ -122,12 +121,12 @@ function useAutocomplete(series?: SeriesMessage) {
|
||||
}
|
||||
|
||||
// we must only run the setup code once
|
||||
let fireqlSetupDone = false;
|
||||
const langId = 'fireql';
|
||||
let phlareqlSetupDone = false;
|
||||
const langId = 'phlareql';
|
||||
|
||||
function ensureFireQL(monaco: Monaco) {
|
||||
if (fireqlSetupDone === false) {
|
||||
fireqlSetupDone = true;
|
||||
function ensurePhlareQL(monaco: Monaco) {
|
||||
if (phlareqlSetupDone === false) {
|
||||
phlareqlSetupDone = true;
|
||||
const { aliases, extensions, mimetypes, def } = languageDefinition;
|
||||
monaco.languages.register({ id: langId, aliases, extensions, mimetypes });
|
||||
monaco.languages.setMonarchTokensProvider(langId, def.language);
|
||||
@ -135,7 +134,7 @@ function ensureFireQL(monaco: Monaco) {
|
||||
}
|
||||
}
|
||||
|
||||
const getStyles = (theme: GrafanaTheme2) => {
|
||||
const getStyles = () => {
|
||||
return {
|
||||
queryField: css`
|
||||
flex: 1;
|
||||
|
@ -5,7 +5,7 @@ import React from 'react';
|
||||
|
||||
import { CoreApp, PluginType } from '@grafana/data';
|
||||
|
||||
import { FireDataSource } from '../datasource';
|
||||
import { PhlareDataSource } from '../datasource';
|
||||
import { ProfileTypeMessage } from '../types';
|
||||
|
||||
import { Props, QueryEditor } from './QueryEditor';
|
||||
@ -44,7 +44,7 @@ async function openOptions() {
|
||||
|
||||
function setup(options: { props: Partial<Props> } = { props: {} }) {
|
||||
const onChange = jest.fn();
|
||||
const ds = new FireDataSource({
|
||||
const ds = new PhlareDataSource({
|
||||
name: 'test',
|
||||
uid: 'test',
|
||||
type: PluginType.datasource,
|
||||
|
@ -5,15 +5,15 @@ import { useAsync } from 'react-use';
|
||||
import { CoreApp, QueryEditorProps } from '@grafana/data';
|
||||
import { ButtonCascader, CascaderOption } from '@grafana/ui';
|
||||
|
||||
import { FireDataSource } from '../datasource';
|
||||
import { defaultQuery, FireDataSourceOptions, ProfileTypeMessage, Query } from '../types';
|
||||
import { PhlareDataSource } from '../datasource';
|
||||
import { defaultQuery, PhlareDataSourceOptions, ProfileTypeMessage, Query } from '../types';
|
||||
|
||||
import { EditorRow } from './EditorRow';
|
||||
import { EditorRows } from './EditorRows';
|
||||
import { LabelsEditor } from './LabelsEditor';
|
||||
import { QueryOptions } from './QueryOptions';
|
||||
|
||||
export type Props = QueryEditorProps<FireDataSource, Query, FireDataSourceOptions>;
|
||||
export type Props = QueryEditorProps<PhlareDataSource, Query, PhlareDataSourceOptions>;
|
||||
|
||||
export function QueryEditor(props: Props) {
|
||||
const profileTypes = useProfileTypes(props.datasource);
|
||||
@ -91,7 +91,7 @@ function useCascaderOptions(profileTypes: ProfileTypeMessage[]) {
|
||||
}, [profileTypes]);
|
||||
}
|
||||
|
||||
function useProfileTypes(datasource: FireDataSource) {
|
||||
function useProfileTypes(datasource: PhlareDataSource) {
|
||||
const [profileTypes, setProfileTypes] = useState<ProfileTypeMessage[]>([]);
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
|
@ -6,7 +6,7 @@ import { SeriesMessage } from '../types';
|
||||
* Class that implements CompletionItemProvider interface and allows us to provide suggestion for the Monaco
|
||||
* 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.
|
||||
*/
|
||||
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.
|
||||
* 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.
|
||||
* @param text
|
||||
* @param offset
|
||||
|
@ -4,10 +4,10 @@ import { DataQueryRequest, DataQueryResponse, DataSourceInstanceSettings } from
|
||||
import { DataSourceWithBackend } from '@grafana/runtime';
|
||||
|
||||
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> {
|
||||
constructor(instanceSettings: DataSourceInstanceSettings<FireDataSourceOptions>) {
|
||||
export class PhlareDataSource extends DataSourceWithBackend<Query, PhlareDataSourceOptions> {
|
||||
constructor(instanceSettings: DataSourceInstanceSettings<PhlareDataSourceOptions>) {
|
||||
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 { QueryEditor } from './QueryEditor/QueryEditor';
|
||||
import { FireDataSource } from './datasource';
|
||||
import { Query, FireDataSourceOptions } from './types';
|
||||
import { PhlareDataSource } from './datasource';
|
||||
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)
|
||||
.setQueryEditor(QueryEditor);
|
||||
|
12
public/app/plugins/datasource/phlare/phlareql/index.ts
Normal file
12
public/app/plugins/datasource/phlare/phlareql/index.ts
Normal file
@ -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 = {
|
||||
ignoreCase: false,
|
||||
defaultToken: '',
|
||||
tokenPostfix: '.fireql',
|
||||
tokenPostfix: '.phlareql',
|
||||
|
||||
keywords: [],
|
||||
operators: [],
|
@ -27,6 +27,6 @@ export const defaultQuery: Partial<Query> = {
|
||||
/**
|
||||
* These are options configured for each DataSource instance.
|
||||
*/
|
||||
export interface FireDataSourceOptions extends DataSourceJsonData {
|
||||
export interface PhlareDataSourceOptions extends DataSourceJsonData {
|
||||
minStep?: string;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user