kibana/packages/elastic-apm-synthtrace/src/lib/instance.ts
Søren Louv-Jansen e6f35c7395
[APM] Use Synthtrace in Cypress tests (#116948) (#117262)
Co-authored-by: Søren Louv-Jansen <sorenlouv@gmail.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Dario Gieselaar <dario.gieselaar@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-11-03 10:09:38 +00:00

53 lines
1.5 KiB
TypeScript

/*
* 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 { ApmError } from './apm_error';
import { ApplicationMetricFields, Entity } from './entity';
import { Metricset } from './metricset';
import { Span } from './span';
import { Transaction } from './transaction';
export class Instance extends Entity {
transaction(transactionName: string, transactionType = 'request') {
return new Transaction({
...this.fields,
'transaction.name': transactionName,
'transaction.type': transactionType,
});
}
span(spanName: string, spanType: string, spanSubtype?: string) {
return new Span({
...this.fields,
'span.name': spanName,
'span.type': spanType,
'span.subtype': spanSubtype,
});
}
error(message: string, type?: string, groupingName?: string) {
return new ApmError({
...this.fields,
'error.exception': [{ message, ...(type ? { type } : {}) }],
'error.grouping_name': groupingName || message,
});
}
podId(podId: string) {
this.fields['kubernetes.pod.uid'] = podId;
return this;
}
appMetrics(metrics: ApplicationMetricFields) {
return new Metricset({
...this.fields,
'metricset.name': 'app',
...metrics,
});
}
}