grafana/public/app/plugins/datasource/parca/datasource.ts
Andrej Ocenas 0845ac2f53
Profiling: Add Phlare and Parca datasources (#57809)
* Add phlare datasource

* Rename

* Add parca

* Add self field to parca

* Make sure phlare works with add to dashboard flow

* Add profiling category and hide behind feature flag

* Update description and logos

* Update phlare icon

* Cleanup logging

* Clean up logging

* Fix for shift+enter

* onRunQuery to set label

* Update type naming

* Fix lint

* Fix test and quality issues

Co-authored-by: Joey Tawadrous <joey.tawadrous@grafana.com>
2022-10-28 13:33:37 +02:00

34 lines
1.1 KiB
TypeScript

import { Observable, of } from 'rxjs';
import { DataQueryRequest, DataQueryResponse, DataSourceInstanceSettings } from '@grafana/data';
import { DataSourceWithBackend } from '@grafana/runtime';
import { ParcaDataSourceOptions, Query, ProfileTypeMessage } from './types';
export class ParcaDataSource extends DataSourceWithBackend<Query, ParcaDataSourceOptions> {
constructor(instanceSettings: DataSourceInstanceSettings<ParcaDataSourceOptions>) {
super(instanceSettings);
}
query(request: DataQueryRequest<Query>): Observable<DataQueryResponse> {
if (!request.targets.every((q) => q.profileTypeId)) {
// When changing data source in explore, firs query can be sent without filled in profileTypeId
return of({ data: [] });
}
return super.query(request);
}
async getProfileTypes(): Promise<ProfileTypeMessage[]> {
return await super.getResource('profileTypes');
}
async getLabelNames(): Promise<string[]> {
return await super.getResource('labelNames');
}
async getLabelValues(labelName: string): Promise<string[]> {
return await super.getResource('labelValues', { label: labelName });
}
}