diff --git a/x-pack/plugins/apm/common/constants.test.ts b/x-pack/plugins/apm/common/constants.test.ts index c750f937cdb91..63c1da116bcb2 100644 --- a/x-pack/plugins/apm/common/constants.test.ts +++ b/x-pack/plugins/apm/common/constants.test.ts @@ -5,8 +5,8 @@ */ import { get } from 'lodash'; -import { Span } from '../typings/Span'; -import { Transaction } from '../typings/Transaction'; +import { Span } from '../typings/es_schemas/Span'; +import { Transaction } from '../typings/es_schemas/Transaction'; import * as constants from './constants'; describe('Transaction v1:', () => { diff --git a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/__snapshots__/DetailView.test.js.snap b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/__snapshots__/DetailView.test.js.snap index 9ca7ebbed2b04..d001e35a8e849 100644 --- a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/__snapshots__/DetailView.test.js.snap +++ b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__test__/__snapshots__/DetailView.test.js.snap @@ -13,8 +13,966 @@ exports[`DetailView should render with data 1`] = ` Error occurrence (server/coffee.js)", + "exception": Object { + "message": "Cannot read property 'level' of undefined", + "stacktrace": Array [ + Object { + "absPath": "/app/server/coffee.js", + "context": Object { + "post": Array [ + " res.send('Of course!')", + " } else {", + " res.send('You can\\\\'t have any!')", + " }", + "})", + "", + "app.get('/log-error', function (req, res) {", + ], + "pre": Array [ + "", + "var express = require('express')", + "var apm = require('elastic-apm-node')", + "", + "var app = module.exports = new express.Router()", + "", + "app.get('/is-it-coffee-time', function (req, res) {", + ], + }, + "filename": "server/coffee.js", + "function": "", + "libraryFrame": false, + "line": Object { + "context": " if (req.paarms.level === 11) {", + "number": 9, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/layer.js", + "context": Object { + "post": Array [ + " } catch (err) {", + " next(err);", + " }", + "};", + "", + "/**", + " * Check if this route matches \`path\`, if so", + ], + "pre": Array [ + "", + " if (fn.length > 3) {", + " // not a standard request handler", + " return next();", + " }", + "", + " try {", + ], + }, + "filename": "node_modules/express/lib/router/layer.js", + "function": "handle", + "libraryFrame": true, + "line": Object { + "context": " fn(req, res, next);", + "number": 95, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/route.js", + "context": Object { + "post": Array [ + " }", + " }", + "};", + "", + "/**", + " * Add a handler for all HTTP verbs to this route.", + " *", + ], + "pre": Array [ + " if (layer.method && layer.method !== method) {", + " return next(err);", + " }", + "", + " if (err) {", + " layer.handle_error(err, req, res, next);", + " } else {", + ], + }, + "filename": "node_modules/express/lib/router/route.js", + "function": "next", + "libraryFrame": true, + "line": Object { + "context": " layer.handle_request(req, res, next);", + "number": 137, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/route.js", + "context": Object { + "post": Array [ + "", + " function next(err) {", + " // signal to exit route", + " if (err && err === 'route') {", + " return done();", + " }", + "", + ], + "pre": Array [ + " var method = req.method.toLowerCase();", + " if (method === 'head' && !this.methods['head']) {", + " method = 'get';", + " }", + "", + " req.route = this;", + "", + ], + }, + "filename": "node_modules/express/lib/router/route.js", + "function": "dispatch", + "libraryFrame": true, + "line": Object { + "context": " next();", + "number": 112, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/layer.js", + "context": Object { + "post": Array [ + " } catch (err) {", + " next(err);", + " }", + "};", + "", + "/**", + " * Check if this route matches \`path\`, if so", + ], + "pre": Array [ + "", + " if (fn.length > 3) {", + " // not a standard request handler", + " return next();", + " }", + "", + " try {", + ], + }, + "filename": "node_modules/express/lib/router/layer.js", + "function": "handle", + "libraryFrame": true, + "line": Object { + "context": " fn(req, res, next);", + "number": 95, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " }", + "", + " trim_prefix(layer, layerError, layerPath, path);", + " });", + " }", + "", + " function trim_prefix(layer, layerError, layerPath, path) {", + ], + "pre": Array [ + " // this should be done for the layer", + " self.process_params(layer, paramcalled, req, res, function (err) {", + " if (err) {", + " return next(layerError || err);", + " }", + "", + " if (route) {", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "", + "libraryFrame": true, + "line": Object { + "context": " return layer.handle_request(req, res, next);", + "number": 281, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " }", + "", + " var i = 0;", + " var name;", + " var paramIndex = 0;", + " var key;", + " var paramVal;", + ], + "pre": Array [ + " var params = this.params;", + "", + " // captured parameters from the layer, keys and values", + " var keys = layer.keys;", + "", + " // fast track", + " if (!keys || keys.length === 0) {", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "process_params", + "libraryFrame": true, + "line": Object { + "context": " return done();", + "number": 335, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " if (err) {", + " return next(layerError || err);", + " }", + "", + " if (route) {", + " return layer.handle_request(req, res, next);", + " }", + ], + "pre": Array [ + " // Capture one-time layer values", + " req.params = self.mergeParams", + " ? mergeParams(layer.params, parentParams)", + " : layer.params;", + " var layerPath = layer.path;", + "", + " // this should be done for the layer", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "next", + "libraryFrame": true, + "line": Object { + "context": " self.process_params(layer, paramcalled, req, res, function (err) {", + "number": 275, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + "", + " function next(err) {", + " var layerError = err === 'route'", + " ? null", + " : err;", + "", + " // remove added slash", + ], + "pre": Array [ + " });", + " }", + "", + " // setup basic req values", + " req.baseUrl = parentUrl;", + " req.originalUrl = req.originalUrl || req.url;", + "", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "handle", + "libraryFrame": true, + "line": Object { + "context": " next();", + "number": 174, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " }", + "", + " // mixin Router class functions", + " setPrototypeOf(router, proto)", + "", + " router.params = {};", + " router._params = [];", + ], + "pre": Array [ + " * @public", + " */", + "", + "var proto = module.exports = function(options) {", + " var opts = options || {};", + "", + " function router(req, res, next) {", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "router", + "libraryFrame": true, + "line": Object { + "context": " router.handle(req, res, next);", + "number": 47, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/layer.js", + "context": Object { + "post": Array [ + " } catch (err) {", + " next(err);", + " }", + "};", + "", + "/**", + " * Check if this route matches \`path\`, if so", + ], + "pre": Array [ + "", + " if (fn.length > 3) {", + " // not a standard request handler", + " return next();", + " }", + "", + " try {", + ], + }, + "filename": "node_modules/express/lib/router/layer.js", + "function": "handle", + "libraryFrame": true, + "line": Object { + "context": " fn(req, res, next);", + "number": 95, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " }", + " }", + "};", + "", + "/**", + " * Process any parameters for the layer.", + " * @private", + ], + "pre": Array [ + " }", + "", + " debug('%s %s : %s', layer.name, layerPath, req.originalUrl);", + "", + " if (layerError) {", + " layer.handle_error(layerError, req, res, next);", + " } else {", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "trim_prefix", + "libraryFrame": true, + "line": Object { + "context": " layer.handle_request(req, res, next);", + "number": 317, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " });", + " }", + "", + " function trim_prefix(layer, layerError, layerPath, path) {", + " if (layerPath.length !== 0) {", + " // Validate path breaks on a path separator", + " var c = path[layerPath.length]", + ], + "pre": Array [ + " return next(layerError || err);", + " }", + "", + " if (route) {", + " return layer.handle_request(req, res, next);", + " }", + "", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "", + "libraryFrame": true, + "line": Object { + "context": " trim_prefix(layer, layerError, layerPath, path);", + "number": 284, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " }", + "", + " var i = 0;", + " var name;", + " var paramIndex = 0;", + " var key;", + " var paramVal;", + ], + "pre": Array [ + " var params = this.params;", + "", + " // captured parameters from the layer, keys and values", + " var keys = layer.keys;", + "", + " // fast track", + " if (!keys || keys.length === 0) {", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "process_params", + "libraryFrame": true, + "line": Object { + "context": " return done();", + "number": 335, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " if (err) {", + " return next(layerError || err);", + " }", + "", + " if (route) {", + " return layer.handle_request(req, res, next);", + " }", + ], + "pre": Array [ + " // Capture one-time layer values", + " req.params = self.mergeParams", + " ? mergeParams(layer.params, parentParams)", + " : layer.params;", + " var layerPath = layer.path;", + "", + " // this should be done for the layer", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "next", + "libraryFrame": true, + "line": Object { + "context": " self.process_params(layer, paramcalled, req, res, function (err) {", + "number": 275, + }, + }, + Object { + "absPath": "/app/server.js", + "context": Object { + "post": Array [ + "})", + "", + "app.use(require('./server/coffee'))", + "app.use('/api', require('./server/routes'))", + "app.get('*', function (req, res) {", + " res.sendFile(path.resolve(__dirname, 'client/build', 'index.html'))", + "})", + ], + "pre": Array [ + "app.use(require('body-parser').json())", + "app.use(express.static('client/build'))", + "app.use(function (req, res, next) {", + " apm.setTag('foo', 'bar')", + " apm.setTag('lorem', 'ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus, ipsum id scelerisque consequat, enim leo vulputate massa, vel ultricies ante neque ac risus. Curabitur tincidunt vitae sapien id pulvinar. Mauris eu vestibulum tortor. Integer sit amet lorem fringilla, egestas tellus vitae, vulputate purus. Nulla feugiat blandit nunc et semper. Morbi purus libero, mattis sed mauris non, euismod iaculis lacus. Curabitur eleifend ante eros, non faucibus velit lacinia id. Duis posuere libero augue, at dignissim urna consectetur eget. Praesent eu congue est, iaculis finibus augue.')", + " apm.setTag('this-is-a-very-long-tag-name-without-any-spaces', 'test')", + " apm.setTag('multi-line', 'foo\\\\nbar\\\\nbaz')", + ], + }, + "filename": "server.js", + "function": "", + "libraryFrame": false, + "line": Object { + "context": " next()", + "number": 27, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/layer.js", + "context": Object { + "post": Array [ + " } catch (err) {", + " next(err);", + " }", + "};", + "", + "/**", + " * Check if this route matches \`path\`, if so", + ], + "pre": Array [ + "", + " if (fn.length > 3) {", + " // not a standard request handler", + " return next();", + " }", + "", + " try {", + ], + }, + "filename": "node_modules/express/lib/router/layer.js", + "function": "handle", + "libraryFrame": true, + "line": Object { + "context": " fn(req, res, next);", + "number": 95, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " }", + " }", + "};", + "", + "/**", + " * Process any parameters for the layer.", + " * @private", + ], + "pre": Array [ + " }", + "", + " debug('%s %s : %s', layer.name, layerPath, req.originalUrl);", + "", + " if (layerError) {", + " layer.handle_error(layerError, req, res, next);", + " } else {", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "trim_prefix", + "libraryFrame": true, + "line": Object { + "context": " layer.handle_request(req, res, next);", + "number": 317, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " });", + " }", + "", + " function trim_prefix(layer, layerError, layerPath, path) {", + " if (layerPath.length !== 0) {", + " // Validate path breaks on a path separator", + " var c = path[layerPath.length]", + ], + "pre": Array [ + " return next(layerError || err);", + " }", + "", + " if (route) {", + " return layer.handle_request(req, res, next);", + " }", + "", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "", + "libraryFrame": true, + "line": Object { + "context": " trim_prefix(layer, layerError, layerPath, path);", + "number": 284, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " }", + "", + " var i = 0;", + " var name;", + " var paramIndex = 0;", + " var key;", + " var paramVal;", + ], + "pre": Array [ + " var params = this.params;", + "", + " // captured parameters from the layer, keys and values", + " var keys = layer.keys;", + "", + " // fast track", + " if (!keys || keys.length === 0) {", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "process_params", + "libraryFrame": true, + "line": Object { + "context": " return done();", + "number": 335, + }, + }, + Object { + "absPath": "/app/node_modules/express/lib/router/index.js", + "context": Object { + "post": Array [ + " if (err) {", + " return next(layerError || err);", + " }", + "", + " if (route) {", + " return layer.handle_request(req, res, next);", + " }", + ], + "pre": Array [ + " // Capture one-time layer values", + " req.params = self.mergeParams", + " ? mergeParams(layer.params, parentParams)", + " : layer.params;", + " var layerPath = layer.path;", + "", + " // this should be done for the layer", + ], + }, + "filename": "node_modules/express/lib/router/index.js", + "function": "next", + "libraryFrame": true, + "line": Object { + "context": " self.process_params(layer, paramcalled, req, res, function (err) {", + "number": 275, + }, + }, + Object { + "absPath": "/app/node_modules/elastic-apm-node/lib/instrumentation/modules/express.js", + "context": Object { + "post": Array [ + " }", + " }", + " }", + " })", + "", + " return express", + "}", + ], + "pre": Array [ + " return function serveStatic (req, res, next) {", + " req._elastic_apm_static = true", + "", + " return origServeStatic(req, res, nextHook)", + "", + " function nextHook (err) {", + " if (!err) req._elastic_apm_static = false", + ], + }, + "filename": "node_modules/elastic-apm-node/lib/instrumentation/modules/express.js", + "function": "nextHook", + "libraryFrame": true, + "line": Object { + "context": " return next.apply(this, arguments)", + "number": 90, + }, + }, + Object { + "absPath": "/app/node_modules/serve-static/index.js", + "context": Object { + "post": Array [ + " })", + "", + " // pipe", + " stream.pipe(res)", + " }", + "}", + "", + ], + "pre": Array [ + " // forward errors", + " stream.on('error', function error (err) {", + " if (forwardError || !(err.statusCode < 500)) {", + " next(err)", + " return", + " }", + "", + ], + }, + "filename": "node_modules/serve-static/index.js", + "function": "error", + "libraryFrame": true, + "line": Object { + "context": " next()", + "number": 121, + }, + }, + Object { + "absPath": "events.js", + "filename": "events.js", + "function": "emitOne", + "libraryFrame": true, + "line": Object { + "number": 96, + }, + }, + Object { + "absPath": "events.js", + "filename": "events.js", + "function": "emit", + "libraryFrame": true, + "line": Object { + "number": 188, + }, + }, + Object { + "absPath": "/app/node_modules/send/index.js", + "context": Object { + "post": Array [ + " expose: false", + " }))", + " }", + "", + " var res = this.res", + " var msg = statuses[status] || String(status)", + " var doc = createHtmlDocument('Error', escapeHtml(msg))", + ], + "pre": Array [ + " * @param {Error} [err]", + " * @private", + " */", + "", + "SendStream.prototype.error = function error (status, err) {", + " // emit if listeners instead of responding", + " if (hasListeners(this, 'error')) {", + ], + }, + "filename": "node_modules/send/index.js", + "function": "error", + "libraryFrame": true, + "line": Object { + "context": " return this.emit('error', createError(status, err, {", + "number": 270, + }, + }, + Object { + "absPath": "/app/node_modules/send/index.js", + "context": Object { + "post": Array [ + " break", + " default:", + " this.error(500, error)", + " break", + " }", + "}", + "", + ], + "pre": Array [ + " */", + "", + "SendStream.prototype.onStatError = function onStatError (error) {", + " switch (error.code) {", + " case 'ENAMETOOLONG':", + " case 'ENOENT':", + " case 'ENOTDIR':", + ], + }, + "filename": "node_modules/send/index.js", + "function": "onStatError", + "libraryFrame": true, + "line": Object { + "context": " this.error(404, error)", + "number": 421, + }, + }, + Object { + "absPath": "/app/node_modules/send/index.js", + "context": Object { + "post": Array [ + " : self.error(404)", + " }", + "", + " var p = path + '.' + self._extensions[i++]", + "", + " debug('stat \\"%s\\"', p)", + " fs.stat(p, function (err, stat) {", + ], + "pre": Array [ + " self.emit('file', path, stat)", + " self.send(path, stat)", + " })", + "", + " function next (err) {", + " if (self._extensions.length <= i) {", + " return err", + ], + }, + "filename": "node_modules/send/index.js", + "function": "next", + "libraryFrame": true, + "line": Object { + "context": " ? self.onStatError(err)", + "number": 736, + }, + }, + Object { + "absPath": "/app/node_modules/send/index.js", + "context": Object { + "post": Array [ + " }", + " if (err) return self.onStatError(err)", + " if (stat.isDirectory()) return self.redirect(path)", + " self.emit('file', path, stat)", + " self.send(path, stat)", + " })", + "", + ], + "pre": Array [ + " var i = 0", + " var self = this", + "", + " debug('stat \\"%s\\"', path)", + " fs.stat(path, function onstat (err, stat) {", + " if (err && err.code === 'ENOENT' && !extname(path) && path[path.length - 1] !== sep) {", + " // not found, check extensions", + ], + }, + "filename": "node_modules/send/index.js", + "function": "onstat", + "libraryFrame": true, + "line": Object { + "context": " return next(err)", + "number": 725, + }, + }, + Object { + "absPath": "/app/node_modules/elastic-apm-node/lib/instrumentation/index.js", + "context": Object { + "post": Array [ + " ins.currentTransaction = prev", + " return result", + " }", + "}", + "", + "Instrumentation.prototype._recoverTransaction = function (trans) {", + " if (this.currentTransaction === trans) return", + ], + "pre": Array [ + " var trans = this.currentTransaction", + "", + " return elasticAPMCallbackWrapper", + "", + " function elasticAPMCallbackWrapper () {", + " var prev = ins.currentTransaction", + " ins.currentTransaction = trans", + ], + }, + "filename": "node_modules/elastic-apm-node/lib/instrumentation/index.js", + "function": "elasticAPMCallbackWrapper", + "libraryFrame": true, + "line": Object { + "context": " var result = original.apply(this, arguments)", + "number": 116, + }, + }, + Object { + "absPath": "fs.js", + "filename": "fs.js", + "function": "FSReqWrap.oncomplete", + "libraryFrame": true, + "line": Object { + "number": 123, + }, + }, + ], + "type": "TypeError", + }, + "groupingKey": "c00e245c2fbebaf178fc31eeb2bb0250", + "id": "c5e55dfc-09cc-4e0d-ace3-1ba4233f66eb", + }, + "processor": Object { + "event": "error", + "name": "error", + }, + } + } > diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/ActionMenu.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/ActionMenu.tsx index 8486059b3f6fd..beb2764aadab6 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/ActionMenu.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/ActionMenu.tsx @@ -12,7 +12,7 @@ import { } from '@elastic/eui'; import React from 'react'; import { KibanaLink } from 'x-pack/plugins/apm/public/utils/url'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { DiscoverTransactionButton } from '../../../shared/DiscoverButtons/DiscoverTransactionButton'; function getInfraMetricsQuery(transaction: Transaction) { diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/StickyTransactionProperties.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/StickyTransactionProperties.tsx index a057c2eabc476..2ec3163397140 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/StickyTransactionProperties.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/StickyTransactionProperties.tsx @@ -12,7 +12,7 @@ import { TRANSACTION_RESULT, USER_ID } from '../../../../../common/constants'; -import { Transaction } from '../../../../../typings/Transaction'; +import { Transaction } from '../../../../../typings/es_schemas/Transaction'; import { asPercent, asTime } from '../../../../utils/formatters'; // @ts-ignore import { diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/TransactionPropertiesTable.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/TransactionPropertiesTable.tsx index db186e532aea3..3d3a975681a46 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/TransactionPropertiesTable.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/TransactionPropertiesTable.tsx @@ -14,7 +14,7 @@ import { import { capitalize, first, get } from 'lodash'; import React from 'react'; import styled from 'styled-components'; -import { Transaction } from '../../../../../typings/Transaction'; +import { Transaction } from '../../../../../typings/es_schemas/Transaction'; import { IUrlParams } from '../../../../store/urlParams'; import { px, units } from '../../../../style/variables'; import { fromQuery, history, toQuery } from '../../../../utils/url'; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/TransactionPropertiesTableForFlyout.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/TransactionPropertiesTableForFlyout.tsx index 25632040ae325..e9087eaf98e40 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/TransactionPropertiesTableForFlyout.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/TransactionPropertiesTableForFlyout.tsx @@ -8,7 +8,7 @@ import { EuiSpacer, EuiTab, EuiTabs } from '@elastic/eui'; import { capitalize, first, get } from 'lodash'; import React from 'react'; -import { Transaction } from '../../../../../typings/Transaction'; +import { Transaction } from '../../../../../typings/es_schemas/Transaction'; import { IUrlParams } from '../../../../store/urlParams'; // @ts-ignore import { fromQuery, history, toQuery } from '../../../../utils/url'; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/FlyoutTopLevelProperties.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/FlyoutTopLevelProperties.tsx index dc26045151f17..2ad668f347fe9 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/FlyoutTopLevelProperties.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/FlyoutTopLevelProperties.tsx @@ -12,7 +12,7 @@ import { import { StickyProperties } from 'x-pack/plugins/apm/public/components/shared/StickyProperties'; import { TransactionLink } from 'x-pack/plugins/apm/public/components/shared/TransactionLink'; import { KibanaLink } from 'x-pack/plugins/apm/public/utils/url'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; interface Props { transaction?: Transaction; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/DatabaseContext.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/DatabaseContext.tsx index 93266464ecdf5..0302212f18e78 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/DatabaseContext.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/DatabaseContext.tsx @@ -27,7 +27,7 @@ import { xcode } from 'react-syntax-highlighter/dist/styles'; import sql from 'react-syntax-highlighter/dist/languages/sql'; import { EuiTitle } from '@elastic/eui'; -import { DbContext } from '../../../../../../../../typings/Span'; +import { DbContext } from '../../../../../../../../typings/es_schemas/Span'; registerLanguage('sql', sql); diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/HttpContext.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/HttpContext.tsx index 2f760adcd4a88..2e3bd3ab732c5 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/HttpContext.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/HttpContext.tsx @@ -16,7 +16,7 @@ import { } from '../../../../../../../style/variables'; import { EuiTitle } from '@elastic/eui'; -import { HttpContext } from '../../../../../../../../typings/Span'; +import { HttpContext } from '../../../../../../../../typings/es_schemas/Span'; const DatabaseStatement = styled.div` margin-top: ${px(unit)}; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/StickySpanProperties.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/StickySpanProperties.tsx index 8ac9c0b7e0b65..df10562c22cff 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/StickySpanProperties.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/StickySpanProperties.tsx @@ -11,7 +11,7 @@ import { SPAN_NAME, SPAN_TYPE } from 'x-pack/plugins/apm/common/constants'; -import { Span } from '../../../../../../../../typings/Span'; +import { Span } from '../../../../../../../../typings/es_schemas/Span'; import { asMillis, asPercent } from '../../../../../../../utils/formatters'; import { StickyProperties } from '../../../../../../shared/StickyProperties'; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/index.tsx index 471e610daef3f..8c4cc9834fe83 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/index.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/SpanFlyout/index.tsx @@ -33,8 +33,8 @@ import { HttpContext } from './HttpContext'; import { StickySpanProperties } from './StickySpanProperties'; import { DiscoverSpanButton } from 'x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverSpanButton'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; -import { Span } from '../../../../../../../../typings/Span'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; +import { Span } from '../../../../../../../../typings/es_schemas/Span'; import { FlyoutTopLevelProperties } from '../FlyoutTopLevelProperties'; const StackTraceContainer = styled.div` diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/TransactionFlyout/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/TransactionFlyout/index.tsx index 897e0d71035ef..751e37ac24d60 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/TransactionFlyout/index.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/TransactionFlyout/index.tsx @@ -23,7 +23,7 @@ import styled from 'styled-components'; import { DiscoverTransactionButton } from 'x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverTransactionButton'; import { IUrlParams } from 'x-pack/plugins/apm/public/store/urlParams'; import { APM_AGENT_DROPPED_SPANS_DOCS } from 'x-pack/plugins/apm/public/utils/documentation/agents'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { StickyTransactionProperties } from '../../../StickyTransactionProperties'; import { TransactionPropertiesTableForFlyout } from '../../../TransactionPropertiesTableForFlyout'; import { FlyoutTopLevelProperties } from '../FlyoutTopLevelProperties'; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.test.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.test.ts index 71038b9427831..70e517d4ff365 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.test.ts +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.test.ts @@ -5,8 +5,8 @@ */ import { groupBy } from 'lodash'; -import { Span } from 'x-pack/plugins/apm/typings/Span'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Span } from 'x-pack/plugins/apm/typings/es_schemas/Span'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { getClockSkew, getWaterfallItems, diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.ts index ea01288b4f66a..ee4f382f19550 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.ts +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.ts @@ -15,8 +15,8 @@ import { zipObject } from 'lodash'; import { colors } from 'x-pack/plugins/apm/public/style/variables'; -import { Span } from '../../../../../../../../typings/Span'; -import { Transaction } from '../../../../../../../../typings/Transaction'; +import { Span } from '../../../../../../../../typings/es_schemas/Span'; +import { Transaction } from '../../../../../../../../typings/es_schemas/Transaction'; export interface IWaterfallIndex { [key: string]: IWaterfallItem; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/get_agent_marks.test.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/get_agent_marks.test.ts index 609d7f5477e5b..c7784577b31fc 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/get_agent_marks.test.ts +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/get_agent_marks.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { getAgentMarks } from './get_agent_marks'; describe('getAgentMarks', () => { diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/get_agent_marks.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/get_agent_marks.ts index b0968ed7a1af8..165959bca189d 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/get_agent_marks.ts +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/get_agent_marks.ts @@ -5,7 +5,7 @@ */ import { sortBy } from 'lodash'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; export interface AgentMark { name: string; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/index.tsx index 5d78ce85d0775..28e93e8b5e0b2 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/index.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/WaterfallContainer/index.tsx @@ -11,7 +11,7 @@ import { TRACE_ID, TRANSACTION_ID } from '../../../../../../common/constants'; -import { Transaction } from '../../../../../../typings/Transaction'; +import { Transaction } from '../../../../../../typings/es_schemas/Transaction'; import { EuiBadge, EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui'; diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/index.tsx index cea8e117e628f..44683bfc67f0b 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/index.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/index.tsx @@ -15,7 +15,7 @@ import { EuiToolTip } from '@elastic/eui'; import React from 'react'; -import { Transaction as ITransaction } from '../../../../../typings/Transaction'; +import { Transaction as ITransaction } from '../../../../../typings/es_schemas/Transaction'; import { IUrlParams } from '../../../../store/urlParams'; import { DiscoverTransactionButton } from '../../../shared/DiscoverButtons/DiscoverTransactionButton'; import { TransactionLink } from '../../../shared/TransactionLink'; diff --git a/x-pack/plugins/apm/public/components/shared/CodePreview/index.tsx b/x-pack/plugins/apm/public/components/shared/CodePreview/index.tsx index 18f8c6bd01fb8..1d2aa5f8c549b 100644 --- a/x-pack/plugins/apm/public/components/shared/CodePreview/index.tsx +++ b/x-pack/plugins/apm/public/components/shared/CodePreview/index.tsx @@ -25,7 +25,7 @@ import python from 'react-syntax-highlighter/dist/languages/python'; import ruby from 'react-syntax-highlighter/dist/languages/ruby'; // @ts-ignore import { registerLanguage } from 'react-syntax-highlighter/dist/light'; -import { Stackframe } from '../../../../typings/APMDoc'; +import { Stackframe } from '../../../../typings/es_schemas/APMDoc'; import { FrameHeading } from '../Stacktrace/FrameHeading'; // @ts-ignore import { Context } from './Context'; diff --git a/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverErrorButton.tsx b/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverErrorButton.tsx index c07ffa6d704a5..e31bd567546b8 100644 --- a/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverErrorButton.tsx +++ b/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverErrorButton.tsx @@ -9,9 +9,12 @@ import { ERROR_GROUP_ID, SERVICE_NAME } from 'x-pack/plugins/apm/common/constants'; +import { APMError } from 'x-pack/plugins/apm/typings/es_schemas/Error'; import { DiscoverButton } from './DiscoverButton'; -function getDiscoverQuery(serviceName: string, groupId: string, kuery: string) { +function getDiscoverQuery(error: APMError, kuery: string) { + const serviceName = error.context.service.name; + const groupId = error.error.grouping_key; let query = `${SERVICE_NAME}:"${serviceName}" AND ${ERROR_GROUP_ID}:"${groupId}"`; if (kuery) { query = ` AND ${kuery}`; @@ -30,13 +33,12 @@ function getDiscoverQuery(serviceName: string, groupId: string, kuery: string) { } export const DiscoverErrorButton: React.SFC<{ - readonly serviceName: string; - readonly groupId: string; + readonly error: APMError; readonly kuery: string; -}> = ({ serviceName, groupId, kuery, children }) => { +}> = ({ error, kuery, children }) => { return ( ); diff --git a/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverSpanButton.tsx b/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverSpanButton.tsx index baf4435a07542..3c945dcbe5eed 100644 --- a/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverSpanButton.tsx +++ b/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverSpanButton.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { SPAN_HEX_ID, SPAN_ID } from 'x-pack/plugins/apm/common/constants'; -import { Span } from 'x-pack/plugins/apm/typings/Span'; +import { Span } from 'x-pack/plugins/apm/typings/es_schemas/Span'; import { DiscoverButton } from './DiscoverButton'; function getDiscoverQuery(span: Span) { diff --git a/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverTransactionButton.tsx b/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverTransactionButton.tsx index d2ed79b7f9cae..f115eb933db72 100644 --- a/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverTransactionButton.tsx +++ b/x-pack/plugins/apm/public/components/shared/DiscoverButtons/DiscoverTransactionButton.tsx @@ -10,7 +10,7 @@ import { TRACE_ID, TRANSACTION_ID } from 'x-pack/plugins/apm/common/constants'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { DiscoverButton } from './DiscoverButton'; function getDiscoverQuery(transaction: Transaction) { diff --git a/x-pack/plugins/apm/public/components/shared/Stacktrace/FrameHeading.tsx b/x-pack/plugins/apm/public/components/shared/Stacktrace/FrameHeading.tsx index ade59c1b2a715..ecaef31679cf3 100644 --- a/x-pack/plugins/apm/public/components/shared/Stacktrace/FrameHeading.tsx +++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/FrameHeading.tsx @@ -7,7 +7,7 @@ import { get } from 'lodash'; import React, { Fragment } from 'react'; import styled from 'styled-components'; -import { Stackframe } from '../../../../typings/APMDoc'; +import { Stackframe } from '../../../../typings/es_schemas/APMDoc'; import { colors, fontFamilyCode, px, units } from '../../../style/variables'; const FileDetails = styled.div` diff --git a/x-pack/plugins/apm/public/components/shared/Stacktrace/LibraryStackFrames.tsx b/x-pack/plugins/apm/public/components/shared/Stacktrace/LibraryStackFrames.tsx index 2d857a39b0e6c..3503f27df0387 100644 --- a/x-pack/plugins/apm/public/components/shared/Stacktrace/LibraryStackFrames.tsx +++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/LibraryStackFrames.tsx @@ -7,7 +7,7 @@ import { EuiLink } from '@elastic/eui'; import React from 'react'; import styled from 'styled-components'; -import { Stackframe } from '../../../../typings/APMDoc'; +import { Stackframe } from 'x-pack/plugins/apm/typings/es_schemas/APMDoc'; import { px, units } from '../../../style/variables'; import { CodePreview } from '../../shared/CodePreview'; // @ts-ignore diff --git a/x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/stacktraceUtils.test.ts b/x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/stacktraceUtils.test.ts index 8b47b082b0c2e..b5a2709a0de62 100644 --- a/x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/stacktraceUtils.test.ts +++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/stacktraceUtils.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Stackframe } from '../../../../../typings/APMDoc'; +import { Stackframe } from '../../../../../typings/es_schemas/APMDoc'; import { getGroupedStackframes, hasSourceLines } from '../stacktraceUtils'; import stacktracesMock from './stacktraces.json'; diff --git a/x-pack/plugins/apm/public/components/shared/Stacktrace/index.tsx b/x-pack/plugins/apm/public/components/shared/Stacktrace/index.tsx index ddbc5b747799a..42249e60e9d02 100644 --- a/x-pack/plugins/apm/public/components/shared/Stacktrace/index.tsx +++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/index.tsx @@ -7,7 +7,7 @@ import { EuiTitle } from '@elastic/eui'; import { isEmpty } from 'lodash'; import React, { PureComponent } from 'react'; -import { Stackframe } from '../../../../typings/APMDoc'; +import { Stackframe } from '../../../../typings/es_schemas/APMDoc'; import { CodePreview } from '../../shared/CodePreview'; import { EmptyMessage } from '../../shared/EmptyMessage'; // @ts-ignore diff --git a/x-pack/plugins/apm/public/components/shared/Stacktrace/stacktraceUtils.ts b/x-pack/plugins/apm/public/components/shared/Stacktrace/stacktraceUtils.ts index 0798d0a2d78b7..ecf63952fc2ab 100644 --- a/x-pack/plugins/apm/public/components/shared/Stacktrace/stacktraceUtils.ts +++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/stacktraceUtils.ts @@ -5,7 +5,7 @@ */ import { get, isEmpty } from 'lodash'; -import { Stackframe } from '../../../../typings/APMDoc'; +import { Stackframe } from 'x-pack/plugins/apm/typings/es_schemas/APMDoc'; interface StackframesGroup { isLibraryFrame: boolean; diff --git a/x-pack/plugins/apm/public/components/shared/TransactionLink.tsx b/x-pack/plugins/apm/public/components/shared/TransactionLink.tsx index eab7735b5073e..a2b296cd93a09 100644 --- a/x-pack/plugins/apm/public/components/shared/TransactionLink.tsx +++ b/x-pack/plugins/apm/public/components/shared/TransactionLink.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { Transaction } from '../../../typings/Transaction'; +import { Transaction } from '../../../typings/es_schemas/Transaction'; import { KibanaLink, legacyEncodeURIComponent } from '../../utils/url'; interface TransactionLinkProps { diff --git a/x-pack/plugins/apm/public/services/rest/apm/apm.ts b/x-pack/plugins/apm/public/services/rest/apm/apm.ts index 8d457ea758ce3..890b9200924d2 100644 --- a/x-pack/plugins/apm/public/services/rest/apm/apm.ts +++ b/x-pack/plugins/apm/public/services/rest/apm/apm.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Span } from 'x-pack/plugins/apm/typings/Span'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Span } from 'x-pack/plugins/apm/typings/es_schemas/Span'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { convertKueryToEsQuery, getAPMIndexPatternForKuery } from '../../kuery'; export async function getEncodedEsQuery(kuery?: string) { diff --git a/x-pack/plugins/apm/public/services/rest/apm/error_groups.ts b/x-pack/plugins/apm/public/services/rest/apm/error_groups.ts index 7043f83129c03..c4146f3163233 100644 --- a/x-pack/plugins/apm/public/services/rest/apm/error_groups.ts +++ b/x-pack/plugins/apm/public/services/rest/apm/error_groups.ts @@ -4,7 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { camelizeKeys } from 'humps'; +import { ErrorDistributionAPIResponse } from 'x-pack/plugins/apm/server/lib/errors/distribution/get_distribution'; +import { ErrorGroupAPIResponse } from 'x-pack/plugins/apm/server/lib/errors/get_error_group'; +import { ErrorGroupListAPIResponse } from 'x-pack/plugins/apm/server/lib/errors/get_error_groups'; import { IUrlParams } from '../../../store/urlParams'; import { callApi } from '../callApi'; import { getEncodedEsQuery } from './apm'; @@ -24,7 +26,7 @@ export async function loadErrorGroupList({ sortField, sortDirection }: ErrorGroupListParams) { - return callApi({ + return callApi({ pathname: `/api/apm/services/${serviceName}/errors`, query: { start, @@ -44,8 +46,7 @@ export async function loadErrorGroupDetails({ kuery, errorGroupId }: IUrlParams) { - // TODO: add types when error section is converted to ts - const res = await callApi( + return callApi( { pathname: `/api/apm/services/${serviceName}/errors/${errorGroupId}`, query: { @@ -58,11 +59,6 @@ export async function loadErrorGroupDetails({ camelcase: false } ); - const camelizedRes: any = camelizeKeys(res); - if (res.error.context) { - camelizedRes.error.context = res.error.context; - } - return camelizedRes; } export async function loadErrorDistribution({ @@ -72,7 +68,7 @@ export async function loadErrorDistribution({ kuery, errorGroupId }: IUrlParams) { - return callApi({ + return callApi({ pathname: `/api/apm/services/${serviceName}/errors/${errorGroupId}/distribution`, query: { start, diff --git a/x-pack/plugins/apm/public/services/rest/apm/transactions.ts b/x-pack/plugins/apm/public/services/rest/apm/transactions.ts index 7f2f23476db4f..3702b96d16c0a 100644 --- a/x-pack/plugins/apm/public/services/rest/apm/transactions.ts +++ b/x-pack/plugins/apm/public/services/rest/apm/transactions.ts @@ -6,7 +6,7 @@ import { TransactionAPIResponse } from 'x-pack/plugins/apm/server/lib/transactions/get_transaction'; import { SpanListAPIResponse } from 'x-pack/plugins/apm/server/lib/transactions/spans/get_spans'; -import { Span } from 'x-pack/plugins/apm/typings/Span'; +import { Span } from 'x-pack/plugins/apm/typings/es_schemas/Span'; import { IUrlParams } from '../../../store/urlParams'; import { callApi } from '../callApi'; import { addVersion, getEncodedEsQuery } from './apm'; diff --git a/x-pack/plugins/apm/public/store/reactReduxRequest/errorDistribution.js b/x-pack/plugins/apm/public/store/reactReduxRequest/errorDistribution.tsx similarity index 60% rename from x-pack/plugins/apm/public/store/reactReduxRequest/errorDistribution.js rename to x-pack/plugins/apm/public/store/reactReduxRequest/errorDistribution.tsx index a46449e7f6140..18f39e3de16a0 100644 --- a/x-pack/plugins/apm/public/store/reactReduxRequest/errorDistribution.js +++ b/x-pack/plugins/apm/public/store/reactReduxRequest/errorDistribution.tsx @@ -5,19 +5,33 @@ */ import React from 'react'; -import { Request } from 'react-redux-request'; +import { Request, RRRRender } from 'react-redux-request'; +import { ErrorDistributionAPIResponse } from 'x-pack/plugins/apm/server/lib/errors/distribution/get_distribution'; import { loadErrorDistribution } from '../../services/rest/apm/error_groups'; +import { IReduxState } from '../rootReducer'; +import { IUrlParams } from '../urlParams'; +// @ts-ignore import { createInitialDataSelector } from './helpers'; const ID = 'errorDistribution'; -const INITIAL_DATA = { buckets: [], totalHits: 0 }; +const INITIAL_DATA: ErrorDistributionAPIResponse = { + buckets: [], + totalHits: 0, + bucketSize: 0 +}; const withInitialData = createInitialDataSelector(INITIAL_DATA); -export function getErrorDistribution(state) { +export function getErrorDistribution(state: IReduxState) { return withInitialData(state.reactReduxRequest[ID]); } -export function ErrorDistributionRequest({ urlParams, render }) { +export function ErrorDistributionRequest({ + urlParams, + render +}: { + urlParams: IUrlParams; + render: RRRRender; +}) { const { serviceName, start, end, errorGroupId, kuery } = urlParams; if (!(serviceName && start && end && errorGroupId)) { diff --git a/x-pack/plugins/apm/public/store/reactReduxRequest/errorGroup.js b/x-pack/plugins/apm/public/store/reactReduxRequest/errorGroup.tsx similarity index 64% rename from x-pack/plugins/apm/public/store/reactReduxRequest/errorGroup.js rename to x-pack/plugins/apm/public/store/reactReduxRequest/errorGroup.tsx index 4717615783542..85bdf94b431b9 100644 --- a/x-pack/plugins/apm/public/store/reactReduxRequest/errorGroup.js +++ b/x-pack/plugins/apm/public/store/reactReduxRequest/errorGroup.tsx @@ -5,19 +5,29 @@ */ import React from 'react'; -import { createInitialDataSelector } from './helpers'; -import { Request } from 'react-redux-request'; +import { Request, RRRRender } from 'react-redux-request'; +import { ErrorGroupAPIResponse } from 'x-pack/plugins/apm/server/lib/errors/get_error_group'; import { loadErrorGroupDetails } from '../../services/rest/apm/error_groups'; +import { IReduxState } from '../rootReducer'; +import { IUrlParams } from '../urlParams'; +// @ts-ignore +import { createInitialDataSelector } from './helpers'; const ID = 'errorGroupDetails'; -const INITIAL_DATA = {}; +const INITIAL_DATA: ErrorGroupAPIResponse = {}; const withInitialData = createInitialDataSelector(INITIAL_DATA); -export function getErrorGroupDetails(state) { +export function getErrorGroupDetails(state: IReduxState) { return withInitialData(state.reactReduxRequest[ID]); } -export function ErrorGroupDetailsRequest({ urlParams, render }) { +export function ErrorGroupDetailsRequest({ + urlParams, + render +}: { + urlParams: IUrlParams; + render: RRRRender; +}) { const { serviceName, errorGroupId, start, end, kuery } = urlParams; if (!(serviceName && start && end && errorGroupId)) { diff --git a/x-pack/plugins/apm/public/store/reactReduxRequest/errorGroupList.js b/x-pack/plugins/apm/public/store/reactReduxRequest/errorGroupList.tsx similarity index 64% rename from x-pack/plugins/apm/public/store/reactReduxRequest/errorGroupList.js rename to x-pack/plugins/apm/public/store/reactReduxRequest/errorGroupList.tsx index 9863d5f783529..6ac50245d0952 100644 --- a/x-pack/plugins/apm/public/store/reactReduxRequest/errorGroupList.js +++ b/x-pack/plugins/apm/public/store/reactReduxRequest/errorGroupList.tsx @@ -5,19 +5,29 @@ */ import React from 'react'; -import { createInitialDataSelector } from './helpers'; -import { Request } from 'react-redux-request'; +import { Request, RRRRender } from 'react-redux-request'; +import { ErrorGroupListAPIResponse } from 'x-pack/plugins/apm/server/lib/errors/get_error_groups'; import { loadErrorGroupList } from '../../services/rest/apm/error_groups'; +import { IReduxState } from '../rootReducer'; +import { IUrlParams } from '../urlParams'; +// @ts-ignore +import { createInitialDataSelector } from './helpers'; const ID = 'errorGroupList'; -const INITIAL_DATA = []; +const INITIAL_DATA: ErrorGroupListAPIResponse = []; const withInitialData = createInitialDataSelector(INITIAL_DATA); -export function getErrorGroupList(state) { +export function getErrorGroupList(state: IReduxState) { return withInitialData(state.reactReduxRequest[ID]); } -export function ErrorGroupDetailsRequest({ urlParams, render }) { +export function ErrorGroupDetailsRequest({ + urlParams, + render +}: { + urlParams: IUrlParams; + render: RRRRender; +}) { const { serviceName, start, diff --git a/x-pack/plugins/apm/public/store/reactReduxRequest/transactionDetails.tsx b/x-pack/plugins/apm/public/store/reactReduxRequest/transactionDetails.tsx index eab1d2390061b..6e5cc6803cc1b 100644 --- a/x-pack/plugins/apm/public/store/reactReduxRequest/transactionDetails.tsx +++ b/x-pack/plugins/apm/public/store/reactReduxRequest/transactionDetails.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { Request, RRRRender } from 'react-redux-request'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { loadTransaction } from '../../services/rest/apm/transactions'; import { IReduxState } from '../rootReducer'; import { IUrlParams } from '../urlParams'; diff --git a/x-pack/plugins/apm/public/store/reactReduxRequest/waterfall.tsx b/x-pack/plugins/apm/public/store/reactReduxRequest/waterfall.tsx index 13038fdea15d7..5029e88ccaf3a 100644 --- a/x-pack/plugins/apm/public/store/reactReduxRequest/waterfall.tsx +++ b/x-pack/plugins/apm/public/store/reactReduxRequest/waterfall.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { RRRRender } from 'react-redux-request'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { IWaterfall } from '../../components/app/TransactionDetails/Transaction/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers'; import { IUrlParams } from '../urlParams'; import { WaterfallV1Request } from './waterfallV1'; diff --git a/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV1.tsx b/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV1.tsx index 3fe9b1a5f120e..cbcf307267017 100644 --- a/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV1.tsx +++ b/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV1.tsx @@ -11,8 +11,8 @@ import { SERVICE_NAME, TRANSACTION_ID } from 'x-pack/plugins/apm/common/constants'; -import { Span } from 'x-pack/plugins/apm/typings/Span'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Span } from 'x-pack/plugins/apm/typings/es_schemas/Span'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { getWaterfall, IWaterfall diff --git a/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV2.tsx b/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV2.tsx index b5e9a28a13e3d..0291a9b2012af 100644 --- a/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV2.tsx +++ b/x-pack/plugins/apm/public/store/reactReduxRequest/waterfallV2.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { Request, RRRRender } from 'react-redux-request'; import { TRACE_ID } from 'x-pack/plugins/apm/common/constants'; import { TraceAPIResponse } from 'x-pack/plugins/apm/server/lib/traces/get_trace'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { getWaterfall, IWaterfall diff --git a/x-pack/plugins/apm/public/store/urlParams.ts b/x-pack/plugins/apm/public/store/urlParams.ts index b0850aa2cf880..5ac0879b31278 100644 --- a/x-pack/plugins/apm/public/store/urlParams.ts +++ b/x-pack/plugins/apm/public/store/urlParams.ts @@ -157,12 +157,14 @@ export const getUrlParams = createSelector( ); export interface IUrlParams { + detailTab?: string; end?: number; errorGroupId?: string; flyoutDetailTab?: string; - detailTab?: string; kuery?: string; serviceName?: string; + sortDirection?: string; + sortField?: string; start?: number; traceId?: string; transactionId?: string; diff --git a/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.js b/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.ts similarity index 68% rename from x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.js rename to x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.ts index 9d77099e6d94f..c8ec98910ece1 100644 --- a/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.js +++ b/x-pack/plugins/apm/server/lib/errors/distribution/get_buckets.ts @@ -4,13 +4,25 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SERVICE_NAME, ERROR_GROUP_ID } from '../../../../common/constants'; +import { BucketAgg } from 'x-pack/plugins/apm/typings/elasticsearch'; +import { ERROR_GROUP_ID, SERVICE_NAME } from '../../../../common/constants'; +import { Setup } from '../../helpers/setup_request'; -export async function getBuckets({ serviceName, groupId, bucketSize, setup }) { +export async function getBuckets({ + serviceName, + groupId, + bucketSize, + setup +}: { + serviceName: string; + groupId: string; + bucketSize: number; + setup: Setup; +}) { const { start, end, esFilterQuery, client, config } = setup; const params = { - index: config.get('apm_oss.errorIndices'), + index: config.get('apm_oss.errorIndices'), body: { size: 0, query: { @@ -50,7 +62,13 @@ export async function getBuckets({ serviceName, groupId, bucketSize, setup }) { params.body.query.bool.filter.push(esFilterQuery); } - const resp = await client('search', params); + interface Aggs { + distribution: { + buckets: Array>; + }; + } + + const resp = await client('search', params); const buckets = resp.aggregations.distribution.buckets.map(bucket => ({ key: bucket.key, @@ -58,7 +76,7 @@ export async function getBuckets({ serviceName, groupId, bucketSize, setup }) { })); return { - total_hits: resp.hits.total, + totalHits: resp.hits.total, buckets }; } diff --git a/x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.js b/x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.js deleted file mode 100644 index 725f5a74903d8..0000000000000 --- a/x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { getBuckets } from './get_buckets'; - -function getBucketSize({ start, end, config }) { - const bucketTargetCount = config.get('xpack.apm.bucketTargetCount'); - return Math.floor((end - start) / bucketTargetCount); -} - -export async function getDistribution({ serviceName, groupId, setup }) { - const bucketSize = getBucketSize(setup); - const { buckets, total_hits: totalHits } = await getBuckets({ - serviceName, - groupId, - bucketSize, - setup - }); - - return { - total_hits: totalHits, - buckets, - bucket_size: bucketSize - }; -} diff --git a/x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.ts b/x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.ts new file mode 100644 index 0000000000000..c2ec74d76a1e6 --- /dev/null +++ b/x-pack/plugins/apm/server/lib/errors/distribution/get_distribution.ts @@ -0,0 +1,46 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Setup } from '../../helpers/setup_request'; +import { getBuckets } from './get_buckets'; + +function getBucketSize({ start, end, config }: Setup) { + const bucketTargetCount = config.get('xpack.apm.bucketTargetCount'); + return Math.floor((end - start) / bucketTargetCount); +} + +export interface ErrorDistributionAPIResponse { + totalHits: number; + buckets: Array<{ + key: number; + count: number; + }>; + bucketSize: number; +} + +export async function getDistribution({ + serviceName, + groupId, + setup +}: { + serviceName: string; + groupId: string; + setup: Setup; +}): Promise { + const bucketSize = getBucketSize(setup); + const { buckets, totalHits } = await getBuckets({ + serviceName, + groupId, + bucketSize, + setup + }); + + return { + totalHits, + buckets, + bucketSize + }; +} diff --git a/x-pack/plugins/apm/server/lib/errors/get_error_group.js b/x-pack/plugins/apm/server/lib/errors/get_error_group.ts similarity index 58% rename from x-pack/plugins/apm/server/lib/errors/get_error_group.js rename to x-pack/plugins/apm/server/lib/errors/get_error_group.ts index f46a36262b4d2..1f64bd1d6db10 100644 --- a/x-pack/plugins/apm/server/lib/errors/get_error_group.js +++ b/x-pack/plugins/apm/server/lib/errors/get_error_group.ts @@ -4,14 +4,29 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SERVICE_NAME, ERROR_GROUP_ID } from '../../../common/constants'; -import { get } from 'lodash'; +import { oc } from 'ts-optchain'; +import { APMError } from 'x-pack/plugins/apm/typings/es_schemas/Error'; +import { ERROR_GROUP_ID, SERVICE_NAME } from '../../../common/constants'; +import { Setup } from '../helpers/setup_request'; -export async function getErrorGroup({ serviceName, groupId, setup }) { +export interface ErrorGroupAPIResponse { + error?: APMError; + occurrencesCount?: number; +} + +export async function getErrorGroup({ + serviceName, + groupId, + setup +}: { + serviceName: string; + groupId: string; + setup: Setup; +}): Promise { const { start, end, esFilterQuery, client, config } = setup; const params = { - index: config.get('apm_oss.errorIndices'), + index: config.get('apm_oss.errorIndices'), body: { size: 1, query: { @@ -43,11 +58,10 @@ export async function getErrorGroup({ serviceName, groupId, setup }) { params.body.query.bool.filter.push(esFilterQuery); } - const resp = await client('search', params); + const resp = await client('search', params); return { - error: get(resp, 'hits.hits[0]._source', {}), - occurrences_count: get(resp, 'hits.total'), - group_id: get(resp, `hits.hits[0]._source.${ERROR_GROUP_ID}`) + error: oc(resp).hits.hits[0]._source(), + occurrencesCount: oc(resp).hits.total() }; } diff --git a/x-pack/plugins/apm/server/lib/errors/get_error_groups.js b/x-pack/plugins/apm/server/lib/errors/get_error_groups.ts similarity index 57% rename from x-pack/plugins/apm/server/lib/errors/get_error_groups.js rename to x-pack/plugins/apm/server/lib/errors/get_error_groups.ts index 32d3cc685b5d6..5100cbd73297b 100644 --- a/x-pack/plugins/apm/server/lib/errors/get_error_groups.js +++ b/x-pack/plugins/apm/server/lib/errors/get_error_groups.ts @@ -4,27 +4,45 @@ * you may not use this file except in compliance with the Elastic License. */ +import { oc } from 'ts-optchain'; +import { APMError } from 'x-pack/plugins/apm/typings/es_schemas/Error'; import { - SERVICE_NAME, - ERROR_GROUP_ID, ERROR_CULPRIT, + ERROR_EXC_HANDLED, ERROR_EXC_MESSAGE, + ERROR_GROUP_ID, ERROR_LOG_MESSAGE, - ERROR_EXC_HANDLED, - PROCESSOR_EVENT + PROCESSOR_EVENT, + SERVICE_NAME } from '../../../common/constants'; -import { get } from 'lodash'; +import { Setup } from '../helpers/setup_request'; + +interface ErrorResponseItems { + message?: string; + occurrenceCount: number; + culprit?: string; + groupId?: string; + latestOccurrenceAt: string; + handled?: boolean; +} + +export type ErrorGroupListAPIResponse = ErrorResponseItems[]; export async function getErrorGroups({ serviceName, sortField, sortDirection = 'desc', setup -}) { +}: { + serviceName: string; + sortField: string; + sortDirection: 'desc' | 'asc'; + setup: Setup; +}): Promise { const { start, end, esFilterQuery, client, config } = setup; - const params = { - index: config.get('apm_oss.errorIndices'), + const params: any = { + index: config.get('apm_oss.errorIndices'), body: { size: 0, query: { @@ -87,23 +105,58 @@ export async function getErrorGroups({ }; } - const resp = await client('search', params); - const hits = get(resp, 'aggregations.error_groups.buckets', []).map( - bucket => { + interface SampleError { + '@timestamp': APMError['@timestamp']; + error: { + log?: { + message: string; + }; + exception?: { + handled?: boolean; + message?: string; + }; + culprit: APMError['error']['culprit']; + grouping_key: APMError['error']['grouping_key']; + }; + } + + interface Bucket { + key: string; + doc_count: number; + sample: { + hits: { + total: number; + max_score: number | null; + hits: Array<{ + _source: SampleError; + }>; + }; + }; + } + + interface Aggs { + error_groups: { + buckets: Bucket[]; + }; + } + + const resp = await client('search', params); + const hits = oc(resp) + .aggregations.error_groups.buckets([]) + .map(bucket => { const source = bucket.sample.hits.hits[0]._source; const message = - get(source, ERROR_LOG_MESSAGE) || get(source, ERROR_EXC_MESSAGE); + oc(source).error.log.message() || oc(source).error.exception.message(); return { message, occurrenceCount: bucket.doc_count, - culprit: get(source, ERROR_CULPRIT), - groupId: get(source, ERROR_GROUP_ID), + culprit: oc(source).error.culprit(), + groupId: oc(source).error.grouping_key(), latestOccurrenceAt: source['@timestamp'], - handled: get(source, ERROR_EXC_HANDLED) + handled: oc(source).error.exception.handled() }; - } - ); + }); return hits; } diff --git a/x-pack/plugins/apm/server/lib/services/get_service.ts b/x-pack/plugins/apm/server/lib/services/get_service.ts index 05beb6b96883d..c3d8037bf7eb0 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service.ts @@ -5,7 +5,7 @@ */ import { oc } from 'ts-optchain'; -import { TermsAggsBucket } from 'x-pack/plugins/apm/typings/elasticsearch'; +import { BucketAgg } from 'x-pack/plugins/apm/typings/elasticsearch'; import { SERVICE_AGENT_NAME, SERVICE_NAME, @@ -65,10 +65,10 @@ export async function getService( interface Aggs { types: { - buckets: TermsAggsBucket[]; + buckets: BucketAgg[]; }; agents: { - buckets: TermsAggsBucket[]; + buckets: BucketAgg[]; }; } diff --git a/x-pack/plugins/apm/server/lib/services/get_services.ts b/x-pack/plugins/apm/server/lib/services/get_services.ts index 023e889e62fe5..014f1fdefdf9d 100644 --- a/x-pack/plugins/apm/server/lib/services/get_services.ts +++ b/x-pack/plugins/apm/server/lib/services/get_services.ts @@ -5,7 +5,7 @@ */ import { oc } from 'ts-optchain'; -import { TermsAggsBucket } from 'x-pack/plugins/apm/typings/elasticsearch'; +import { BucketAgg } from 'x-pack/plugins/apm/typings/elasticsearch'; import { PROCESSOR_EVENT, SERVICE_AGENT_NAME, @@ -85,19 +85,19 @@ export async function getServices( params.body.query.bool.filter.push(esFilterQuery); } - interface ServiceBucket extends TermsAggsBucket { + interface ServiceBucket extends BucketAgg { avg: { value: number; }; agents: { - buckets: TermsAggsBucket[]; + buckets: BucketAgg[]; }; events: { - buckets: TermsAggsBucket[]; + buckets: BucketAgg[]; }; } - interface Aggs extends TermsAggsBucket { + interface Aggs extends BucketAgg { services: { buckets: ServiceBucket[]; }; diff --git a/x-pack/plugins/apm/server/lib/traces/get_trace.ts b/x-pack/plugins/apm/server/lib/traces/get_trace.ts index 4adb8ece0c81b..64dab397a9979 100644 --- a/x-pack/plugins/apm/server/lib/traces/get_trace.ts +++ b/x-pack/plugins/apm/server/lib/traces/get_trace.ts @@ -6,8 +6,8 @@ import { SearchParams } from 'elasticsearch'; import { TRACE_ID } from '../../../common/constants'; -import { Span } from '../../../typings/Span'; -import { Transaction } from '../../../typings/Transaction'; +import { Span } from '../../../typings/es_schemas/Span'; +import { Transaction } from '../../../typings/es_schemas/Transaction'; import { Setup } from '../helpers/setup_request'; export type TraceAPIResponse = Array; diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts b/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts index eda72b750a7aa..77ba7a9d7bf04 100644 --- a/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts +++ b/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts @@ -10,7 +10,7 @@ import { TRANSACTION_DURATION, TRANSACTION_NAME } from '../../../common/constants'; -import { Transaction } from '../../../typings/Transaction'; +import { Transaction } from '../../../typings/es_schemas/Transaction'; import { Setup } from '../helpers/setup_request'; interface Bucket { diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/transform.ts b/x-pack/plugins/apm/server/lib/transaction_groups/transform.ts index 53f8ca04d4ee6..fb62bfc91adcb 100644 --- a/x-pack/plugins/apm/server/lib/transaction_groups/transform.ts +++ b/x-pack/plugins/apm/server/lib/transaction_groups/transform.ts @@ -6,7 +6,7 @@ import moment from 'moment'; import { oc } from 'ts-optchain'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { ESResponse } from './fetcher'; export interface ITransactionGroup { diff --git a/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/fetcher.ts b/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/fetcher.ts index 746606947aa62..e59d65d61bda6 100644 --- a/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/fetcher.ts +++ b/x-pack/plugins/apm/server/lib/transactions/distribution/get_buckets/fetcher.ts @@ -15,7 +15,7 @@ import { TRANSACTION_TYPE } from 'x-pack/plugins/apm/common/constants'; import { Setup } from 'x-pack/plugins/apm/server/lib/helpers/setup_request'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; interface Bucket { key: number; diff --git a/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts b/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts index e88b17d4ef99c..dc86889a52b27 100644 --- a/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts +++ b/x-pack/plugins/apm/server/lib/transactions/get_transaction/index.ts @@ -6,7 +6,7 @@ import { SearchParams } from 'elasticsearch'; import { oc } from 'ts-optchain'; -import { Transaction } from 'x-pack/plugins/apm/typings/Transaction'; +import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; import { PROCESSOR_EVENT, TRACE_ID, diff --git a/x-pack/plugins/apm/server/lib/transactions/spans/get_spans.ts b/x-pack/plugins/apm/server/lib/transactions/spans/get_spans.ts index a6fb6f7aac711..5a384c5acf83c 100644 --- a/x-pack/plugins/apm/server/lib/transactions/spans/get_spans.ts +++ b/x-pack/plugins/apm/server/lib/transactions/spans/get_spans.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Span } from 'x-pack/plugins/apm/typings/Span'; +import { Span } from 'x-pack/plugins/apm/typings/es_schemas/Span'; import { PROCESSOR_EVENT, SPAN_START, diff --git a/x-pack/plugins/apm/typings/Error.ts b/x-pack/plugins/apm/typings/Error.ts deleted file mode 100644 index b422b1d801a80..0000000000000 --- a/x-pack/plugins/apm/typings/Error.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { APMDocV1, ContextService, Stackframe } from './APMDoc'; - -export interface Error extends APMDocV1 { - processor: { - name: 'error'; - event: 'error'; - }; - context: { - process?: { - pid: number; - }; - service: ContextService; - }; - transaction?: { - id: string; // transaction ID is not required in v1 - }; - error: { - id?: string; // ID is not required in v1 - timestamp: string; - culprit: string; - grouping_key: string; - // either exception or log are given - exception?: { - message?: string; // either message or type are given - type?: string; - code?: string; - module?: string; - attributes?: unknown; - handled?: boolean; - stacktrace?: Stackframe[]; - }; - log?: { - message: string; - param_message?: string; - logger_name?: string; - level?: string; - stacktrace?: Stackframe[]; - }; - }; -} diff --git a/x-pack/plugins/apm/typings/elasticsearch.ts b/x-pack/plugins/apm/typings/elasticsearch.ts index 35b58795ed1ca..ac2c3cacb28d2 100644 --- a/x-pack/plugins/apm/typings/elasticsearch.ts +++ b/x-pack/plugins/apm/typings/elasticsearch.ts @@ -4,19 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SearchResponse } from 'elasticsearch'; - -export interface TermsAggsBucket { - key: string; +export interface BucketAgg { + key: T; doc_count: number; } -type Omit = Pick>; -export type TopHits = Omit< - SearchResponse, - 'took' | 'timed_out' | '_shards' ->; - declare module 'elasticsearch' { // extending SearchResponse to be able to have typed aggregations export interface AggregationSearchResponse diff --git a/x-pack/plugins/apm/typings/APMDoc.ts b/x-pack/plugins/apm/typings/es_schemas/APMDoc.ts similarity index 100% rename from x-pack/plugins/apm/typings/APMDoc.ts rename to x-pack/plugins/apm/typings/es_schemas/APMDoc.ts diff --git a/x-pack/plugins/apm/typings/es_schemas/Error.ts b/x-pack/plugins/apm/typings/es_schemas/Error.ts new file mode 100644 index 0000000000000..a1aa9d6ff21e9 --- /dev/null +++ b/x-pack/plugins/apm/typings/es_schemas/Error.ts @@ -0,0 +1,84 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { APMDocV1, APMDocV2, ContextService, Stackframe } from './APMDoc'; + +interface Agent { + hostname: string; + type: string; + version: string; +} + +interface Processor { + name: 'error'; + event: 'error'; +} + +interface Context { + process?: { + pid: number; + }; + service: ContextService; +} + +interface Exception { + message?: string; // either message or type are given + type?: string; + code?: string; + module?: string; + attributes?: unknown; + handled?: boolean; + stacktrace?: Stackframe[]; +} + +interface Log { + message: string; + param_message?: string; + logger_name?: string; + level?: string; + stacktrace?: Stackframe[]; +} + +interface ErrorV1 extends APMDocV1 { + version: 'v1'; + agent: Agent; + processor: Processor; + context: Context; + transaction?: { + id: string; // transaction ID is not required in v1 + }; + error: { + id?: string; // ID is not required in v1 + timestamp: string; + culprit: string; + grouping_key: string; + // either exception or log are given + exception?: Exception; + log?: Log; + }; +} + +interface ErrorV2 extends APMDocV2 { + version: 'v2'; + agent: Agent; + processor: Processor; + context: Context; + transaction: { + id: string; // transaction ID is required in v2 + }; + error: { + id: string; // ID is required in v2 + timestamp: string; + culprit: string; + grouping_key: string; + // either exception or log are given + exception?: Exception; + log?: Log; + }; +} + +// Not calling it "Error" to avoid clashes with types for native Error +export type APMError = ErrorV1 | ErrorV2; diff --git a/x-pack/plugins/apm/typings/Span.ts b/x-pack/plugins/apm/typings/es_schemas/Span.ts similarity index 100% rename from x-pack/plugins/apm/typings/Span.ts rename to x-pack/plugins/apm/typings/es_schemas/Span.ts diff --git a/x-pack/plugins/apm/typings/Transaction.ts b/x-pack/plugins/apm/typings/es_schemas/Transaction.ts similarity index 100% rename from x-pack/plugins/apm/typings/Transaction.ts rename to x-pack/plugins/apm/typings/es_schemas/Transaction.ts