Skip to content

Commit

Permalink
Merge branch 'main' into allow-rules-bulk-upgrade-with-solvable-confl…
Browse files Browse the repository at this point in the history
…icts
  • Loading branch information
maximpn authored Mar 6, 2025
2 parents 1d35bd4 + 5010d1f commit 4990a63
Show file tree
Hide file tree
Showing 42 changed files with 1,471 additions and 422 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"@elastic/ecs": "^8.11.5",
"@elastic/elasticsearch": "9.0.0-alpha.3",
"@elastic/ems-client": "8.6.3",
"@elastic/eui": "99.4.0-borealis.0",
"@elastic/eui": "100.0.0",
"@elastic/eui-theme-borealis": "0.0.11",
"@elastic/filesaver": "1.1.2",
"@elastic/node-crypto": "^1.2.3",
Expand Down
2 changes: 1 addition & 1 deletion src/dev/license_checker/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const LICENSE_OVERRIDES = {
'jsts@1.6.2': ['Eclipse Distribution License - v 1.0'], // cf. https://github.com/bjornharrtell/jsts
'@mapbox/jsonlint-lines-primitives@2.0.2': ['MIT'], // license in readme https://github.com/tmcw/jsonlint
'@elastic/ems-client@8.6.3': ['Elastic License 2.0'],
'@elastic/eui@99.4.0-borealis.0': ['Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0'],
'@elastic/eui@100.0.0': ['Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0'],
'@elastic/eui-theme-borealis@0.0.11': ['Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0'],
'language-subtag-registry@0.3.21': ['CC-BY-4.0'], // retired ODC‑By license https://github.com/mattcg/language-subtag-registry
'buffers@0.1.1': ['MIT'], // license in importing module https://www.npmjs.com/package/binary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,13 @@ class Otel extends Serializable<OtelDocument> {
},
resource: {
attributes: {
'agent.name': 'otlp',
'agent.name': 'opentelemetry/nodejs',
'agent.version': '1.28.0',
'service.instance.id': '89117ac1-0dbf-4488-9e17-4c2c3b76943a',
'service.name': 'sendotlp-synth',
'metricset.interval': '10m',
'telemetry.sdk.name': 'opentelemetry',
'telemetry.sdk.language': 'nodejs',
},
dropped_attributes_count: 0,
},
Expand Down
4 changes: 4 additions & 0 deletions src/platform/packages/shared/kbn-elastic-agent-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export {
AGENT_NAMES,
} from './src/agent_names';

export { getIngestionPath } from './src/agent_ingestion_path';

export { getSdkNameAndLanguage } from './src/agent_sdk_name_and_language';

