[Fleet] Action APM tracing (#139849)

## Summary

Related to https://github.com/elastic/ingest-dev/issues/1489
Add a `traceparent` field to actions created in `.fleet-actions`

Co-authored-by: Julia Bardi <90178898+juliaElastic@users.noreply.github.com>
This commit is contained in:
Josh Dover 2023-04-05 16:09:00 +02:00 committed by GitHub
parent 24c106907f
commit d9bd659ab5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -389,7 +389,10 @@ export interface FleetServerAgentAction {
data?: {
[k: string]: unknown;
};
total?: number;
/** Trace id */
traceparent?: string | null;
[k: string]: unknown;
}

View file

@ -7,6 +7,7 @@
import { v4 as uuidv4 } from 'uuid';
import type { ElasticsearchClient, SavedObjectsClientContract } from '@kbn/core/server';
import apm from 'elastic-apm-node';
import { appContextService } from '../app_context';
import type {
@ -50,6 +51,7 @@ export async function createAgentAction(
minimum_execution_duration: newAgentAction.minimum_execution_duration,
rollout_duration_seconds: newAgentAction.rollout_duration_seconds,
total: newAgentAction.total,
traceparent: apm.currentTraceparent,
};
await esClient.create({
@ -98,6 +100,7 @@ export async function bulkCreateAgentActions(
action_id: action.id,
data: action.data,
type: action.type,
traceparent: apm.currentTraceparent,
};
return [