Skip to content

Commit

Permalink
Merge branch 'main' into error-case-show-sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
jughosta authored Dec 7, 2022
2 parents 2405b5f + a30d225 commit 8cc0d96
Show file tree
Hide file tree
Showing 52 changed files with 1,531 additions and 383 deletions.
2 changes: 1 addition & 1 deletion fleet_packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@
"name": "security_detection_engine",
"version": "8.4.1"
}
]
]
62 changes: 49 additions & 13 deletions packages/kbn-apm-synthtrace/src/lib/apm/apm_fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,74 @@ export interface Observer {
version_major: number;
}

export interface GeoLocation {
coordinates: number[];
type: string;
}

export type ApmFields = Fields &
Partial<{
'timestamp.us'?: number;
'agent.name': string;
'agent.version': string;
'client.geo.city_name': string;
'client.geo.continent_name': string;
'client.geo.country_iso_code': string;
'client.geo.country_name': string;
'client.geo.region_iso_code': string;
'client.geo.region_name': string;
'client.geo.location': GeoLocation;
'client.ip': string;
'cloud.provider': string;
'cloud.project.name': string;
'cloud.service.name': string;
'cloud.availability_zone': string;
'cloud.machine.type': string;
'cloud.region': string;
'container.id': string;
'destination.address': string;
'destination.port': number;
'device.id': string;
'device.model.identifier': string;
'device.model.name': string;
'device.manufacturer': string;
'ecs.version': string;
'event.outcome': string;
'event.ingested': number;
'error.id': string;
'error.exception': ApmException[];
'error.grouping_name': string;
'error.grouping_key': string;
'faas.id': string;
'faas.name': string;
'faas.coldstart': boolean;
'faas.execution': string;
'faas.trigger.type': string;
'faas.trigger.request_id': string;
'host.name': string;
'host.architecture': string;
'host.hostname': string;
'host.os.full': string;
'host.os.name': string;
'host.os.platform': string;
'host.os.type': string;
'host.os.version': string;
'http.request.method': string;
'http.response.status_code': number;
'kubernetes.pod.uid': string;
'kubernetes.pod.name': string;
'metricset.name': string;
observer: Observer;
'network.connection.type': string;
'network.connection.subtype': string;
'network.carrier.name': string;
'network.carrier.mcc': string;
'network.carrier.mnc': string;
'network.carrier.icc': string;
'parent.id': string;
'processor.event': string;
'processor.name': string;
'session.id': string;
'trace.id': string;
'transaction.name': string;
'transaction.type': string;
Expand All @@ -86,6 +127,7 @@ export type ApmFields = Fields &
'service.runtime.name': string;
'service.runtime.version': string;
'service.framework.name': string;
'service.framework.version': string;
'service.target.name': string;
'service.target.type': string;
'span.action': string;
Expand All @@ -103,18 +145,12 @@ export type ApmFields = Fields &
trace: { id: string };
span: { id: string };
}>;
'cloud.provider': string;
'cloud.project.name': string;
'cloud.service.name': string;
'cloud.availability_zone': string;
'cloud.machine.type': string;
'cloud.region': string;
'host.os.platform': string;
'faas.id': string;
'faas.name': string;
'faas.coldstart': boolean;
'faas.execution': string;
'faas.trigger.type': string;
'faas.trigger.request_id': string;
'url.original': string;
}> &
ApmApplicationMetricFields;

export type SpanParams = {
spanName: string;
spanType: string;
spanSubtype?: string;
} & ApmFields;
2 changes: 2 additions & 0 deletions packages/kbn-apm-synthtrace/src/lib/apm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/
import { service } from './service';
import { mobileApp } from './mobile_app';
import { browser } from './browser';
import { serverlessFunction } from './serverless_function';
import { getTransactionMetrics } from './processors/get_transaction_metrics';
Expand All @@ -20,6 +21,7 @@ import type { ApmException } from './apm_fields';

export const apm = {
service,
mobileApp,
browser,
getTransactionMetrics,
getSpanDestinationMetrics,
Expand Down
8 changes: 1 addition & 7 deletions packages/kbn-apm-synthtrace/src/lib/apm/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ import { Entity } from '../entity';
import { Metricset } from './metricset';
import { Span } from './span';
import { Transaction } from './transaction';
import { ApmApplicationMetricFields, ApmFields } from './apm_fields';

export type SpanParams = {
spanName: string;
spanType: string;
spanSubtype?: string;
} & ApmFields;
import { ApmApplicationMetricFields, ApmFields, SpanParams } from './apm_fields';

export class Instance extends Entity<ApmFields> {
transaction(
Expand Down
48 changes: 48 additions & 0 deletions packages/kbn-apm-synthtrace/src/lib/apm/mobile_app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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 { Entity } from '../entity';
import { ApmFields } from './apm_fields';
import { MobileDevice } from './mobile_device';
import { generateLongId } from '../utils/generate_id';

type MobileAgentName = 'android/java' | 'iOS/swift';

export class MobileApp extends Entity<ApmFields> {
mobileDevice(deviceId?: string) {
return new MobileDevice({
...this.fields,
'device.id': deviceId ? deviceId : generateLongId(),
'service.language.name': this.fields['agent.name'] === 'iOS' ? 'swift' : 'java',
'service.version': this.fields['service.version'] ?? '1.0',
}).startNewSession();
}
}

export function mobileApp(name: string, environment: string, agentName: MobileAgentName): MobileApp;

export function mobileApp(options: {
name: string;
environment: string;
agentName: MobileAgentName;
}): MobileApp;

export function mobileApp(
...args:
| [{ name: string; environment: string; agentName: MobileAgentName }]
| [string, string, MobileAgentName]
) {
const [name, environment, agentName] =
args.length === 1 ? [args[0].name, args[0].environment, args[0].agentName] : args;

return new MobileApp({
'service.name': name,
'service.environment': environment,
'agent.name': agentName,
});
}
Loading

0 comments on commit 8cc0d96

Please sign in to comment.