diff --git a/x-pack/solutions/observability/plugins/apm/common/agent_configuration/runtime_types/logging_level_rt.ts b/x-pack/solutions/observability/plugins/apm/common/agent_configuration/runtime_types/logging_level_rt.ts new file mode 100644 index 0000000000000..9eace644edfe2 --- /dev/null +++ b/x-pack/solutions/observability/plugins/apm/common/agent_configuration/runtime_types/logging_level_rt.ts @@ -0,0 +1,18 @@ +/* + * 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 * as t from 'io-ts'; + +export const loggingLevelRt = t.union([ + t.literal('trace'), + t.literal('debug'), + t.literal('info'), + t.literal('warn'), + t.literal('error'), + t.literal('fatal'), + t.literal('off'), +]); diff --git a/x-pack/solutions/observability/plugins/apm/common/agent_configuration/setting_definitions/__snapshots__/index.test.ts.snap b/x-pack/solutions/observability/plugins/apm/common/agent_configuration/setting_definitions/__snapshots__/index.test.ts.snap index 3cb3279dee29d..44352219f7436 100644 --- a/x-pack/solutions/observability/plugins/apm/common/agent_configuration/setting_definitions/__snapshots__/index.test.ts.snap +++ b/x-pack/solutions/observability/plugins/apm/common/agent_configuration/setting_definitions/__snapshots__/index.test.ts.snap @@ -201,6 +201,41 @@ Array [ "type": "boolean", "validationName": "(\\"true\\" | \\"false\\")", }, + Object { + "key": "logging_level", + "options": Array [ + Object { + "text": "trace", + "value": "trace", + }, + Object { + "text": "debug", + "value": "debug", + }, + Object { + "text": "info", + "value": "info", + }, + Object { + "text": "warn", + "value": "warn", + }, + Object { + "text": "error", + "value": "error", + }, + Object { + "text": "fatal", + "value": "fatal", + }, + Object { + "text": "off", + "value": "off", + }, + ], + "type": "select", + "validationName": "(\\"trace\\" | \\"debug\\" | \\"info\\" | \\"warn\\" | \\"error\\" | \\"fatal\\" | \\"off\\")", + }, Object { "key": "mongodb_capture_statement_commands", "type": "boolean", diff --git a/x-pack/solutions/observability/plugins/apm/common/agent_configuration/setting_definitions/edot_sdk_settings.ts b/x-pack/solutions/observability/plugins/apm/common/agent_configuration/setting_definitions/edot_sdk_settings.ts index 4ddcba8b320d2..30a77750c6b32 100644 --- a/x-pack/solutions/observability/plugins/apm/common/agent_configuration/setting_definitions/edot_sdk_settings.ts +++ b/x-pack/solutions/observability/plugins/apm/common/agent_configuration/setting_definitions/edot_sdk_settings.ts @@ -7,6 +7,7 @@ import { i18n } from '@kbn/i18n'; import type { RawSettingDefinition } from './types'; +import { loggingLevelRt } from '../runtime_types/logging_level_rt'; export const edotSDKSettings: RawSettingDefinition[] = [ { @@ -45,6 +46,28 @@ export const edotSDKSettings: RawSettingDefinition[] = [ ), includeAgents: ['opentelemetry/java/elastic'], }, + { + key: 'logging_level', + validation: loggingLevelRt, + type: 'select', + defaultValue: 'info', + label: i18n.translate('xpack.apm.agentConfig.loggingLevel.label', { + defaultMessage: 'Logging level', + }), + description: i18n.translate('xpack.apm.agentConfig.loggingLevel.description', { + defaultMessage: 'Sets the logging level for the agent', + }), + options: [ + { text: 'trace', value: 'trace' }, + { text: 'debug', value: 'debug' }, + { text: 'info', value: 'info' }, + { text: 'warn', value: 'warn' }, + { text: 'error', value: 'error' }, + { text: 'fatal', value: 'fatal' }, + { text: 'off', value: 'off' }, + ], + includeAgents: ['opentelemetry/java/elastic'], + }, { key: 'send_traces', type: 'boolean', diff --git a/x-pack/solutions/observability/plugins/apm/common/agent_configuration/setting_definitions/index.test.ts b/x-pack/solutions/observability/plugins/apm/common/agent_configuration/setting_definitions/index.test.ts index 5aecea96004b7..9a2addd618e1f 100644 --- a/x-pack/solutions/observability/plugins/apm/common/agent_configuration/setting_definitions/index.test.ts +++ b/x-pack/solutions/observability/plugins/apm/common/agent_configuration/setting_definitions/index.test.ts @@ -190,14 +190,17 @@ describe('filterByAgent', () => { }); it('opentelemetry/java/elastic', () => { - expect(getSettingKeysForAgent('opentelemetry/java/elastic')).toEqual([ - 'deactivate_all_instrumentations', - 'deactivate_instrumentations', - 'recording', - 'send_logs', - 'send_metrics', - 'send_traces', - ]); + expect(getSettingKeysForAgent('opentelemetry/java/elastic')).toEqual( + expect.arrayContaining([ + 'deactivate_all_instrumentations', + 'deactivate_instrumentations', + 'logging_level', + 'recording', + 'send_logs', + 'send_metrics', + 'send_traces', + ]) + ); }); it('"All" services (no agent name)', () => {