Skip to content

Commit

Permalink
Merge pull request #6 from jennypavlova/196161-apmotel-fix-an-error-w…
Browse files Browse the repository at this point in the history
…ith-mobile-services

[APM][Otel] Fix an error with mobile services
  • Loading branch information
crespocarlos authored Oct 14, 2024
2 parents cba684f + 937e9f3 commit 40d5fa9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
6 changes: 3 additions & 3 deletions packages/kbn-apm-types/src/es_schemas/raw/transaction_raw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface TransactionRaw extends APMBaseDoc {
trace: { id: string }; // trace is required
event?: { outcome?: EventOutcome };
transaction: {
duration: { us: number };
duration?: { us?: number };
id: string;
marks?: {
// "agent": not defined by APM Server - only sent by RUM agent
Expand All @@ -46,12 +46,12 @@ export interface TransactionRaw extends APMBaseDoc {
name?: string;
page?: Page; // special property for RUM: shared by error and transaction
result?: string;
sampled: boolean;
sampled?: boolean;
span_count?: {
started?: number;
dropped?: number;
};
type: string;
type?: string;
custom?: Record<string, unknown>;
message?: {
queue?: { name: string };
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-apm-types/src/es_schemas/ui/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Agent } from './fields/agent';
// and thus it doesn't make sense to treat it as optional
type InnerTransaction = TransactionRaw['transaction'];
interface InnerTransactionWithName extends InnerTransaction {
name: string;
name?: string;
}

export interface Transaction extends TransactionRaw {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export interface WaterfallTransaction {
event?: { outcome?: EventOutcome };
parent?: { id?: string };
processor: { event: 'transaction' };
transaction: {
duration: { us: number };
transaction?: {
duration?: { us?: number };
id: string;
name: string;
type: string;
name?: string;
type?: string;
result?: string;
};
faas?: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,7 @@ async function getTraceDocsPerPage({
PROCESSOR_EVENT,
] as const);

const requiredTxFields = asMutableArray([
TRANSACTION_ID,
TRANSACTION_DURATION,
TRANSACTION_NAME,
TRANSACTION_TYPE,
] as const);
const requiredTxFields = asMutableArray([TRANSACTION_ID] as const);

const requiredSpanFields = asMutableArray([
SPAN_ID,
Expand All @@ -301,6 +296,9 @@ async function getTraceDocsPerPage({
SPAN_COMPOSITE_SUM,
SPAN_SYNC,
CHILD_ID,
TRANSACTION_NAME,
TRANSACTION_TYPE,
TRANSACTION_DURATION,
] as const);

const body = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,17 @@ export async function getTransaction({
TIMESTAMP_US,
SERVICE_NAME,
TRANSACTION_ID,
] as const);

const optionalFields = asMutableArray([
PROCESSOR_NAME,
SERVICE_LANGUAGE_NAME,
TRANSACTION_DURATION,
TRANSACTION_NAME,
TRANSACTION_SAMPLED,
TRANSACTION_TYPE,
] as const);

const optionalFields = asMutableArray([PROCESSOR_NAME, SERVICE_LANGUAGE_NAME] as const);

const resp = await apmEventClient.search('get_transaction', {
apm: {
sources: [
Expand All @@ -83,7 +86,7 @@ export async function getTransaction({
},
},
fields: [...requiredFields, ...optionalFields],
_source: [SPAN_LINKS, TRANSACTION_AGENT_MARKS],
_source: [SPAN_LINKS, TRANSACTION_AGENT_MARKS, TRANSACTION_NAME],
},
});

Expand Down

0 comments on commit 40d5fa9

Please sign in to comment.