-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Observability] Create context container to enable Observability plug…
…in registry function (#68642) * creating observability context registry * adding registryContext * addressing PR comments * addressing PR comments * adding context to registry provider * adding obs own registry * refactoring * refactoring * fixing types * removing apm code Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
4ce3702
commit 437f9f6
Showing
7 changed files
with
89 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { FetchData, HasData } from './typings/data_handler'; | ||
import { ObservabilityApp } from '../typings/common'; | ||
|
||
interface DataHandler { | ||
fetchData: FetchData; | ||
hasData: HasData; | ||
} | ||
|
||
const dataHandlers: Partial<Record<ObservabilityApp, DataHandler>> = {}; | ||
|
||
export type RegisterDataHandler = (params: { appName: ObservabilityApp } & DataHandler) => void; | ||
export const registerDataHandler: RegisterDataHandler = ({ appName, fetchData, hasData }) => { | ||
dataHandlers[appName] = { fetchData, hasData }; | ||
}; | ||
|
||
export function getDataHandler(appName: ObservabilityApp): DataHandler | undefined { | ||
return dataHandlers[appName]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
x-pack/plugins/observability/public/typings/data_handler/index.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
interface Stat { | ||
label: string; | ||
value: string; | ||
color?: string; | ||
} | ||
|
||
export interface Coordinates { | ||
x: number; | ||
y?: number; | ||
} | ||
|
||
interface Series { | ||
label: string; | ||
coordinates: Coordinates[]; | ||
color?: string; | ||
key?: string; | ||
} | ||
|
||
interface FetchDataResponse { | ||
title: string; | ||
appLink: string; | ||
stats: Stat[]; | ||
series: Series[]; | ||
} | ||
interface FetchDataParams { | ||
// The start timestamp in milliseconds of the queried time interval | ||
startTime: string; | ||
// The end timestamp in milliseconds of the queried time interval | ||
endTime: string; | ||
// The aggregation bucket size in milliseconds if applicable to the data source | ||
bucketSize: string; | ||
} | ||
|
||
export type FetchData = (fetchDataParams: FetchDataParams) => Promise<FetchDataResponse>; | ||
|
||
export type HasData = () => Promise<boolean>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters