Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] Adding db statement to simple trace sample #129217

Closed
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/elastic-apm-synthtrace/src/lib/apm/apm_fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,6 @@ export type ApmFields = Fields &
'faas.execution': string;
'faas.trigger.type': string;
'faas.trigger.request_id': string;
'span.db.statement': string;
}> &
ApmApplicationMetricFields;
5 changes: 5 additions & 0 deletions packages/elastic-apm-synthtrace/src/lib/apm/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ export class Span extends BaseSpan {

return this;
}

dbStatement(value: string) {
this.fields['span.db.statement'] = value;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Instance } from '../../lib/apm/instance';
import { Scenario } from '../scenario';
import { getCommonServices } from '../utils/get_common_services';
import { RunOptions } from '../utils/parse_run_cli_flags';
import { mockDbStatement } from './mock/mock_db';

const scenario: Scenario = async (runOptions: RunOptions) => {
const { logger } = getCommonServices(runOptions);
Expand Down Expand Up @@ -38,8 +39,16 @@ const scenario: Scenario = async (runOptions: RunOptions) => {
.duration(1000)
.success()
.children(
instance
.span('GET /products', 'sql', 'mysql')
.dbStatement('SELECT * FROM PRODUCTS')
cauemarcondes marked this conversation as resolved.
Show resolved Hide resolved
.duration(1000)
.success()
.destination('elasticsearch')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does a SQL span talk to ES?

.timestamp(timestamp),
instance
.span('GET apm-*/_search', 'db', 'elasticsearch')
.dbStatement(JSON.stringify(mockDbStatement))
.duration(1000)
.success()
.destination('elasticsearch')
Expand Down
277 changes: 277 additions & 0 deletions packages/elastic-apm-synthtrace/src/scripts/examples/mock/mock_db.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
/*
* 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 const mockDbStatement = {
from: 0,
size: 1000,
_source: [
'parent.id',
'service.name',
'service.environment',
'trace.id',
'processor.event',
'span.id',
'span.type',
'span.subtype',
'span.destination.service.resource',
'agent.name',
'transaction.id',
],
query: {
bool: {
filter: [
{
terms: {
'trace.id': [
'fca31c9a63c413baf339888062ad87a0',
'65ddb4e70865a19e311ada0e57a11b5f',
'fa0638d50848937085b01bdf7e9cee9e',
'f2310020fddb484da919b0fecda0ba80',
'fb80df2772526ec39deb1a9bef684ed0',
'd5dc2e50643ff08010e8b49e0bbbf5ec',
'20a39ef2067450ab54cca248fc8b2d62',
'1a2cfdb5465fd1234e2cbc8889b20544',
'50f0c52af6d1135c001f24d5fa37fc24',
'ff30af37d335aa0fea4b43158c4f79f7',
'f534abbb79d46d945f8fcd748613a50e',
'fd5890bd2da591e1bb1a2f0b0dfca523',
'fff9163790da7e3bfbb7dc888a191e1b',
'fa823198b53ef243c8c1c813ade8b9a5',
'72f51e181547c6289875e4061203a178',
'f938be6f30fa81b9eff34256f8844f55',
'fc253b78172baffb59b229ac1d817f80',
'ff39c346db243b1355d1fe4e5717651e',
'ff61c4305e973b1dca8232302fc2e708',
'ffb1a4c1c0754356b14ca2eb9825e991',
'ebb1896872fd1262a82ea0493b1674f7',
'fe62975ea1c0272a973ea1eccb7e8f53',
'f45f9bff2f419a1d4f324c63c5804b12',
'3f890f868181b2bacedcd31c974e2299',
'fa8af6532251f9aaab1494af90372705',
'ffc1558869e681cd25b4593ef93f65f5',
'fe4bec12ef0d960308dcc97bcd2b0fc5',
'b8e2f30ac0185122433fe61e3634fb19',
'e44ee481730bf3b66d9af28c256e5b20',
'f14aac39dcb098140c8209baa005da6f',
'ff69e93c661cde5ca2f87c1315b05af8',
'c46a19c33c7262075f3e1c16f1f2505b',
'fe149913fda677abebf5e3b3bbd06475',
'fd1020cdafd1ecc018ca0c4cb710d004',
'd2a7b703ca4cb6e9330dd7dfb7c6523c',
'fb1cec4bbf37b618afea1bd61e717a24',
'fb50eae87d402ab7eb4ba6d772dd3c80',
'd898d7fdd80de4f5eefc47ade7f75561',
'fe96e42a9bf5d3a84352fb748c906cb2',
'f4242010bf3a6af591a56ff1e7b34b62',
'f8020702e756560a4b521d9d224f97ef',
'b822c124ee07ee301d7bd8bd0f5c1813',
'f212c868e633238413c7b5c86317156e',
'f89f899cf959bd6b654d841f806b4fca',
'a2f9580c26b9dd0fa4f5217e36b28f5f',
'b4da8c3baede648f1309516f7ea16b15',
'ba2e28aa5ccf4b735ef8224b372c3ddf',
'9a9aa5fa0b36e9ec937c84f645c979b9',
'fc9ea288ce274cba365caef340acd688',
'a3bb6013ea3ce6ad2676f3474b60adf5',
'd95ba0d02564ba4f8e399cc76ea66be4',
'ff8bdb4858d0ffbd3ec090fc3b157e30',
'58c5b97fc05c04f7c3626ff6cdf42868',
'c6fc505506ef462074e08bbcec6192f2',
'9e0c8417dcf3c29e2b33d37c1541b901',
'37293ba16ed399325f643f0ffac3e94b',
'c93df18438d939e74393122e105bd511',
'dc8ad0823bb3b3e7fd3a8fd24348c7a4',
'88ababdd9e2c0e034c4b42b5194bc181',
'a92ea999bc93a701f5e97a56a97dfdbf',
'8a5619b54cd285820df02b7df8d7bcb8',
'f4e360136f934f46f952a790f67ed557',
'd4517cc3feb89aae4b5880be381f577b',
'7a9ca2890fa87d8b95ffc5986a0286e7',
'5c784e8002abb585daebbed0f12783c8',
'e25387ee7ee6b61e15113407806749d8',
'c277c0bfba2d8cef01b79f01107b5571',
'e3015fc34b38b3b047aa2f62d5f138b2',
'ea609a409b2845e06684c4b93dec31e9',
'fccae12eb48b4a9bb2f2dd8f4b974cce',
'626e22d69db9da98d6768f562958d082',
'f79522367207046a921b4a67780ad7f7',
'feb372c2d260b04bbfcc331fbaa3cd10',
'eb11bf57c4fd5aef4be1e255b8d8a28b',
'f6beeb46fc7bb7976c27d0b7ae487ab0',
'67b27fcc841364ffd1f48d6884d59c4a',
'f893c7d8e7fa753f922eff5611dfcb1a',
'fdc12c4df1e164f5a23cc3cf2a061dcd',
'fd8a1ed95b6d550448fb3503de0fd719',
'fd8a246408329a0f0d56dc6263dd29a7',
'e815e6546f1aec27981ca7e1d64b45a2',
'fe42909b9be1e5683e3e916b2d3a3a03',
'f1d28c475a71de3d199305b578f5433e',
'05af0b963d4be2360062fd98172e73ad',
'f0d72691e4b42bca89206a3bbc2c53ff',
'f8b9f35b9265b35dfad6021770363897',
'ff1ad47a006f9c6ad6841dee82aa5679',
'f385c77ace771dc34466053a2cd9b803',
'5a97a167ded4f060fa108131238ccfab',
'eef8a7e597eda3da7540372b0140e1a4',
'fcfca1cd45aa406daffa1427d5fb5b70',
'67e4bb3e6e256aa2df78039bdff1288e',
'f82e402c0f5f473cdfc52934e62b6752',
'fdf0d58ebe10d25fb482f34856ec88f1',
'f5383570bf87d261aa200fe38b6a0f76',
'c3c5eb47d406033a3766e562603873d3',
'6ef01824b669c9843e59d46cffdcc444',
'82474f6a150fba7cbc87c284884727bb',
'f5f074f4bee134d943c41d673075a4aa',
'733e275534b9a257d00086c1e4d34873',
'ea86c0b54d78ed42f7403e37f98dfb68',
'7f96e6b89db7057bfc381c49fa28187c',
'955fd911f04bbc1123803e462bef8218',
'fb795050eb7143fad1a66e07bedab134',
'60b8da9b0bec88ed6d616d94e0c7700b',
'8c66ab62647aba5984952243b8bf0c74',
'68f4c00e37cae46934807d71c18d7cf7',
'27580a4c71e7638b4ae3d46db3bf20a1',
'8a815e5aed3087dbde07d7f1693c52e9',
'5e37aed7c1032ffd3df9d0a10e72ec7e',
'cad738d616ae20c4581cbc3cc2ad4bfb',
'7b6e48a3ff3d33c191db57d4fb8097ab',
'5d3639d1d5bfdf4f4961d9b710ed0c8c',
'6fa37543cc18b3a1f26bbdb14f38aff8',
'a750b032e6d022307b71b5106eedde6c',
'2d92b85faee9aecc8155f15c96ae520e',
'f4e79d0ef6240fd89ad44b74f5f6d935',
'ee7fa23ab5c0f87f6e2c6b3a33158a8c',
'ae4d8c08254d6fb8d209a4f9a7cf1a11',
'f1b831ed9c48cb8f06fc94c7f90ed51c',
'fc77bb5261db42c47ff11801397bfffe',
'fa84f649387c3d19a22475291f139aaa',
'e95aa37f7281dafa19352a1f1c84a46b',
'd28fa26e79785e7ad625fb256cca0c6d',
'fa1466b59d75682d27dd72f9965f847f',
'ef10e2466a3ad2cc910eb98fc46355d0',
'ea00916783756b623685a744017831d3',
'dee373277d9645af04f80bc45b5bf880',
'f33fb5d43de9efd7f8f8cf5e207d95ba',
'fb5446b1cd8514f50d0e36b9c8066839',
'64a8a2c8f6fc5b15a243cae28a6393b7',
'e6956de884b761610151e5ecd4a473af',
'f29ff36e780d9248c2f002c40136820e',
'9efd09d785e70f36228047499f7b905a',
'248076807e7538727b26cd5794d76f7c',
'2eb29b9e6bfcc2f9c707c7ee07953550',
'027f61895b44067126a8287f5f2df9b3',
'7e19e405f81fbf412c1d99185c18bb8c',
'b0654658f12c4896657bbb0c5c4024d5',
'0c8b169936b0da410607a6255ea4fb71',
'e732da6c9e2f844a1af19c26b3cb31eb',
'80190cc082bf81be45b3eccac9971fae',
'371938d78f36c6e504390f4c29534575',
'64903c3a311d1621da4fec18fe3877e4',
'0ac3c48283a6d7b4c886bd2b6e98bce7',
'a2b8f17aa3f5bd078c16744547d8f40f',
'7a14edd8f67488171f2c72d1c07df87d',
'4e9931a23c4e8df2598040424741c6db',
'a63a1769cfa2784711d53d4428b5a0c3',
'1f17ee69bc24c4951dd89a22b5e9a8df',
'f47cd924858833250d2afb3c502926d4',
'ec1b65b19dc9fac79a19f665f6b9d312',
'a589c25294aaeb6b5020b3decad801fc',
'dc35d0d25de2814ddb97a6085d08f2e0',
'8ead33d6fc7174ab7cc297a1cc87b487',
'efb667909bc93ef9dfe32846b9bd46be',
'f6d1e484233d0606c4d053199c8a11d4',
'ef12560ee5e7f14a667e0ff863d298ab',
'e5929b2bc1f6ebab4a63f49031ee5465',
'c52c82d7529f5df29e3dfa496ca2669e',
'f543559f3e3f3d6c82ebe1ab2590145b',
'ed898ec4ae06d9c87e39c0de4c189158',
'e79b86851eb5b63322b1a7f10d57a07e',
'a43e8f72866de72815d07082a84f77bb',
'f0e66d512dcd0f9b37c9bfb6395882cd',
'f5503cfcb750de0994a494aa1ad488fc',
'06daecd68f898811cc00fd8ed9c910e5',
'dee657b6aec9a019e840e7a7f1240741',
'd5f73619540f6692f56b2bcb29058156',
'f240dafb7129cdc4dfd42566528928fa',
'09596e80830e79e60a75098fafde0cf2',
'9b0d57930951088d109877f0fb1307c4',
'bf353e378f36ab77fb51802b15ab7fa2',
'e62c6f641b7ace19fd63226f9c8ab524',
'f5d8a6ef34b69f33e6178a71a6d1f482',
'0781e5e79340bf5f05871ede865935e5',
'f5eb487eb131991cd7705dc0da9fcbda',
'9a1db7823dafd0ef83cc54e788d72a43',
'52eba5390aef91877e4cdceac3d9ece0',
'3912301337188eae6fd1b5d6eacdd443',
'36558079a5d4fd7c694947ab15a2c356',
'4bb77137e496c68e2bb40a299098a44d',
'f17a59e4f112bb5a973a154da02f7acf',
'e36e78a648b2a5e909bdee587e64e577',
'9d2eaf8fce7dd83eee15c5ca26f14634',
'd78a311b38b1843c0772100483615d0a',
'6d9708631388688e53404255c1ee2726',
'ed0d4f53ddc2461e70e7dabe5ffd6464',
'f2e060390ea697f98208669a11a83780',
'ed4b60fa5369ea9f38e97461da22f170',
'e2a747d9da9d27a3cb09157498461508',
'b9d2601c2127190964334d5d054474ec',
'f509a5fd56c8728bd44cd9d5c1b0b64e',
'de64321b55535c6e458cf88741e6acf3',
'df20e0240b044aeb0c4daafe9469da7d',
'a1b18ba135be8515e859099bb0060c0f',
'e004e3f8efb00b0c8242722b1d003bb1',
'e3a5c5637346d021d397170eebe921ff',
'c6b7abe8cca81889073efdd6d7cfa67d',
'ec5d1e6c5ea892d1120f3082d578da60',
'949c44e87b8aa1a1128fbb18c1b6dc3d',
'de882e5daa348b8e4bfe216885f7253d',
'22dd0fbcb5402923e9c6bb1a8e4b1fe4',
'9728cde51b0a130ca6b7a14dab651105',
'7035c8a52ae249e8e6987e84a4a7f2f3',
'0740cae8883711e524bcff2963968814',
'ee87621a9ab35b508f4886c684cfe79e',
'e27e1a51c5d1dd388cf88fcb838c526b',
'3fe1d4ed226b9d6660902bcdef20d5d1',
'e81c0ca258f05e091bfe49f491d45185',
'd2c0f281fe56a00d71cf75749a0fb78a',
'e50a5e6854267272707d94e71ba19636',
'f25169db6bea511d9d89cb172bc1b36a',
'ed29e9ff5f9d1a266e6934c1231c9e9c',
'e21ea9668b23de75fbd231fbd5224122',
'b90cc2a6e25577bb34709d7630710bd7',
'eefe0fa3019e9f94ea6b858166787728',
'da3d85dbb17dd24f89c9f652353ed221',
'dcb80d3abe66b05f1040ba5e60e69003',
'7b98be7be9454dd284707d4da73f633f',
'f171cbc0745edb40adf62e4fa86c3c48',
'dc5ae5aed3cde5fff681ed9e437b1592',
'74e3dc125ce03f958d3ba218acdd45c8',
'e360e3812766f94f910a4ac946bb0af4',
'c681ae645057d4baa962bb700e98ff0b',
'cb9f54d89c1fb51133d6d5466dd25298',
'e842988243e5d878b281ff9de3f5fa0c',
'85c9076b48a7a1207a850ba2a0f5fb8e',
'b35e17db8dbdd74db68a999a50e40966',
'f2e826d779e1adab4644eaa8318f7deb',
'ddf635f30d6f09614940d256bd5179f3',
'08e8e8da8ac0a1e915ec6181fc34d6f4',
'87187964d47609770bf20d0acf5e07d2',
'42fd5ecbedf3ff53fa239389281930e8',
],
},
},
{
range: {
'@timestamp': { gte: 1646670000000, lte: 1646842920000, format: 'epoch_millis' },
},
},
{ terms: { 'processor.event': ['span', 'transaction'] } },
],
},
},
};