export type {
ElasticAgentName,
OpenTelemetryAgentName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
isAndroidAgentName,
isAWSLambdaAgentName,
isAzureFunctionsAgentName,
isElasticAgentName,
isIosAgentName,
isJavaAgentName,
isJRubyAgentName,
Expand Down Expand Up @@ -44,6 +45,17 @@ describe('Agents guards', () => {
expect(isOpenTelemetryAgentName('not-an-agent')).toBe(false);
});

it('isElasticAgentName should guard if the passed agent is an APM agent one.', () => {
expect(isElasticAgentName('nodejs')).toBe(true);
expect(isElasticAgentName('iOS/swift')).toBe(true);
expect(isElasticAgentName('java')).toBe(true);
expect(isElasticAgentName('rum-js')).toBe(true);
expect(isElasticAgentName('android/java')).toBe(true);
expect(isElasticAgentName('node-js')).toBe(false);
expect(isElasticAgentName('opentelemetry/nodejs/elastic')).toBe(false);
expect(isElasticAgentName('not-an-agent')).toBe(false);
});

it('isJavaAgentName should guard if the passed agent is an Java one.', () => {
expect(isJavaAgentName('java')).toBe(true);
expect(isJavaAgentName('otlp/java')).toBe(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import {
ANDROID_AGENT_NAMES,
ELASTIC_AGENT_NAMES,
IOS_AGENT_NAMES,
JAVA_AGENT_NAMES,
OPEN_TELEMETRY_AGENT_NAMES,
Expand All @@ -17,13 +18,16 @@ import {

import type {
AndroidAgentName,
ElasticAgentName,
IOSAgentName,
JavaAgentName,
OpenTelemetryAgentName,
RumAgentName,
ServerlessType,
} from './agent_names';

const ElasticAgentNamesSet = new Set(ELASTIC_AGENT_NAMES);

export function getAgentName(
agentName: string | null,
telemetryAgentName: string | null,
Expand Down Expand Up @@ -57,6 +61,9 @@ export function isOpenTelemetryAgentName(agentName: string): agentName is OpenTe
);
}

export const isElasticAgentName = (agentName: string): agentName is ElasticAgentName =>
ElasticAgentNamesSet.has(agentName as ElasticAgentName);

export function isJavaAgentName(agentName?: string): agentName is JavaAgentName {
return (
hasOpenTelemetryPrefix(agentName, 'java') ||
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* 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 const getIngestionPath = (hasOpenTelemetryFields: boolean) =>
hasOpenTelemetryFields ? 'otel_native' : 'classic_apm';
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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 { getSdkNameAndLanguage } from './agent_sdk_name_and_language';

describe('getSdkNameAndLanguage', () => {
it.each([
{
agentName: 'java',
result: { sdkName: 'apm', language: 'java' },
},
{
agentName: 'iOS/swift',
result: { sdkName: 'apm', language: 'iOS/swift' },
},
{
agentName: 'android/java',
result: { sdkName: 'apm', language: 'android/java' },
},
{
agentName: 'opentelemetry/java/test/elastic',
result: { sdkName: 'edot', language: 'java' },
},
{
agentName: 'opentelemetry/java/elastic',
result: { sdkName: 'edot', language: 'java' },
},
{
agentName: 'otlp/nodejs',
result: { sdkName: 'otel_other', language: 'nodejs' },
},
{
agentName: 'otlp',
result: { sdkName: 'otel_other', language: undefined },
},
{
agentName: 'test/test/test/something-else/elastic',
result: { sdkName: undefined, language: undefined },
},
{
agentName: 'test/java/test/something-else/',
result: { sdkName: undefined, language: undefined },
},
{
agentName: 'elastic',
result: { sdkName: undefined, language: undefined },
},
{
agentName: 'my-awesome-agent/otel',
result: { sdkName: undefined, language: undefined },
},
])('for the agent name $agentName returns $result', ({ agentName, result }) => {
expect(getSdkNameAndLanguage(agentName)).toStrictEqual(result);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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 { isElasticAgentName, isOpenTelemetryAgentName } from './agent_guards';

interface SdkNameAndLanguage {
sdkName?: 'apm' | 'edot' | 'otel_other';
language?: string;
}

const LANGUAGE_INDEX = 1;

export const getSdkNameAndLanguage = (agentName: string): SdkNameAndLanguage => {
if (isElasticAgentName(agentName)) {
return { sdkName: 'apm', language: agentName };
}
const agentNameParts = agentName.split('/');

if (isOpenTelemetryAgentName(agentName)) {
if (agentNameParts[agentNameParts.length - 1] === 'elastic') {
return { sdkName: 'edot', language: agentNameParts[LANGUAGE_INDEX] };
}
return {
sdkName: 'otel_other',
language: agentNameParts[LANGUAGE_INDEX],
};
}

return { sdkName: undefined, language: undefined };
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* 2.0.
*/

import { v4 as uuidv4 } from 'uuid';
import type { SavedObjectReference } from '@kbn/core/public';
import { EVENT_ANNOTATION_GROUP_TYPE } from '@kbn/event-annotation-common';
import { cloneDeep } from 'lodash';
Expand Down Expand Up @@ -100,58 +99,68 @@ export function convertToPersistable(state: XYState) {
const persistableLayers: XYPersistedLayerConfig[] = [];

persistableState.layers.forEach((layer) => {
// anything but an annotation can just be persisted as is
if (!isAnnotationsLayer(layer)) {
persistableLayers.push(layer);
} else {
if (isByReferenceAnnotationsLayer(layer)) {
const referenceName = `ref-${uuidv4()}`;
savedObjectReferences.push({
type: EVENT_ANNOTATION_GROUP_TYPE,
id: layer.annotationGroupId,
name: referenceName,
});

if (!annotationLayerHasUnsavedChanges(layer)) {
const persistableLayer: XYPersistedByReferenceAnnotationLayerConfig = {
persistanceType: 'byReference',
layerId: layer.layerId,
layerType: layer.layerType,
annotationGroupRef: referenceName,
};

persistableLayers.push(persistableLayer);
} else {
const persistableLayer: XYPersistedLinkedByValueAnnotationLayerConfig = {
persistanceType: 'linked',
cachedMetadata: layer.cachedMetadata || {
title: layer.__lastSaved.title,
description: layer.__lastSaved.description,
tags: layer.__lastSaved.tags,
},
layerId: layer.layerId,
layerType: layer.layerType,
annotationGroupRef: referenceName,
annotations: layer.annotations,
ignoreGlobalFilters: layer.ignoreGlobalFilters,
};
persistableLayers.push(persistableLayer);

savedObjectReferences.push({
type: 'index-pattern',
id: layer.indexPatternId,
name: getLayerReferenceName(layer.layerId),
});
}
} else {
const { indexPatternId, ...persistableLayer } = layer;
savedObjectReferences.push({
type: 'index-pattern',
id: indexPatternId,
name: getLayerReferenceName(layer.layerId),
});
persistableLayers.push({ ...persistableLayer, persistanceType: 'byValue' });
}
return;
}
// a by value annotation layer can be persisted with some config tweak
if (!isByReferenceAnnotationsLayer(layer)) {
const { indexPatternId, ...persistableLayer } = layer;
savedObjectReferences.push({
type: 'index-pattern',
id: indexPatternId,
name: getLayerReferenceName(layer.layerId),
});
persistableLayers.push({ ...persistableLayer, persistanceType: 'byValue' });
return;
}
/**
* by reference annotation layer needs to be handled carefully
**/

// make this id stable so that it won't retrigger all the time a change diff
const referenceName = `ref-${layer.layerId}`;
savedObjectReferences.push({
type: EVENT_ANNOTATION_GROUP_TYPE,
id: layer.annotationGroupId,
name: referenceName,
});

// if there's no divergence from the library, it can be persisted without much ado
if (!annotationLayerHasUnsavedChanges(layer)) {
const persistableLayer: XYPersistedByReferenceAnnotationLayerConfig = {
persistanceType: 'byReference',
layerId: layer.layerId,
layerType: layer.layerType,
annotationGroupRef: referenceName,
};

persistableLayers.push(persistableLayer);
return;
}
// this is the case where the by reference diverged from library
// so it needs to persist some extra metadata
const persistableLayer: XYPersistedLinkedByValueAnnotationLayerConfig = {
persistanceType: 'linked',
cachedMetadata: layer.cachedMetadata || {
title: layer.__lastSaved.title,
description: layer.__lastSaved.description,
tags: layer.__lastSaved.tags,
},
layerId: layer.layerId,
layerType: layer.layerType,
annotationGroupRef: referenceName,
annotations: layer.annotations,
ignoreGlobalFilters: layer.ignoreGlobalFilters,
};
persistableLayers.push(persistableLayer);

savedObjectReferences.push({
type: 'index-pattern',
id: layer.indexPatternId,
name: getLayerReferenceName(layer.layerId),
});
});
return { savedObjectReferences, state: { ...persistableState, layers: persistableLayers } };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,7 @@ import type {
TooltipProps,
TooltipValue,
} from '@elastic/charts';
import {
Chart,
Heatmap,
Position,
ScaleType,
Settings,
Tooltip,
LEGACY_LIGHT_THEME,
} from '@elastic/charts';
import { Chart, Heatmap, Position, ScaleType, Settings, Tooltip } from '@elastic/charts';
import moment from 'moment';
import { i18n } from '@kbn/i18n';
import type { ChartsPluginStart } from '@kbn/charts-plugin/public';
Expand Down Expand Up @@ -200,6 +192,10 @@ export const SwimlaneContainer: FC<SwimlaneProps> = ({
yAxisWidth,
onRenderComplete,
}) => {
const {
theme: { useChartsBaseTheme },
} = chartsService;

const [chartWidth, setChartWidth] = useState<number>(0);

const { colorMode, euiTheme } = useEuiTheme();
Expand All @@ -218,6 +214,8 @@ export const SwimlaneContainer: FC<SwimlaneProps> = ({
[chartWidth]
);

const baseTheme = useChartsBaseTheme();

const swimLanePoints = useMemo(() => {
const showFilterContext = filterActive === true && swimlaneType === SWIMLANE_TYPE.OVERALL;

Expand Down Expand Up @@ -458,8 +456,7 @@ export const SwimlaneContainer: FC<SwimlaneProps> = ({
<Tooltip {...tooltipOptions} />
<Settings
theme={themeOverrides}
// TODO connect to charts.theme service see src/plugins/charts/public/services/theme/README.md
baseTheme={LEGACY_LIGHT_THEME}
baseTheme={baseTheme}
onElementClick={onElementClick}
onPointerUpdate={handleCursorUpdate}
showLegend={showLegend}
Expand Down
Loading

0 comments on commit 4990a63

Please sign in to comment.