logs: send more info to getLogRowContext (#52130) (#52333)

(cherry picked from commit 1d3cd0103e)

Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2022-07-15 10:15:51 -04:00
committed by GitHub
co-authored by Gábor Farkas
parent 2e1bc52ae9
commit d7cef15a60
2 changed files with 10 additions and 4 deletions
+3 -2
View File
@@ -149,13 +149,14 @@ export enum LogsDedupDescription {
* Data sources that allow showing context rows around the provided LowRowModel should implement this method.
* This will enable "context" button in Logs Panel.
*/
export interface DataSourceWithLogsContextSupport {
export interface DataSourceWithLogsContextSupport<TQuery extends DataQuery = DataQuery> {
/**
* Retrieve context for a given log row
*/
getLogRowContext: <TContextQueryOptions extends {}>(
row: LogRowModel,
options?: TContextQueryOptions
options?: TContextQueryOptions,
query?: TQuery
) => Promise<DataQueryResponse>;
/**
@@ -44,10 +44,15 @@ class LogsContainer extends PureComponent<LogsContainerProps> {
};
getLogRowContext = async (row: LogRowModel, options?: any): Promise<any> => {
const { datasourceInstance } = this.props;
const { datasourceInstance, logsQueries } = this.props;
if (hasLogsContextSupport(datasourceInstance)) {
return datasourceInstance.getLogRowContext(row, options);
// we need to find the query, and we need to be very sure that
// it's a query from this datasource
const query = (logsQueries ?? []).find(
(q) => q.refId === row.dataFrame.refId && q.datasource != null && q.datasource.type === datasourceInstance.type
);
return datasourceInstance.getLogRowContext(row, options, query);
}
return [];