diff --git a/packages/kbn-elastic-agent-utils/src/agent_guards.test.ts b/packages/kbn-elastic-agent-utils/src/agent_guards.test.ts index 0de2ea225ce81..aa55aa94b16ca 100644 --- a/packages/kbn-elastic-agent-utils/src/agent_guards.test.ts +++ b/packages/kbn-elastic-agent-utils/src/agent_guards.test.ts @@ -23,11 +23,17 @@ import { describe('Agents guards', () => { it('isOpenTelemetryAgentName should guard if the passed agent is an OpenTelemetry one.', () => { expect(isOpenTelemetryAgentName('otlp')).toBe(true); + expect(isOpenTelemetryAgentName('opentelemetry/java')).toBe(true); + expect(isOpenTelemetryAgentName('opentelemetry/java/opentelemetry-java-instrumentation')).toBe( + true + ); expect(isOpenTelemetryAgentName('not-an-agent')).toBe(false); }); it('isJavaAgentName should guard if the passed agent is an Java one.', () => { expect(isJavaAgentName('java')).toBe(true); + expect(isJavaAgentName('opentelemetry/java')).toBe(true); + expect(isJavaAgentName('opentelemetry/java/opentelemetry-java-instrumentation')).toBe(true); expect(isJavaAgentName('not-an-agent')).toBe(false); }); diff --git a/packages/kbn-elastic-agent-utils/src/agent_guards.ts b/packages/kbn-elastic-agent-utils/src/agent_guards.ts index 6997cbd81c42c..43cf4cce89f4a 100644 --- a/packages/kbn-elastic-agent-utils/src/agent_guards.ts +++ b/packages/kbn-elastic-agent-utils/src/agent_guards.ts @@ -16,11 +16,17 @@ import type { } from './agent_names'; export function isOpenTelemetryAgentName(agentName: string): agentName is OpenTelemetryAgentName { - return OPEN_TELEMETRY_AGENT_NAMES.includes(agentName as OpenTelemetryAgentName); + return ( + agentName?.startsWith('opentelemetry/') || + OPEN_TELEMETRY_AGENT_NAMES.includes(agentName as OpenTelemetryAgentName) + ); } export function isJavaAgentName(agentName?: string): agentName is JavaAgentName { - return JAVA_AGENT_NAMES.includes(agentName! as JavaAgentName); + return ( + agentName?.startsWith('opentelemetry/java') || + JAVA_AGENT_NAMES.includes(agentName! as JavaAgentName) + ); } export function isRumAgentName(agentName?: string): agentName is RumAgentName {