[8.x] Move storage adapter and traced ES client into dedicated package (#211761)

# Backport

This will backport the following commits from `main` to `8.x`:
- Move storage adapter and traced ES client into dedicated package
(#211578)](https://github.com/elastic/kibana/pull/211578)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Joe Reuter 2025-02-19 16:48:40 +01:00 committed by GitHub
parent e7769c9fe4
commit 20763c69b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
55 changed files with 264 additions and 119 deletions

2
.github/CODEOWNERS vendored
View file

@ -955,6 +955,7 @@ test/server_integration/plugins/status_plugin_a @elastic/kibana-core
test/server_integration/plugins/status_plugin_b @elastic/kibana-core
src/platform/packages/shared/kbn-std @elastic/kibana-core
packages/kbn-stdio-dev-helpers @elastic/kibana-operations
src/platform/packages/shared/kbn-storage-adapter @elastic/observability-ui
packages/kbn-storybook @elastic/kibana-operations
x-pack/solutions/observability/plugins/streams_app @simianhacker @flash1293 @dgieselaar
x-pack/solutions/observability/plugins/streams @simianhacker @flash1293 @dgieselaar
@ -990,6 +991,7 @@ src/platform/packages/private/kbn-timelion-grammar @elastic/kibana-visualization
src/platform/packages/shared/kbn-timerange @elastic/obs-ux-logs-team
src/platform/packages/private/kbn-tinymath @elastic/kibana-visualizations
packages/kbn-tooling-log @elastic/kibana-operations
src/platform/packages/shared/kbn-traced-es-client @elastic/observability-ui
x-pack/platform/plugins/private/transform @elastic/ml-ui
x-pack/platform/plugins/private/translations @elastic/kibana-localization
src/platform/packages/private/kbn-transpose-utils @elastic/kibana-visualizations

View file

@ -936,6 +936,7 @@
"@kbn/status-plugin-a-plugin": "link:test/server_integration/plugins/status_plugin_a",
"@kbn/status-plugin-b-plugin": "link:test/server_integration/plugins/status_plugin_b",
"@kbn/std": "link:src/platform/packages/shared/kbn-std",
"@kbn/storage-adapter": "link:src/platform/packages/shared/kbn-storage-adapter",
"@kbn/streams-app-plugin": "link:x-pack/solutions/observability/plugins/streams_app",
"@kbn/streams-plugin": "link:x-pack/solutions/observability/plugins/streams",
"@kbn/streams-schema": "link:x-pack/platform/packages/shared/kbn-streams-schema",
@ -957,6 +958,7 @@
"@kbn/timelion-grammar": "link:src/platform/packages/private/kbn-timelion-grammar",
"@kbn/timerange": "link:src/platform/packages/shared/kbn-timerange",
"@kbn/tinymath": "link:src/platform/packages/private/kbn-tinymath",
"@kbn/traced-es-client": "link:src/platform/packages/shared/kbn-traced-es-client",
"@kbn/transform-plugin": "link:x-pack/platform/plugins/private/transform",
"@kbn/translations-plugin": "link:x-pack/platform/plugins/private/translations",
"@kbn/transpose-utils": "link:src/platform/packages/private/kbn-transpose-utils",

View file

@ -1,9 +1,12 @@
/*
* 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.
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import type {
BulkRequest,
BulkResponse,
@ -151,6 +154,6 @@ export type StorageDocumentOf<TStorageSettings extends StorageSettings> = Storag
properties: TStorageSettings['schema']['properties'];
}> & { _id: string };
export { StorageIndexAdapter } from './index_adapter';
export { StorageIndexAdapter } from './src/index_adapter';
export { types } from './types';

View file

@ -0,0 +1,14 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../../../../..',
roots: ['<rootDir>/src/platform/packages/shared/kbn-storage-adapter'],
};

View file

@ -0,0 +1,14 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
module.exports = {
preset: '@kbn/test/jest_integration',
rootDir: '../../../../..',
roots: ['<rootDir>/src/platform/packages/shared/kbn-storage-adapter'],
};

View file

@ -0,0 +1,9 @@
{
"type": "shared-server",
"id": "@kbn/storage-adapter",
"owner": [
"@elastic/observability-ui"
],
"group": "platform",
"visibility": "shared"
}

View file

@ -0,0 +1,6 @@
{
"name": "@kbn/storage-adapter",
"private": true,
"version": "1.0.0",
"license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0"
}

View file

@ -0,0 +1,17 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import stringify from 'json-stable-stringify';
import objectHash from 'object-hash';
import { IndexStorageSettings } from '..';
export function getSchemaVersion(storage: IndexStorageSettings): string {
const version = objectHash(stringify(storage.schema.properties));
return version;
}

View file

@ -1,8 +1,10 @@
/*
* 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.
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import type {
@ -35,9 +37,9 @@ import {
StorageClientCleanResponse,
ApplicationDocument,
InternalIStorageClient,
} from '..';
} from '../..';
import { getSchemaVersion } from '../get_schema_version';
import { StorageMappingProperty } from '../types';
import { StorageMappingProperty } from '../../types';
function getAliasName(name: string) {
return name;

View file

@ -1,8 +1,10 @@
/*
* 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.
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import {
@ -16,7 +18,7 @@ import {
StorageClientIndexResponse,
StorageIndexAdapter,
type StorageSettings,
} from '../..';
} from '../../..';
import type { ElasticsearchClient, Logger } from '@kbn/core/server';
import { httpServerMock } from '@kbn/core/server/mocks';
import * as getSchemaVersionModule from '../../get_schema_version';

View file

@ -0,0 +1,24 @@
{
"extends": "../../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
"jest",
"node",
"react"
]
},
"include": [
"**/*.ts",
"**/*.tsx",
],
"exclude": [
"target/**/*"
],
"kbn_references": [
"@kbn/core",
"@kbn/es-types",
"@kbn/es-errors",
"@kbn/core-test-helpers-kbn-server",
]
}

