mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
# Backport This will backport the following commits from `main` to `8.x`: - [[Security Solution][SIEM migrations] Fix langsmight tracing (#208065)](https://github.com/elastic/kibana/pull/208065) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Sergi Massaneda","email":"sergi.massaneda@elastic.co"},"sourceCommit":{"committedDate":"2025-01-23T16:46:40Z","message":"[Security Solution][SIEM migrations] Fix langsmight tracing (#208065)\n\n## Summary\r\n\r\nFixes LangSmith tracing on the API side","sha":"8578c73a6697085e2004911af76e8950eae568f3","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Threat Hunting","backport:version","v8.18.0"],"title":"[Security Solution][SIEM migrations] Fix langsmight tracing","number":208065,"url":"https://github.com/elastic/kibana/pull/208065","mergeCommit":{"message":"[Security Solution][SIEM migrations] Fix langsmight tracing (#208065)\n\n## Summary\r\n\r\nFixes LangSmith tracing on the API side","sha":"8578c73a6697085e2004911af76e8950eae568f3"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/208065","number":208065,"mergeCommit":{"message":"[Security Solution][SIEM migrations] Fix langsmight tracing (#208065)\n\n## Summary\r\n\r\nFixes LangSmith tracing on the API side","sha":"8578c73a6697085e2004911af76e8950eae568f3"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Sergi Massaneda <sergi.massaneda@elastic.co>
This commit is contained in:
parent
8a5f3ecede
commit
581d6f2612
1 changed files with 16 additions and 7 deletions
|
@ -9,6 +9,8 @@ import type { IKibanaResponse, Logger } from '@kbn/core/server';
|
|||
import { APMTracer } from '@kbn/langchain/server/tracers/apm';
|
||||
import { getLangSmithTracer } from '@kbn/langchain/server/tracers/langsmith';
|
||||
import { buildRouteValidationWithZod } from '@kbn/zod-helpers';
|
||||
import type { Callbacks } from '@langchain/core/callbacks/manager';
|
||||
import type { LangSmithOptions } from '../../../../../common/siem_migrations/model/common.gen';
|
||||
import { SIEM_RULE_MIGRATION_START_PATH } from '../../../../../common/siem_migrations/constants';
|
||||
import {
|
||||
StartRuleMigrationRequestBody,
|
||||
|
@ -63,17 +65,12 @@ export const registerSiemRuleMigrationsStartRoute = (
|
|||
}
|
||||
}
|
||||
|
||||
const invocationConfig = {
|
||||
callbacks: [
|
||||
new APMTracer({ projectName: langsmithOptions?.project_name ?? 'default' }, logger),
|
||||
...getLangSmithTracer({ ...langsmithOptions, logger }),
|
||||
],
|
||||
};
|
||||
const callbacks = createInvocationCallbacks(langsmithOptions, logger);
|
||||
|
||||
const { exists, started } = await ruleMigrationsClient.task.start({
|
||||
migrationId,
|
||||
connectorId,
|
||||
invocationConfig,
|
||||
invocationConfig: { callbacks },
|
||||
});
|
||||
|
||||
if (!exists) {
|
||||
|
@ -88,3 +85,15 @@ export const registerSiemRuleMigrationsStartRoute = (
|
|||
)
|
||||
);
|
||||
};
|
||||
|
||||
function createInvocationCallbacks(
|
||||
langsmithOptions: LangSmithOptions | undefined,
|
||||
logger: Logger
|
||||
): Callbacks {
|
||||
const { api_key: apiKey, project_name: projectName = 'default' } = langsmithOptions ?? {};
|
||||
const callbacks: Callbacks = [new APMTracer({ projectName }, logger)];
|
||||
if (langsmithOptions) {
|
||||
callbacks.push(...getLangSmithTracer({ apiKey, projectName, logger }));
|
||||
}
|
||||
return callbacks;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue