-
Notifications
You must be signed in to change notification settings - Fork 8.3k
/
Copy pathplugin.tsx
106 lines (90 loc) · 2.76 KB
/
plugin.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { CoreStart } from '@kbn/core/public';
import {
LogsLocatorDefinition,
NodeLogsLocatorDefinition,
TraceLogsLocatorDefinition,
} from '../common/locators';
import { createLogAIAssistant, createLogsAIAssistantRenderer } from './components/log_ai_assistant';
import { createLogsOverview } from './components/logs_overview';
import { LogViewsService } from './services/log_views';
import {
LogsSharedClientCoreSetup,
LogsSharedClientPluginClass,
LogsSharedClientSetupDeps,
LogsSharedClientStartDeps,
} from './types';
export class LogsSharedPlugin implements LogsSharedClientPluginClass {
private logViews: LogViewsService;
constructor() {
this.logViews = new LogViewsService();
}
public setup(_: LogsSharedClientCoreSetup, pluginsSetup: LogsSharedClientSetupDeps) {
const logViews = this.logViews.setup();
const logsLocator = pluginsSetup.share.url.locators.create(
new LogsLocatorDefinition(pluginsSetup.share.url.locators)
);
const nodeLogsLocator = pluginsSetup.share.url.locators.create(
new NodeLogsLocatorDefinition(pluginsSetup.share.url.locators)
);
const traceLogsLocator = pluginsSetup.share.url.locators.create(
new TraceLogsLocatorDefinition(pluginsSetup.share.url.locators)
);
const locators = {
logsLocator,
nodeLogsLocator,
traceLogsLocator,
};
return { logViews, locators };
}
public start(core: CoreStart, plugins: LogsSharedClientStartDeps) {
const { http, settings } = core;
const {
charts,
data,
dataViews,
discoverShared,
logsDataAccess,
observabilityAIAssistant,
share,
} = plugins;
const logViews = this.logViews.start({
http,
dataViews,
logSourcesService: logsDataAccess.services.logSourcesService,
search: data.search,
});
const LogsOverview = createLogsOverview({
charts,
logsDataAccess,
search: data.search.search,
searchSource: data.search.searchSource,
uiSettings: settings,
share,
dataViews,
embeddable: plugins.embeddable,
});
if (!observabilityAIAssistant) {
return {
logViews,
LogsOverview,
};
}
const LogAIAssistant = createLogAIAssistant({ observabilityAIAssistant });
discoverShared.features.registry.register({
id: 'observability-logs-ai-assistant',
render: createLogsAIAssistantRenderer(LogAIAssistant),
});
return {
logViews,
LogAIAssistant,
LogsOverview,
};
}
public stop() {}
}