View file

@ -1,8 +1,10 @@
/*
* 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.
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { MappingObjectProperty, MappingProperty } from '@elastic/elasticsearch/lib/api/types';

View file

@ -0,0 +1,4 @@
# Traced ES Client
This package provides a wrapper around the regular platform ES client which adds tracing information for better analysis.
Each operation can be given a custom name that shows up as a trace when instrumenting using APM.

View file

@ -0,0 +1,10 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export * from './src/create_traced_es_client';

View file

@ -0,0 +1,14 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
module.exports = {
preset: '@kbn/test',
rootDir: '../../../../..',
roots: ['<rootDir>/src/platform/packages/shared/kbn-traced-es-client'],
};

View file

@ -0,0 +1,9 @@
{
"type": "shared-server",
"id": "@kbn/traced-es-client",
"owner": [
"@elastic/observability-ui"
],
"group": "platform",
"visibility": "shared"
}

View file

@ -0,0 +1,6 @@
{
"name": "@kbn/traced-es-client",
"private": true,
"version": "1.0.0",
"license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0"
}

View file

@ -1,8 +1,10 @@
/*
* 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.
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import type {
@ -19,7 +21,7 @@ import type { ESSearchRequest, InferSearchResponseOf } from '@kbn/es-types';
import { Required, ValuesType } from 'utility-types';
import { DedotObject } from '@kbn/utility-types';
import { unflattenObject } from '@kbn/task-manager-plugin/server/metrics/lib';
import { esqlResultToPlainObjects } from '../esql_result_to_plain_objects';
import { esqlResultToPlainObjects } from './esql_result_to_plain_objects';
type SearchRequest = ESSearchRequest & {
index: string | string[];
@ -78,7 +80,7 @@ export type EsqlQueryResponse = UnparsedEsqlResponse | ParsedEsqlResponse;
* An Elasticsearch Client with a fully typed `search` method and built-in
* APM instrumentation.
*/
export interface ObservabilityElasticsearchClient {
export interface TracedElasticsearchClient {
search<TDocument = unknown, TSearchRequest extends SearchRequest = SearchRequest>(
operationName: string,
parameters: TSearchRequest
@ -108,7 +110,7 @@ export interface ObservabilityElasticsearchClient {
client: ElasticsearchClient;
}
export function createObservabilityEsClient({
export function createTracedEsClient({
client,
logger,
plugin,
@ -118,7 +120,7 @@ export function createObservabilityEsClient({
logger: Logger;
plugin?: string;
labels?: Record<string, string>;
}): ObservabilityElasticsearchClient {
}): TracedElasticsearchClient {
// wraps the ES calls in a named APM span for better analysis
// (otherwise it would just eg be a _search span)
const callWithLogger = <T>(

View file

@ -1,8 +1,10 @@
/*
* 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.
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import type { ESQLSearchResponse } from '@kbn/es-types';

View file

@ -1,8 +1,10 @@
/*
* 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.
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import type { ESQLSearchResponse } from '@kbn/es-types';

View file

@ -0,0 +1,25 @@
{
"extends": "../../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
"jest",
"node",
"react"
]
},
"include": [
"**/*.ts",
"**/*.tsx",
],
"exclude": [
"target/**/*"
],
"kbn_references": [
"@kbn/core",
"@kbn/es-types",
"@kbn/apm-utils",
"@kbn/utility-types",
"@kbn/task-manager-plugin",
]
}

View file

@ -1904,6 +1904,8 @@
"@kbn/std/*": ["src/platform/packages/shared/kbn-std/*"],
"@kbn/stdio-dev-helpers": ["packages/kbn-stdio-dev-helpers"],
"@kbn/stdio-dev-helpers/*": ["packages/kbn-stdio-dev-helpers/*"],
"@kbn/storage-adapter": ["src/platform/packages/shared/kbn-storage-adapter"],
"@kbn/storage-adapter/*": ["src/platform/packages/shared/kbn-storage-adapter/*"],
"@kbn/storybook": ["packages/kbn-storybook"],
"@kbn/storybook/*": ["packages/kbn-storybook/*"],
"@kbn/streams-app-plugin": ["x-pack/solutions/observability/plugins/streams_app"],
@ -1974,6 +1976,8 @@
"@kbn/tinymath/*": ["src/platform/packages/private/kbn-tinymath/*"],
"@kbn/tooling-log": ["packages/kbn-tooling-log"],
"@kbn/tooling-log/*": ["packages/kbn-tooling-log/*"],
"@kbn/traced-es-client": ["src/platform/packages/shared/kbn-traced-es-client"],
"@kbn/traced-es-client/*": ["src/platform/packages/shared/kbn-traced-es-client/*"],
"@kbn/transform-plugin": ["x-pack/platform/plugins/private/transform"],
"@kbn/transform-plugin/*": ["x-pack/platform/plugins/private/transform/*"],
"@kbn/translations-plugin": ["x-pack/platform/plugins/private/translations"],

View file

@ -15,7 +15,7 @@ import { findLast, pick } from 'lodash';
import moment from 'moment';
import { catchError, filter, from, map, mergeMap, Observable, of, switchMap } from 'rxjs';
import { ObservabilityAIAssistantClient } from '@kbn/observability-ai-assistant-plugin/server';
import { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client';
import { TracedElasticsearchClient } from '@kbn/traced-es-client';
import {
RCA_END_PROCESS_TOOL_NAME,
RCA_INVESTIGATE_ENTITY_TOOL_NAME,
@ -94,7 +94,7 @@ export function runRootCauseAnalysis({
end: number;
alertsClient: AlertsClient;
rulesClient: RulesClient;
esClient: ObservabilityElasticsearchClient;
esClient: TracedElasticsearchClient;
observabilityAIAssistantClient: ObservabilityAIAssistantClient;
indices: {
logs: string[];

View file

@ -15,7 +15,7 @@ import {
import { sortAndTruncateAnalyzedFields } from '@kbn/observability-utils-common/llm/log_analysis/sort_and_truncate_analyzed_fields';
import { analyzeDocuments } from '@kbn/observability-utils-server/entities/analyze_documents';
import { FieldPatternResultWithChanges } from '@kbn/observability-utils-server/entities/get_log_patterns';
import { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client';
import { TracedElasticsearchClient } from '@kbn/traced-es-client';
import { kqlQuery } from '@kbn/observability-utils-server/es/queries/kql_query';
import { rangeQuery } from '@kbn/observability-utils-server/es/queries/range_query';
import { chunk, isEmpty, isEqual } from 'lodash';
@ -202,7 +202,7 @@ export async function analyzeFetchedRelatedEntities({
}: {
connectorId: string;
inferenceClient: InferenceClient;
esClient: ObservabilityElasticsearchClient;
esClient: TracedElasticsearchClient;
start: number;
end: number;
searches: RelatedEntityKeywordSearch[];

View file

@ -11,7 +11,7 @@ import {
DocumentAnalysis,
TruncatedDocumentAnalysis,
} from '@kbn/observability-utils-common/llm/log_analysis/document_analysis';
import { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client';
import { TracedElasticsearchClient } from '@kbn/traced-es-client';
import { FieldPatternResultWithChanges } from '@kbn/observability-utils-server/entities/get_log_patterns';
import {
analyzeFetchedRelatedEntities,
@ -45,7 +45,7 @@ export async function findRelatedEntities({
start: number;
end: number;
index: string | string[];
esClient: ObservabilityElasticsearchClient;
esClient: TracedElasticsearchClient;
entity: Record<string, string>;
analysis: {
truncated: TruncatedDocumentAnalysis;

View file

@ -11,7 +11,7 @@ import { analyzeDocuments } from '@kbn/observability-utils-server/entities/analy
import { getDataStreamsForEntity } from '@kbn/observability-utils-server/entities/get_data_streams_for_entity';
import { getAlertsForEntity } from '@kbn/observability-utils-server/entities/signals/get_alerts_for_entity';
import { getSlosForEntity } from '@kbn/observability-utils-server/entities/signals/get_slos_for_entity';
import { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client';
import { TracedElasticsearchClient } from '@kbn/traced-es-client';
import { RootCauseAnalysisContext } from '../../types';
import { stringifySummaries } from '../../util/stringify_summaries';
import { analyzeLogPatterns } from '../analyze_log_patterns';
@ -251,7 +251,7 @@ async function analyzeDataStreamsForEntity({
end: number;
kuery: string;
dataStreams: string[];
esClient: ObservabilityElasticsearchClient;
esClient: TracedElasticsearchClient;
}) {
const analysis = await analyzeDocuments({
esClient,

View file

@ -17,7 +17,7 @@ import { Logger } from '@kbn/logging';
import { AlertsClient } from '@kbn/rule-registry-plugin/server';
import { RulesClient } from '@kbn/alerting-plugin/server';
import { ObservabilityAIAssistantClient } from '@kbn/observability-ai-assistant-plugin/server';
import { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client';
import { TracedElasticsearchClient } from '@kbn/traced-es-client';
import {
RCA_END_PROCESS_TOOL_NAME,
RCA_INVESTIGATE_ENTITY_TOOL_NAME,
@ -92,7 +92,7 @@ export interface RootCauseAnalysisContext {
inferenceClient: InferenceClient;
tokenLimit: number;
connectorId: string;
esClient: ObservabilityElasticsearchClient;
esClient: TracedElasticsearchClient;
alertsClient: AlertsClient;
rulesClient: RulesClient;
logger: Logger;

View file

@ -25,5 +25,6 @@
"@kbn/inference-common",
"@kbn/observability-ai-common",
"@kbn/observability-utils-server",
"@kbn/traced-es-client",
]
}

View file

@ -8,7 +8,7 @@
import { mapValues } from 'lodash';
import { mergeSampleDocumentsWithFieldCaps } from '@kbn/observability-utils-common/llm/log_analysis/merge_sample_documents_with_field_caps';
import { DocumentAnalysis } from '@kbn/observability-utils-common/llm/log_analysis/document_analysis';
import type { ObservabilityElasticsearchClient } from '../es/client/create_observability_es_client';
import type { TracedElasticsearchClient } from '@kbn/traced-es-client';
import { kqlQuery } from '../es/queries/kql_query';
import { rangeQuery } from '../es/queries/range_query';
@ -19,7 +19,7 @@ export async function analyzeDocuments({
end,
index,
}: {
esClient: ObservabilityElasticsearchClient;
esClient: TracedElasticsearchClient;
kuery: string;
start: number;
end: number;

View file

@ -6,7 +6,7 @@
*/
import { compact, uniq } from 'lodash';
import { ObservabilityElasticsearchClient } from '../es/client/create_observability_es_client';
import type { TracedElasticsearchClient } from '@kbn/traced-es-client';
import { excludeFrozenQuery } from '../es/queries/exclude_frozen_query';
import { kqlQuery } from '../es/queries/kql_query';
@ -15,7 +15,7 @@ export async function getDataStreamsForEntity({
kuery,
index,
}: {
esClient: ObservabilityElasticsearchClient;
esClient: TracedElasticsearchClient;
kuery: string;
index: string | string[];
}) {

View file

@ -7,7 +7,7 @@
import { castArray, orderBy } from 'lodash';
import Fuse from 'fuse.js';
import { ObservabilityElasticsearchClient } from '../es/client/create_observability_es_client';
import { TracedElasticsearchClient } from '@kbn/traced-es-client';
export async function getEntitiesByFuzzySearch({
esClient,
@ -16,7 +16,7 @@ export async function getEntitiesByFuzzySearch({
end,
index,
}: {
esClient: ObservabilityElasticsearchClient;
esClient: TracedElasticsearchClient;
entity: Record<string, string>;
start: number;
end: number;

View file

@ -19,7 +19,7 @@ import { pValueToLabel } from '@kbn/observability-utils-common/ml/p_value_to_lab
import { calculateAuto } from '@kbn/calculate-auto';
import { omit, orderBy, uniqBy } from 'lodash';
import moment from 'moment';
import { ObservabilityElasticsearchClient } from '../es/client/create_observability_es_client';
import { TracedElasticsearchClient } from '@kbn/traced-es-client';
import { kqlQuery } from '../es/queries/kql_query';
import { rangeQuery } from '../es/queries/range_query';
@ -54,7 +54,7 @@ export type FieldPatternResultWithChanges = FieldPatternResult<true>;
interface CategorizeTextOptions {
query: QueryDslQueryContainer;
metadata: string[];
esClient: ObservabilityElasticsearchClient;
esClient: TracedElasticsearchClient;
samplingProbability: number;
fields: string[];
index: string | string[];
@ -247,7 +247,7 @@ export async function runCategorizeTextAggregation({
}
interface LogPatternOptions {
esClient: ObservabilityElasticsearchClient;
esClient: TracedElasticsearchClient;
start: number;
end: number;
index: string | string[];

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { ObservabilityElasticsearchClient } from '../../es/client/create_observability_es_client';
import { TracedElasticsearchClient } from '@kbn/traced-es-client';
import { kqlQuery } from '../../es/queries/kql_query';
export async function getSlosForEntity({
@ -20,7 +20,7 @@ export async function getSlosForEntity({
start: number;
end: number;
entity: Record<string, unknown>;
esClient: ObservabilityElasticsearchClient;
esClient: TracedElasticsearchClient;
sloSummaryIndices: string | string[];
size: number;
spaceId: string;

View file

@ -1,15 +0,0 @@
/*
* 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 stringify from 'json-stable-stringify';
import objectHash from 'object-hash';
import { IndexStorageSettings } from '.';
export function getSchemaVersion(storage: IndexStorageSettings): string {
const version = objectHash(stringify(storage.schema.properties));
return version;
}

View file

@ -1,12 +0,0 @@
/*
* 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.
*/
module.exports = {
preset: '@kbn/test/jest_integration',
rootDir: '../../../../..',
roots: ['<rootDir>/x-pack/solutions/observability/packages/utils-server'],
};

View file

@ -16,19 +16,14 @@
"target/**/*"
],
"kbn_references": [
"@kbn/core",
"@kbn/es-types",
"@kbn/apm-utils",
"@kbn/es-query",
"@kbn/observability-utils-common",
"@kbn/traced-es-client",
"@kbn/alerting-plugin",
"@kbn/rule-registry-plugin",
"@kbn/rule-data-utils",
"@kbn/aiops-log-pattern-analysis",
"@kbn/calculate-auto",
"@kbn/utility-types",
"@kbn/task-manager-plugin",
"@kbn/es-errors",
"@kbn/core-test-helpers-kbn-server",
]
}

View file

@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client';
import type { TracedElasticsearchClient } from '@kbn/traced-es-client';
import { type EntityClient } from '@kbn/entityManager-plugin/server/lib/entity_client';
import { type InfraMetricsClient } from '../../lib/helpers/get_infra_metrics_client';
import { getDataStreamTypes } from './get_data_stream_types';
@ -22,13 +22,13 @@ jest.mock('./get_latest_entity', () => ({
describe('getDataStreamTypes', () => {
let infraMetricsClient: jest.Mocked<InfraMetricsClient>;
let obsEsClient: jest.Mocked<ObservabilityElasticsearchClient>;
let obsEsClient: jest.Mocked<TracedElasticsearchClient>;
let entityManagerClient: jest.Mocked<EntityClient>;
const logger = loggingSystemMock.createLogger();
beforeEach(() => {
infraMetricsClient = {} as jest.Mocked<InfraMetricsClient>;
obsEsClient = {} as jest.Mocked<ObservabilityElasticsearchClient>;
obsEsClient = {} as jest.Mocked<TracedElasticsearchClient>;
entityManagerClient = {} as jest.Mocked<EntityClient>;
jest.clearAllMocks();
});

View file

@ -9,7 +9,7 @@ import { type EntityClient } from '@kbn/entityManager-plugin/server/lib/entity_c
import type { InventoryItemType } from '@kbn/metrics-data-access-plugin/common';
import { findInventoryFields } from '@kbn/metrics-data-access-plugin/common';
import { EntityDataStreamType } from '@kbn/observability-shared-plugin/common';
import type { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client';
import type { TracedElasticsearchClient } from '@kbn/traced-es-client';
import { castArray } from 'lodash';
import type { Logger } from '@kbn/logging';
import { type InfraMetricsClient } from '../../lib/helpers/get_infra_metrics_client';
@ -22,7 +22,7 @@ interface Params {
entityFilterType: string;
entityCentricExperienceEnabled: boolean;
infraMetricsClient: InfraMetricsClient;
obsEsClient: ObservabilityElasticsearchClient;
obsEsClient: TracedElasticsearchClient;
entityManagerClient: EntityClient;
logger: Logger;
from: string;

View file

@ -8,7 +8,7 @@
import { schema } from '@kbn/config-schema';
import { METRICS_APP_ID } from '@kbn/deeplinks-observability/constants';
import { entityCentricExperience } from '@kbn/observability-plugin/common';
import { createObservabilityEsClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client';
import { createTracedEsClient } from '@kbn/traced-es-client';
import { BUILT_IN_ENTITY_TYPES } from '@kbn/observability-shared-plugin/common';
import { getInfraMetricsClient } from '../../lib/helpers/get_infra_metrics_client';
import type { InfraBackendLibs } from '../../lib/infra_types';
@ -55,7 +55,7 @@ export const initEntitiesConfigurationRoutes = (libs: InfraBackendLibs) => {
context: requestContext,
});
const obsEsClient = createObservabilityEsClient({
const obsEsClient = createTracedEsClient({
client: coreContext.elasticsearch.client.asCurrentUser,
logger,
plugin: `@kbn/${METRICS_APP_ID}-plugin`,

View file

@ -115,12 +115,12 @@
"@kbn/core-ui-settings-common",
"@kbn/entityManager-plugin",
"@kbn/zod",
"@kbn/observability-utils-server",
"@kbn/observability-utils-common",
"@kbn/core-plugins-server",
"@kbn/config",
"@kbn/response-ops-rule-params",
"@kbn/charts-theme"
"@kbn/charts-theme",
"@kbn/traced-es-client",
"@kbn/observability-utils-common"
],
"exclude": ["target/**/*"]
}

View file

@ -14,7 +14,7 @@ import {
import { z } from '@kbn/zod';
import datemath from '@elastic/datemath';
import { OBSERVABILITY_LOGS_DATA_ACCESS_LOG_SOURCES_ID } from '@kbn/management-settings-ids';
import { createObservabilityEsClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client';
import { createTracedEsClient } from '@kbn/traced-es-client';
import { preconditionFailed } from '@hapi/boom';
import { createInvestigateAppServerRoute } from '../create_investigate_app_server_route';
import { investigationRepositoryFactory } from '../../services/investigation_repository';
@ -69,7 +69,7 @@ export const rootCauseAnalysisRoute = createInvestigateAppServerRoute({
const repository = investigationRepositoryFactory({ soClient, logger });
const esClient = createObservabilityEsClient({
const esClient = createTracedEsClient({
client: coreEsClient,
logger,
plugin: 'investigateApp',

View file

@ -59,7 +59,6 @@
"@kbn/observability-plugin",
"@kbn/observability-shared-plugin",
"@kbn/observability-utils-browser",
"@kbn/observability-utils-server",
"@kbn/presentation-containers",
"@kbn/react-kibana-context-theme",
"@kbn/rule-data-utils",
@ -80,6 +79,7 @@
"@kbn/utility-types-jest",
"@kbn/visualization-utils",
"@kbn/zod",
"@kbn/traced-es-client",
"@kbn/react-hooks",
],
}

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { createObservabilityEsClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client';
import { createTracedEsClient } from '@kbn/traced-es-client';
import { ElasticsearchClient, Logger } from '@kbn/core/server';
export async function createObservabilityAIAssistantAppEsClient({
@ -15,7 +15,7 @@ export async function createObservabilityAIAssistantAppEsClient({
client: ElasticsearchClient;
logger: Logger;
}) {
const esClient = createObservabilityEsClient({
const esClient = createTracedEsClient({
client,
logger,
plugin: 'observabilityAIAssistantApp',

View file

@ -70,7 +70,6 @@
"@kbn/cloud-plugin",
"@kbn/logs-data-access-plugin",
"@kbn/ai-assistant-common",
"@kbn/observability-utils-server",
"@kbn/observability-utils-common",
"@kbn/slo-plugin",
"@kbn/spaces-plugin",
@ -84,6 +83,7 @@
"@kbn/ai-assistant-icon",
"@kbn/rule-data-utils",
"@kbn/utility-types",
"@kbn/traced-es-client"
],
"exclude": ["target/**/*"]
}

View file

@ -8,7 +8,7 @@ import { SanitizedRule } from '@kbn/alerting-plugin/common';
import { RulesClient } from '@kbn/alerting-plugin/server';
import { SavedObject, SavedObjectsClientContract } from '@kbn/core/server';
import { termQuery } from '@kbn/observability-utils-server/es/queries/term_query';
import { IStorageClient } from '@kbn/observability-utils-server/es/storage';
import { IStorageClient } from '@kbn/storage-adapter';
import { keyBy } from 'lodash';
import objectHash from 'object-hash';
import pLimit from 'p-limit';

View file

@ -6,7 +6,7 @@
*/
import { CoreSetup, KibanaRequest, Logger } from '@kbn/core/server';
import { StorageIndexAdapter } from '@kbn/observability-utils-server/es/storage';
import { StorageIndexAdapter } from '@kbn/storage-adapter';
import { StreamsPluginStartDependencies } from '../../../types';
import { AssetClient, StoredAssetLink } from './asset_client';
import { AssetStorageSettings, assetStorageSettings } from './storage_settings';

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { IndexStorageSettings, types } from '@kbn/observability-utils-server/es/storage';
import { IndexStorageSettings, types } from '@kbn/storage-adapter';
import { ASSET_ASSET_ID, ASSET_ENTITY_ID, ASSET_ENTITY_TYPE, ASSET_TYPE } from './fields';
export const assetStorageSettings = {

View file

@ -6,12 +6,7 @@
*/
import type { CoreSetup, KibanaRequest, Logger } from '@kbn/core/server';
import {
IStorageClient,
StorageIndexAdapter,
StorageSettings,
types,
} from '@kbn/observability-utils-server/es/storage';
import { IStorageClient, StorageIndexAdapter, StorageSettings, types } from '@kbn/storage-adapter';
import { StreamDefinition } from '@kbn/streams-schema';
import type { StreamsPluginStartDependencies } from '../../types';
import { StreamsClient } from './client';

View file

@ -8,10 +8,7 @@
import { excludeFrozenQuery } from '@kbn/observability-utils-common/es/queries/exclude_frozen_query';
import { kqlQuery } from '@kbn/observability-utils-common/es/queries/kql_query';
import { rangeQuery } from '@kbn/observability-utils-common/es/queries/range_query';
import {
UnparsedEsqlResponse,
createObservabilityEsClient,
} from '@kbn/observability-utils-server/es/client/create_observability_es_client';
import { UnparsedEsqlResponse, createTracedEsClient } from '@kbn/traced-es-client';
import { z } from '@kbn/zod';
import { isNumber } from 'lodash';
import { createServerRoute } from '../create_server_route';
@ -40,7 +37,7 @@ export const executeEsqlRoute = createServerRoute({
}),
handler: async ({ params, request, logger, getScopedClients }): Promise<UnparsedEsqlResponse> => {
const { scopedClusterClient } = await getScopedClients({ request });
const observabilityEsClient = createObservabilityEsClient({
const observabilityEsClient = createTracedEsClient({
client: scopedClusterClient.asCurrentUser,
logger,
plugin: 'streams',

View file

@ -36,6 +36,8 @@
"@kbn/safer-lodash-set",
"@kbn/streams-schema",
"@kbn/es-errors",
"@kbn/server-route-repository-utils"
"@kbn/server-route-repository-utils",
"@kbn/storage-adapter",
"@kbn/traced-es-client"
]
}

View file

@ -23,7 +23,7 @@ import { i18n } from '@kbn/i18n';
import { getTimeZone } from '@kbn/observability-utils-browser/utils/ui_settings/get_timezone';
import { css } from '@emotion/css';
import { AbortableAsyncState } from '@kbn/react-hooks';
import type { UnparsedEsqlResponse } from '@kbn/observability-utils-server/es/client/create_observability_es_client';
import type { UnparsedEsqlResponse } from '@kbn/traced-es-client';
import { esqlResultToTimeseries } from '../../util/esql_result_to_timeseries';
import { useKibana } from '../../hooks/use_kibana';
import { LoadingPanel } from '../loading_panel';

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import type { AbortableAsyncState } from '@kbn/react-hooks';
import type { UnparsedEsqlResponse } from '@kbn/observability-utils-server/es/client/create_observability_es_client';
import type { UnparsedEsqlResponse } from '@kbn/traced-es-client';
import { orderBy } from 'lodash';
interface Timeseries<T extends string> {

View file

@ -28,7 +28,6 @@
"@kbn/react-kibana-context-render",
"@kbn/code-editor",
"@kbn/observability-utils-browser",
"@kbn/observability-utils-server",
"@kbn/ui-theme",
"@kbn/calculate-auto",
"@kbn/kibana-react-plugin",
@ -40,7 +39,6 @@
"@kbn/calculate-auto",
"@kbn/streams-plugin",
"@kbn/share-plugin",
"@kbn/observability-utils-server",
"@kbn/code-editor",
"@kbn/ui-theme",
"@kbn/navigation-plugin",
@ -55,6 +53,7 @@
"@kbn/deeplinks-analytics",
"@kbn/dashboard-plugin",
"@kbn/react-kibana-mount",
"@kbn/fields-metadata-plugin"
"@kbn/fields-metadata-plugin",
"@kbn/traced-es-client"
]
}

View file

@ -7662,6 +7662,10 @@
version "0.0.0"
uid ""
"@kbn/storage-adapter@link:src/platform/packages/shared/kbn-storage-adapter":
version "0.0.0"
uid ""
"@kbn/storybook@link:packages/kbn-storybook":
version "0.0.0"
uid ""
@ -7802,6 +7806,10 @@
version "0.0.0"
uid ""
"@kbn/traced-es-client@link:src/platform/packages/shared/kbn-traced-es-client":
version "0.0.0"
uid ""
"@kbn/transform-plugin@link:x-pack/platform/plugins/private/transform":
version "0.0.0"
uid ""