Skip to content

Commit

Permalink
Merge branch 'main' into fix/edit-description-refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
academo authored May 23, 2022
2 parents 8f3f0ce + c993ff2 commit ef42d3c
Show file tree
Hide file tree
Showing 85 changed files with 1,997 additions and 875 deletions.
1 change: 1 addition & 0 deletions packages/elastic-apm-synthtrace/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
export { timerange } from './lib/timerange';
export { apm } from './lib/apm';
export { stackMonitoring } from './lib/stack_monitoring';
export { observer } from './lib/agent_config';
export { cleanWriteTargets } from './lib/utils/clean_write_targets';
export { createLogger, LogLevel } from './lib/utils/create_logger';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/

import { AgentConfigFields } from './agent_config_fields';
import { Metricset } from '../apm/metricset';

export class AgentConfig extends Metricset<AgentConfigFields> {
constructor() {
super({
'metricset.name': 'agent_config',
agent_config_applied: 1,
});
}

etag(etag: string) {
this.fields['labels.etag'] = etag;
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/

import { ApmFields } from '../apm/apm_fields';

export type AgentConfigFields = Pick<
ApmFields,
| '@timestamp'
| 'processor.event'
| 'processor.name'
| 'metricset.name'
| 'observer'
| 'ecs.version'
| 'event.ingested'
> &
Partial<{
'labels.etag': string;
agent_config_applied: number;
'event.agent_id_status': string;
}>;
9 changes: 9 additions & 0 deletions packages/elastic-apm-synthtrace/src/lib/agent_config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/

export { observer } from './observer';
21 changes: 21 additions & 0 deletions packages/elastic-apm-synthtrace/src/lib/agent_config/observer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/

import { AgentConfigFields } from './agent_config_fields';
import { AgentConfig } from './agent_config';
import { Entity } from '../entity';

export class Observer extends Entity<AgentConfigFields> {
agentConfig() {
return new AgentConfig();
}
}

export function observer() {
return new Observer({});
}
2 changes: 1 addition & 1 deletion packages/elastic-apm-synthtrace/src/lib/apm/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class Instance extends Entity<ApmFields> {
}

appMetrics(metrics: ApmApplicationMetricFields) {
return new Metricset({
return new Metricset<ApmFields>({
...this.fields,
'metricset.name': 'app',
...metrics,
Expand Down
6 changes: 3 additions & 3 deletions packages/elastic-apm-synthtrace/src/lib/apm/metricset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
*/

import { Serializable } from '../serializable';
import { ApmFields } from './apm_fields';
import { Fields } from '../entity';

export class Metricset extends Serializable<ApmFields> {
constructor(fields: ApmFields) {
export class Metricset<TFields extends Fields> extends Serializable<TFields> {
constructor(fields: TFields) {
super({
'processor.event': 'metric',
'processor.name': 'metric',
Expand Down
4 changes: 3 additions & 1 deletion packages/elastic-apm-synthtrace/src/lib/stream_processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ export class StreamProcessor<TFields extends Fields = ApmFields> {
const eventType = d.processor.event as keyof ApmElasticsearchOutputWriteTargets;
let dataStream = writeTargets[eventType];
if (eventType === 'metric') {
if (!d.service?.name) {
if (d.metricset?.name === 'agent_config') {
dataStream = 'metrics-apm.internal-default';
} else if (!d.service?.name) {
dataStream = 'metrics-apm.app-default';
} else {
if (!d.transaction && !d.span) {
Expand Down
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 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 or the Server
* Side Public License, v 1.
*/

import { observer, timerange } from '../..';
import { Scenario } from '../scenario';
import { getLogger } from '../utils/get_common_services';
import { RunOptions } from '../utils/parse_run_cli_flags';
import { AgentConfigFields } from '../../lib/agent_config/agent_config_fields';

const scenario: Scenario<AgentConfigFields> = async (runOptions: RunOptions) => {
const logger = getLogger(runOptions);

return {
generate: ({ from, to }) => {
const agentConfig = observer().agentConfig();

const range = timerange(from, to);
return range
.interval('30s')
.rate(1)
.generator((timestamp) => {
const events = logger.perf('generating_agent_config_events', () => {
return agentConfig.etag('test-etag').timestamp(timestamp);
});
return events;
});
},
};
};

export default scenario;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import { i18n } from '@kbn/i18n';
import { ThemeServiceSetup } from '@kbn/core/public';
import { toMountPoint } from '@kbn/kibana-react-plugin/public';
import { Action, createAction, IncompatibleActionError } from '@kbn/ui-actions-plugin/public';
import { Filter, FilterManager, TimefilterContract, esFilters } from '@kbn/data-plugin/public';
// for cleanup esFilters need to fix the issue https://github.com/elastic/kibana/issues/131292
import { FilterManager, TimefilterContract, esFilters } from '@kbn/data-plugin/public';
import type { Filter } from '@kbn/es-query';
import { getOverlays, getIndexPatterns } from '../services';
import { applyFiltersPopover } from '../apply_filters';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
mapAndFlattenFilters,
getFieldDisplayValueFromFilter,
} from '@kbn/data-plugin/public';
import { Filter } from '@kbn/data-plugin/common';
import type { Filter } from '@kbn/es-query';
import { DataView } from '@kbn/data-views-plugin/public';
import { FilterLabel } from '../filter_bar';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import React from 'react';
import { Filter } from '@kbn/data-plugin/common';
import type { Filter } from '@kbn/es-query';
import { DataView } from '@kbn/data-views-plugin/common';

type CancelFnType = () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { coreMock } from '@kbn/core/public/mocks';
import { KueryNode } from '@kbn/data-plugin/public';
import type { KueryNode } from '@kbn/es-query';
import { setupGetConjunctionSuggestions } from './conjunction';
import { QuerySuggestionGetFnArgs } from '../query_suggestion_provider';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import indexPatternResponse from './__fixtures__/index_pattern_response.json';

import { indexPatterns as indexPatternsUtils, KueryNode } from '@kbn/data-plugin/public';
import { indexPatterns as indexPatternsUtils } from '@kbn/data-plugin/public';
import type { KueryNode } from '@kbn/es-query';
import { setupGetFieldSuggestions } from './field';
import { QuerySuggestionGetFnArgs } from '../query_suggestion_provider';
import { coreMock } from '@kbn/core/public/mocks';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

// for replace IFieldType => DataViewField need to fix the issue https://github.com/elastic/kibana/issues/131292
import { IFieldType, indexPatterns as indexPatternsUtils } from '@kbn/data-plugin/public';
import { flatten } from 'lodash';
import { sortPrefixFirst } from './sort_prefix_first';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import indexPatternResponse from './__fixtures__/index_pattern_response.json';

import { setupGetOperatorSuggestions } from './operator';
import { KueryNode } from '@kbn/data-plugin/public';
import type { KueryNode } from '@kbn/es-query';
import { QuerySuggestionGetFnArgs } from '../query_suggestion_provider';
import { coreMock } from '@kbn/core/public/mocks';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { setupGetValueSuggestions } from './value';
import indexPatternResponse from './__fixtures__/index_pattern_response.json';

import { coreMock } from '@kbn/core/public/mocks';
import { KueryNode } from '@kbn/data-plugin/public';
import type { KueryNode } from '@kbn/es-query';
import { QuerySuggestionGetFnArgs } from '../query_suggestion_provider';

const mockKueryNode = (kueryNode: Partial<KueryNode>) => kueryNode as unknown as KueryNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

import { flatten } from 'lodash';
import { CoreSetup } from '@kbn/core/public';
import { IFieldType, IIndexPattern } from '@kbn/data-plugin/public';
// for replace IIndexPattern => DataView and IFieldType => DataViewField
// need to fix the issue https://github.com/elastic/kibana/issues/131292
import type { IIndexPattern, IFieldType } from '@kbn/data-views-plugin/common';
import { escapeQuotes } from './lib/escape_kuery';
import { KqlQuerySuggestionProvider } from './types';
import type { UnifiedSearchPublicPluginStart } from '../../../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/

import { ValueSuggestionsMethod } from '@kbn/data-plugin/common';
import { IFieldType, IIndexPattern } from '@kbn/data-plugin/common';
// for replace IIndexPattern => DataView need to fix the issue https://github.com/elastic/kibana/issues/131292
import type { DataViewField, IIndexPattern } from '@kbn/data-views-plugin/common';

export enum QuerySuggestionTypes {
Field = 'field',
Expand Down Expand Up @@ -47,7 +48,7 @@ export interface QuerySuggestionBasic {
/** @public **/
export interface QuerySuggestionField extends QuerySuggestionBasic {
type: QuerySuggestionTypes.Field;
field: IFieldType;
field: DataViewField;
}

/** @public **/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
import { CoreSetup } from '@kbn/core/public';
import dateMath from '@kbn/datemath';
import { memoize } from 'lodash';
import {
IIndexPattern,
IFieldType,
UI_SETTINGS,
ValueSuggestionsMethod,
} from '@kbn/data-plugin/common';
import { UI_SETTINGS, ValueSuggestionsMethod } from '@kbn/data-plugin/common';
// for replace IIndexPattern => DataView and IFieldType => DataViewField
// need to fix the issue https://github.com/elastic/kibana/issues/131292
import type { IIndexPattern, IFieldType } from '@kbn/data-views-plugin/common';
import type { TimefilterSetup } from '@kbn/data-plugin/public';
import { AutocompleteUsageCollector } from '../collectors';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
import { get } from 'lodash';
import React, { Component } from 'react';
import { XJsonLang } from '@kbn/monaco';
import { DataView, IFieldType } from '@kbn/data-views-plugin/common';
import { DataView, DataViewField } from '@kbn/data-views-plugin/common';
import { getIndexPatternFromFilter } from '@kbn/data-plugin/public';
import { CodeEditor } from '@kbn/kibana-react-plugin/public';
import { GenericComboBox, GenericComboBoxProps } from './generic_combo_box';
Expand Down Expand Up @@ -61,7 +61,7 @@ export interface Props {

interface State {
selectedIndexPattern?: DataView;
selectedField?: IFieldType;
selectedField?: DataViewField;
selectedOperator?: Operator;
params: any;
useCustomLabel: boolean;
Expand Down Expand Up @@ -447,7 +447,7 @@ class FilterEditorUI extends Component<Props, State> {
this.setState({ selectedIndexPattern, selectedField, selectedOperator, params });
};

private onFieldChange = ([selectedField]: IFieldType[]) => {
private onFieldChange = ([selectedField]: DataViewField[]) => {
const selectedOperator = undefined;
const params = undefined;
this.setState({ selectedField, selectedOperator, params });
Expand Down Expand Up @@ -529,7 +529,7 @@ function IndexPatternComboBox(props: GenericComboBoxProps<DataView>) {
return GenericComboBox(props);
}

function FieldComboBox(props: GenericComboBoxProps<IFieldType>) {
function FieldComboBox(props: GenericComboBoxProps<DataViewField>) {
return GenericComboBox(props);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
stubIndexPattern,
stubFields,
} from '@kbn/data-plugin/common/stubs';
import { toggleFilterNegated } from '@kbn/data-plugin/common';
import { toggleFilterNegated } from '@kbn/es-query';
import {
getFieldFromFilter,
getFilterableFields,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import dateMath from '@kbn/datemath';
import { Filter, FieldFilter } from '@kbn/es-query';
import { ES_FIELD_TYPES } from '@kbn/field-types';
import isSemverValid from 'semver/functions/valid';
import { isFilterable, IFieldType, IpAddress } from '@kbn/data-plugin/common';
import { DataView } from '@kbn/data-views-plugin/common';
import { isFilterable, IpAddress } from '@kbn/data-plugin/common';
import type { DataView, DataViewField } from '@kbn/data-views-plugin/common';
import { FILTER_OPERATORS, Operator } from './filter_operators';

export function getFieldFromFilter(filter: FieldFilter, indexPattern: DataView) {
Expand All @@ -28,15 +28,15 @@ export function getFilterableFields(indexPattern: DataView) {
return indexPattern.fields.filter(isFilterable);
}

export function getOperatorOptions(field: IFieldType) {
export function getOperatorOptions(field: DataViewField) {
return FILTER_OPERATORS.filter((operator) => {
if (operator.field) return operator.field(field);
if (operator.fieldTypes) return operator.fieldTypes.includes(field.type);
return true;
});
}

export function validateParams(params: any, field: IFieldType) {
export function validateParams(params: any, field: DataViewField) {
switch (field.type) {
case 'date':
const moment = typeof params === 'string' ? dateMath.parse(params) : null;
Expand All @@ -59,7 +59,7 @@ export function validateParams(params: any, field: IFieldType) {

export function isFilterValid(
indexPattern?: DataView,
field?: IFieldType,
field?: DataViewField,
operator?: Operator,
params?: any
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import React, { Fragment } from 'react';
import { EuiTextColor } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { Filter, FILTERS } from '@kbn/data-plugin/common';
import { Filter, FILTERS } from '@kbn/es-query';
import { existsOperator, isOneOfOperator } from './filter_operators';
import type { FilterLabelStatus } from '../../filter_item/filter_item';

Expand Down
Loading

0 comments on commit ef42d3c

Please sign in to comment.