eas-cli 27.1.0 → 27.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +221 -146
- package/build/analytics/AnalyticsManager.d.ts +2 -0
- package/build/analytics/AnalyticsManager.js +2 -0
- package/build/build/build.d.ts +1 -2
- package/build/build/build.js +3 -4
- package/build/build/freeTierNearLimitAgentUpdatesTip.d.ts +98 -0
- package/build/build/freeTierNearLimitAgentUpdatesTip.js +205 -0
- package/build/build/runBuildAndSubmit.d.ts +2 -0
- package/build/build/runBuildAndSubmit.js +3 -0
- package/build/build/simulatorsLaunchHint.d.ts +7 -0
- package/build/build/simulatorsLaunchHint.js +40 -0
- package/build/commands/build/index.js +8 -1
- package/build/commands/observe/session.js +4 -3
- package/build/commands/observe/trace.d.ts +17 -0
- package/build/commands/observe/trace.js +58 -0
- package/build/commands/observe/traces.d.ts +33 -0
- package/build/commands/observe/traces.js +159 -0
- package/build/credentials/ios/appstore/capabilityIdentifiers.js +6 -3
- package/build/graphql/generated.d.ts +404 -0
- package/build/graphql/mutations/UserPreferenceMutation.d.ts +5 -0
- package/build/graphql/mutations/UserPreferenceMutation.js +24 -0
- package/build/graphql/queries/AccountQuery.d.ts +3 -1
- package/build/graphql/queries/AccountQuery.js +54 -0
- package/build/graphql/queries/ObserveQuery.d.ts +24 -1
- package/build/graphql/queries/ObserveQuery.js +114 -1
- package/build/graphql/queries/UserPreferenceQuery.d.ts +8 -0
- package/build/graphql/queries/UserPreferenceQuery.js +28 -0
- package/build/graphql/types/Observe.d.ts +1 -0
- package/build/graphql/types/Observe.js +53 -1
- package/build/observe/fetchSessions.d.ts +12 -1
- package/build/observe/fetchSessions.js +39 -2
- package/build/observe/fetchSpans.d.ts +27 -0
- package/build/observe/fetchSpans.js +36 -0
- package/build/observe/formatSessions.d.ts +3 -1
- package/build/observe/formatSessions.js +40 -3
- package/build/observe/formatSpans.d.ts +110 -0
- package/build/observe/formatSpans.js +250 -0
- package/build/observe/spanFilters.d.ts +5 -0
- package/build/observe/spanFilters.js +32 -0
- package/oclif.manifest.json +1493 -1143
- package/package.json +7 -7
- package/build/build/freeTierLimitGuidance.d.ts +0 -19
- package/build/build/freeTierLimitGuidance.js +0 -39
|
@@ -7,16 +7,38 @@ exports.formatMetricCandidateTitle = formatMetricCandidateTitle;
|
|
|
7
7
|
exports.formatLogCandidateTitle = formatLogCandidateTitle;
|
|
8
8
|
const tslib_1 = require("tslib");
|
|
9
9
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
10
|
+
const formatSpans_1 = require("./formatSpans");
|
|
10
11
|
const formatUtils_1 = require("./formatUtils");
|
|
11
12
|
const metricNames_1 = require("./metricNames");
|
|
12
13
|
const renderTextTable_1 = tslib_1.__importDefault(require("../utils/renderTextTable"));
|
|
14
|
+
const terminalText_1 = require("../utils/terminalText");
|
|
13
15
|
function formatEntryName(entry) {
|
|
14
16
|
if (entry.source === 'metric') {
|
|
15
17
|
const name = (0, metricNames_1.getMetricDisplayName)(entry.name);
|
|
16
18
|
return entry.routeName ? `${name} · ${entry.routeName}` : name;
|
|
17
19
|
}
|
|
20
|
+
if (entry.source === 'span') {
|
|
21
|
+
if (!entry.urlHost) {
|
|
22
|
+
return (0, terminalText_1.sanitizeTerminalText)(entry.name);
|
|
23
|
+
}
|
|
24
|
+
const path = entry.urlFull ? (0, formatSpans_1.formatSpanUrlPath)(entry.urlFull) : '';
|
|
25
|
+
return (0, terminalText_1.sanitizeTerminalText)(`${entry.name} ${entry.urlHost}${path}`);
|
|
26
|
+
}
|
|
18
27
|
return entry.name;
|
|
19
28
|
}
|
|
29
|
+
function formatSpanEntryValue(entry) {
|
|
30
|
+
return typeof entry.durationMs === 'number' ? (0, formatSpans_1.formatSpanDuration)(entry.durationMs) : '-';
|
|
31
|
+
}
|
|
32
|
+
function formatSpanEntryProperties(entry) {
|
|
33
|
+
const parts = [`status=${entry.statusCode ?? '-'}`];
|
|
34
|
+
if (entry.httpStatusCode != null) {
|
|
35
|
+
parts.push(`http=${entry.httpStatusCode}`);
|
|
36
|
+
}
|
|
37
|
+
else if (entry.httpErrorType) {
|
|
38
|
+
parts.push(`error=${entry.httpErrorType}`);
|
|
39
|
+
}
|
|
40
|
+
return parts.join(' ');
|
|
41
|
+
}
|
|
20
42
|
function formatMetricEntryValue(entry) {
|
|
21
43
|
if (typeof entry.value === 'number') {
|
|
22
44
|
return `${entry.value.toFixed(2)}s`;
|
|
@@ -62,13 +84,24 @@ function buildObserveSessionEventsTable(entries, options) {
|
|
|
62
84
|
const rows = [];
|
|
63
85
|
for (const entry of entries) {
|
|
64
86
|
const offset = formatOffsetSeconds(startIso, entry.timestamp);
|
|
65
|
-
const type = entry.source
|
|
87
|
+
const type = entry.source;
|
|
66
88
|
const name = formatEntryName(entry);
|
|
67
89
|
const severity = formatEntrySeverity(entry);
|
|
68
90
|
if (entry.source === 'metric') {
|
|
69
91
|
rows.push([offset, type, name, formatMetricEntryValue(entry), '-', severity]);
|
|
70
92
|
continue;
|
|
71
93
|
}
|
|
94
|
+
if (entry.source === 'span') {
|
|
95
|
+
rows.push([
|
|
96
|
+
offset,
|
|
97
|
+
type,
|
|
98
|
+
name,
|
|
99
|
+
formatSpanEntryValue(entry),
|
|
100
|
+
formatSpanEntryProperties(entry),
|
|
101
|
+
severity,
|
|
102
|
+
]);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
72
105
|
const propLines = primitivePropertyLines(entry);
|
|
73
106
|
if (propLines.length === 0) {
|
|
74
107
|
rows.push([offset, type, name, '-', '-', severity]);
|
|
@@ -80,7 +113,7 @@ function buildObserveSessionEventsTable(entries, options) {
|
|
|
80
113
|
}
|
|
81
114
|
}
|
|
82
115
|
lines.push((0, renderTextTable_1.default)(headers, rows));
|
|
83
|
-
if (options?.hasMoreMetricEvents || options?.hasMoreLogEvents) {
|
|
116
|
+
if (options?.hasMoreMetricEvents || options?.hasMoreLogEvents || options?.hasMoreSpans) {
|
|
84
117
|
const sources = [];
|
|
85
118
|
if (options.hasMoreMetricEvents) {
|
|
86
119
|
sources.push('metric events');
|
|
@@ -88,17 +121,21 @@ function buildObserveSessionEventsTable(entries, options) {
|
|
|
88
121
|
if (options.hasMoreLogEvents) {
|
|
89
122
|
sources.push('log events');
|
|
90
123
|
}
|
|
124
|
+
if (options.hasMoreSpans) {
|
|
125
|
+
sources.push('spans');
|
|
126
|
+
}
|
|
91
127
|
lines.push('', chalk_1.default.yellow(`More ${sources.join(' and ')} are available for this session; only the first 100 of each are shown.`));
|
|
92
128
|
}
|
|
93
129
|
return lines.join('\n');
|
|
94
130
|
}
|
|
95
|
-
function buildObserveSessionEventsJson(entries, sessionId, metadata, hasMoreMetricEvents, hasMoreLogEvents) {
|
|
131
|
+
function buildObserveSessionEventsJson(entries, sessionId, metadata, hasMoreMetricEvents, hasMoreLogEvents, hasMoreSpans) {
|
|
96
132
|
return {
|
|
97
133
|
sessionId,
|
|
98
134
|
metadata,
|
|
99
135
|
entries,
|
|
100
136
|
hasMoreMetricEvents,
|
|
101
137
|
hasMoreLogEvents,
|
|
138
|
+
hasMoreSpans,
|
|
102
139
|
};
|
|
103
140
|
}
|
|
104
141
|
/**
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { AppObserveSpan, AppObserveSpanName, AppObserveTrace, PageInfo } from '../graphql/generated';
|
|
2
|
+
export declare function formatSpanDuration(durationMs: number): string;
|
|
3
|
+
/**
|
|
4
|
+
* The HTTP response status code, or the client-side error type when the
|
|
5
|
+
* request got no response, or "-" for a span that is not an HTTP request.
|
|
6
|
+
*/
|
|
7
|
+
export declare function formatSpanHttpStatus(span: AppObserveSpan): string;
|
|
8
|
+
/** The path and query of a full URL; the URL itself when it does not parse. */
|
|
9
|
+
export declare function formatSpanUrlPath(urlFull: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* One-line title for a span: the HTTP method, host, and path for a request
|
|
12
|
+
* span (`GET api.example.com/users`), else the span name.
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatSpanTitle(span: AppObserveSpan): string;
|
|
15
|
+
export interface ObserveSpanHttpJson {
|
|
16
|
+
method: string | null;
|
|
17
|
+
statusCode: number | null;
|
|
18
|
+
urlHost: string | null;
|
|
19
|
+
urlFull: string | null;
|
|
20
|
+
protocolVersion: string | null;
|
|
21
|
+
requestSize: number | null;
|
|
22
|
+
responseSize: number | null;
|
|
23
|
+
errorType: string | null;
|
|
24
|
+
}
|
|
25
|
+
export interface ObserveSpanJson {
|
|
26
|
+
id: string;
|
|
27
|
+
traceId: string;
|
|
28
|
+
spanId: string;
|
|
29
|
+
parentSpanId: string | null;
|
|
30
|
+
name: string;
|
|
31
|
+
kind: string;
|
|
32
|
+
startTimestamp: string;
|
|
33
|
+
endTimestamp: string;
|
|
34
|
+
durationMs: number;
|
|
35
|
+
statusCode: string;
|
|
36
|
+
statusMessage: string | null;
|
|
37
|
+
sessionId: string | null;
|
|
38
|
+
http: ObserveSpanHttpJson | null;
|
|
39
|
+
attributes: Array<{
|
|
40
|
+
key: string;
|
|
41
|
+
value: string;
|
|
42
|
+
type: string;
|
|
43
|
+
}>;
|
|
44
|
+
events: Array<{
|
|
45
|
+
name: string;
|
|
46
|
+
timestamp: string;
|
|
47
|
+
attributes: unknown;
|
|
48
|
+
}>;
|
|
49
|
+
droppedAttributesCount: number;
|
|
50
|
+
droppedEventsCount: number;
|
|
51
|
+
droppedLinksCount: number;
|
|
52
|
+
ingestedAt: string | null;
|
|
53
|
+
appVersion: string;
|
|
54
|
+
appBuildNumber: string;
|
|
55
|
+
appUpdateId: string | null;
|
|
56
|
+
appEasBuildId: string | null;
|
|
57
|
+
expoSdkVersion: string | null;
|
|
58
|
+
reactNativeVersion: string | null;
|
|
59
|
+
deviceModel: string;
|
|
60
|
+
deviceOs: string;
|
|
61
|
+
deviceOsVersion: string;
|
|
62
|
+
environment: string | null;
|
|
63
|
+
easClientId: string;
|
|
64
|
+
countryCode: string | null;
|
|
65
|
+
}
|
|
66
|
+
export declare function buildObserveSpanJson(span: AppObserveSpan): ObserveSpanJson;
|
|
67
|
+
export interface BuildSpanNamesTableOptions {
|
|
68
|
+
daysBack?: number;
|
|
69
|
+
startTime?: string;
|
|
70
|
+
endTime?: string;
|
|
71
|
+
isTruncated?: boolean;
|
|
72
|
+
}
|
|
73
|
+
export declare function buildObserveSpanNamesTable(names: AppObserveSpanName[], options?: BuildSpanNamesTableOptions): string;
|
|
74
|
+
export declare function buildObserveSpanNamesJson(names: AppObserveSpanName[], isTruncated: boolean): {
|
|
75
|
+
names: Array<{
|
|
76
|
+
name: string;
|
|
77
|
+
kind: string;
|
|
78
|
+
count: number;
|
|
79
|
+
}>;
|
|
80
|
+
isTruncated: boolean;
|
|
81
|
+
};
|
|
82
|
+
export interface BuildSpansTableOptions {
|
|
83
|
+
daysBack?: number;
|
|
84
|
+
startTime?: string;
|
|
85
|
+
endTime?: string;
|
|
86
|
+
sessionId?: string;
|
|
87
|
+
}
|
|
88
|
+
export declare function buildObserveSpansTable(spans: AppObserveSpan[], pageInfo: PageInfo, options?: BuildSpansTableOptions): string;
|
|
89
|
+
export declare function buildObserveSpansJson(spans: AppObserveSpan[], pageInfo: PageInfo): {
|
|
90
|
+
spans: ObserveSpanJson[];
|
|
91
|
+
pageInfo: {
|
|
92
|
+
hasNextPage: boolean;
|
|
93
|
+
endCursor: string | null;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
export interface TraceTreeRow {
|
|
97
|
+
span: AppObserveSpan;
|
|
98
|
+
depth: number;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Orders a trace's spans depth-first, children under their parent, siblings
|
|
102
|
+
* oldest first. A span whose parent is not in the trace is shown as a root.
|
|
103
|
+
*/
|
|
104
|
+
export declare function orderTraceSpans(spans: AppObserveSpan[]): TraceTreeRow[];
|
|
105
|
+
export declare function buildObserveTraceTable(trace: AppObserveTrace): string;
|
|
106
|
+
export declare function buildObserveTraceJson(trace: AppObserveTrace): {
|
|
107
|
+
id: string;
|
|
108
|
+
isTruncated: boolean;
|
|
109
|
+
spans: ObserveSpanJson[];
|
|
110
|
+
};
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatSpanDuration = formatSpanDuration;
|
|
4
|
+
exports.formatSpanHttpStatus = formatSpanHttpStatus;
|
|
5
|
+
exports.formatSpanUrlPath = formatSpanUrlPath;
|
|
6
|
+
exports.formatSpanTitle = formatSpanTitle;
|
|
7
|
+
exports.buildObserveSpanJson = buildObserveSpanJson;
|
|
8
|
+
exports.buildObserveSpanNamesTable = buildObserveSpanNamesTable;
|
|
9
|
+
exports.buildObserveSpanNamesJson = buildObserveSpanNamesJson;
|
|
10
|
+
exports.buildObserveSpansTable = buildObserveSpansTable;
|
|
11
|
+
exports.buildObserveSpansJson = buildObserveSpansJson;
|
|
12
|
+
exports.orderTraceSpans = orderTraceSpans;
|
|
13
|
+
exports.buildObserveTraceTable = buildObserveTraceTable;
|
|
14
|
+
exports.buildObserveTraceJson = buildObserveTraceJson;
|
|
15
|
+
const tslib_1 = require("tslib");
|
|
16
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
17
|
+
const renderTextTable_1 = tslib_1.__importDefault(require("../utils/renderTextTable"));
|
|
18
|
+
const terminalText_1 = require("../utils/terminalText");
|
|
19
|
+
const formatUtils_1 = require("./formatUtils");
|
|
20
|
+
function formatSpanDuration(durationMs) {
|
|
21
|
+
const wholeMs = Math.round(durationMs);
|
|
22
|
+
if (wholeMs >= 1000) {
|
|
23
|
+
return `${(durationMs / 1000).toFixed(2)}s`;
|
|
24
|
+
}
|
|
25
|
+
return `${wholeMs}ms`;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The HTTP response status code, or the client-side error type when the
|
|
29
|
+
* request got no response, or "-" for a span that is not an HTTP request.
|
|
30
|
+
*/
|
|
31
|
+
function formatSpanHttpStatus(span) {
|
|
32
|
+
if (span.http?.statusCode != null) {
|
|
33
|
+
return String(span.http.statusCode);
|
|
34
|
+
}
|
|
35
|
+
return span.http?.errorType ?? '-';
|
|
36
|
+
}
|
|
37
|
+
/** The path and query of a full URL; the URL itself when it does not parse. */
|
|
38
|
+
function formatSpanUrlPath(urlFull) {
|
|
39
|
+
try {
|
|
40
|
+
const url = new URL(urlFull);
|
|
41
|
+
return `${url.pathname}${url.search}`;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return urlFull;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* One-line title for a span: the HTTP method, host, and path for a request
|
|
49
|
+
* span (`GET api.example.com/users`), else the span name.
|
|
50
|
+
*/
|
|
51
|
+
function formatSpanTitle(span) {
|
|
52
|
+
const host = span.http?.urlHost;
|
|
53
|
+
if (!host) {
|
|
54
|
+
return span.name;
|
|
55
|
+
}
|
|
56
|
+
const path = span.http?.urlFull ? formatSpanUrlPath(span.http.urlFull) : '';
|
|
57
|
+
return `${span.name} ${host}${path}`;
|
|
58
|
+
}
|
|
59
|
+
function buildObserveSpanJson(span) {
|
|
60
|
+
return {
|
|
61
|
+
id: span.id,
|
|
62
|
+
traceId: span.traceId,
|
|
63
|
+
spanId: span.spanId,
|
|
64
|
+
parentSpanId: span.parentSpanId ?? null,
|
|
65
|
+
name: span.name,
|
|
66
|
+
kind: span.kind,
|
|
67
|
+
startTimestamp: span.startTimestamp,
|
|
68
|
+
endTimestamp: span.endTimestamp,
|
|
69
|
+
durationMs: span.durationMs,
|
|
70
|
+
statusCode: span.statusCode,
|
|
71
|
+
statusMessage: span.statusMessage ?? null,
|
|
72
|
+
sessionId: span.sessionId ?? null,
|
|
73
|
+
http: span.http
|
|
74
|
+
? {
|
|
75
|
+
method: span.http.method ?? null,
|
|
76
|
+
statusCode: span.http.statusCode ?? null,
|
|
77
|
+
urlHost: span.http.urlHost ?? null,
|
|
78
|
+
urlFull: span.http.urlFull ?? null,
|
|
79
|
+
protocolVersion: span.http.protocolVersion ?? null,
|
|
80
|
+
requestSize: span.http.requestSize ?? null,
|
|
81
|
+
responseSize: span.http.responseSize ?? null,
|
|
82
|
+
errorType: span.http.errorType ?? null,
|
|
83
|
+
}
|
|
84
|
+
: null,
|
|
85
|
+
attributes: span.attributes.map(a => ({ key: a.key, value: a.value, type: a.type })),
|
|
86
|
+
events: span.events.map(e => ({
|
|
87
|
+
name: e.name,
|
|
88
|
+
timestamp: e.timestamp,
|
|
89
|
+
attributes: e.attributes,
|
|
90
|
+
})),
|
|
91
|
+
droppedAttributesCount: span.droppedAttributesCount,
|
|
92
|
+
droppedEventsCount: span.droppedEventsCount,
|
|
93
|
+
droppedLinksCount: span.droppedLinksCount,
|
|
94
|
+
ingestedAt: span.ingestedAt ?? null,
|
|
95
|
+
appVersion: span.appVersion,
|
|
96
|
+
appBuildNumber: span.appBuildNumber,
|
|
97
|
+
appUpdateId: span.appUpdateId ?? null,
|
|
98
|
+
appEasBuildId: span.appEasBuildId ?? null,
|
|
99
|
+
expoSdkVersion: span.expoSdkVersion ?? null,
|
|
100
|
+
reactNativeVersion: span.reactNativeVersion ?? null,
|
|
101
|
+
deviceModel: span.deviceModel,
|
|
102
|
+
deviceOs: span.deviceOs,
|
|
103
|
+
deviceOsVersion: span.deviceOsVersion,
|
|
104
|
+
environment: span.environment ?? null,
|
|
105
|
+
easClientId: span.easClientId,
|
|
106
|
+
countryCode: span.countryCode ?? null,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function buildObserveSpanNamesTable(names, options) {
|
|
110
|
+
if (names.length === 0) {
|
|
111
|
+
return chalk_1.default.yellow('No spans found.');
|
|
112
|
+
}
|
|
113
|
+
const headers = ['Span Name', 'Kind', 'Count'];
|
|
114
|
+
const rows = names.map(n => [
|
|
115
|
+
(0, terminalText_1.sanitizeTerminalText)(n.name),
|
|
116
|
+
n.kind,
|
|
117
|
+
n.count.toLocaleString(),
|
|
118
|
+
]);
|
|
119
|
+
const lines = [];
|
|
120
|
+
if (options) {
|
|
121
|
+
const timeDesc = (0, formatUtils_1.buildTimeRangeDescription)(options);
|
|
122
|
+
lines.push(chalk_1.default.bold(`Span names ${timeDesc}`.trim()), '');
|
|
123
|
+
}
|
|
124
|
+
lines.push((0, renderTextTable_1.default)(headers, rows));
|
|
125
|
+
if (options?.isTruncated) {
|
|
126
|
+
lines.push('', chalk_1.default.yellow('Result is truncated; not all span names are shown.'));
|
|
127
|
+
}
|
|
128
|
+
lines.push('', 'Pass --all-spans or a span filter such as --name, --host, or --status to list individual spans.');
|
|
129
|
+
return lines.join('\n');
|
|
130
|
+
}
|
|
131
|
+
function buildObserveSpanNamesJson(names, isTruncated) {
|
|
132
|
+
return {
|
|
133
|
+
names: names.map(n => ({ name: n.name, kind: n.kind, count: n.count })),
|
|
134
|
+
isTruncated,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function buildObserveSpansTable(spans, pageInfo, options) {
|
|
138
|
+
if (spans.length === 0) {
|
|
139
|
+
return chalk_1.default.yellow('No spans found.');
|
|
140
|
+
}
|
|
141
|
+
const headers = [
|
|
142
|
+
'Timestamp',
|
|
143
|
+
'Name',
|
|
144
|
+
'Duration',
|
|
145
|
+
'Status',
|
|
146
|
+
'HTTP',
|
|
147
|
+
'Host',
|
|
148
|
+
'App Version',
|
|
149
|
+
'Platform',
|
|
150
|
+
'Trace ID',
|
|
151
|
+
];
|
|
152
|
+
const rows = spans.map(span => [
|
|
153
|
+
(0, formatUtils_1.formatLogTimestamp)(span.startTimestamp),
|
|
154
|
+
(0, terminalText_1.sanitizeTerminalText)(span.name),
|
|
155
|
+
formatSpanDuration(span.durationMs),
|
|
156
|
+
span.statusCode,
|
|
157
|
+
formatSpanHttpStatus(span),
|
|
158
|
+
(0, terminalText_1.sanitizeTerminalText)(span.http?.urlHost ?? '-'),
|
|
159
|
+
`${span.appVersion} (${span.appBuildNumber})`,
|
|
160
|
+
`${span.deviceOs} ${span.deviceOsVersion}`,
|
|
161
|
+
span.traceId,
|
|
162
|
+
]);
|
|
163
|
+
const lines = [];
|
|
164
|
+
if (options) {
|
|
165
|
+
const subject = options.sessionId ? `Spans in session ${options.sessionId}` : 'Spans';
|
|
166
|
+
const timeDesc = options.sessionId ? '' : (0, formatUtils_1.buildTimeRangeDescription)(options);
|
|
167
|
+
lines.push(chalk_1.default.bold(`${subject} ${timeDesc}`.trim()), '');
|
|
168
|
+
}
|
|
169
|
+
lines.push((0, renderTextTable_1.default)(headers, rows));
|
|
170
|
+
lines.push('', 'Show a whole trace: eas observe:trace <Trace ID>');
|
|
171
|
+
if (pageInfo.hasNextPage && pageInfo.endCursor) {
|
|
172
|
+
lines.push('', `Next page: --after ${pageInfo.endCursor}`);
|
|
173
|
+
}
|
|
174
|
+
return lines.join('\n');
|
|
175
|
+
}
|
|
176
|
+
function buildObserveSpansJson(spans, pageInfo) {
|
|
177
|
+
return {
|
|
178
|
+
spans: spans.map(buildObserveSpanJson),
|
|
179
|
+
pageInfo: {
|
|
180
|
+
hasNextPage: pageInfo.hasNextPage,
|
|
181
|
+
endCursor: pageInfo.endCursor ?? null,
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function compareByStart(a, b) {
|
|
186
|
+
if (a.startTimestamp !== b.startTimestamp) {
|
|
187
|
+
return a.startTimestamp < b.startTimestamp ? -1 : 1;
|
|
188
|
+
}
|
|
189
|
+
return a.spanId < b.spanId ? -1 : a.spanId > b.spanId ? 1 : 0;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Orders a trace's spans depth-first, children under their parent, siblings
|
|
193
|
+
* oldest first. A span whose parent is not in the trace is shown as a root.
|
|
194
|
+
*/
|
|
195
|
+
function orderTraceSpans(spans) {
|
|
196
|
+
const spanIds = new Set(spans.map(span => span.spanId));
|
|
197
|
+
const childrenByParent = new Map();
|
|
198
|
+
for (const span of spans) {
|
|
199
|
+
const parentKey = span.parentSpanId && spanIds.has(span.parentSpanId) ? span.parentSpanId : null;
|
|
200
|
+
const siblings = childrenByParent.get(parentKey) ?? [];
|
|
201
|
+
siblings.push(span);
|
|
202
|
+
childrenByParent.set(parentKey, siblings);
|
|
203
|
+
}
|
|
204
|
+
const rows = [];
|
|
205
|
+
const visit = (parentKey, depth) => {
|
|
206
|
+
const children = childrenByParent.get(parentKey) ?? [];
|
|
207
|
+
for (const span of [...children].sort(compareByStart)) {
|
|
208
|
+
rows.push({ span, depth });
|
|
209
|
+
visit(span.spanId, depth + 1);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
visit(null, 0);
|
|
213
|
+
return rows;
|
|
214
|
+
}
|
|
215
|
+
function buildObserveTraceTable(trace) {
|
|
216
|
+
const rows = orderTraceSpans(trace.spans);
|
|
217
|
+
const lines = [chalk_1.default.bold(`Trace ${trace.id}`), ''];
|
|
218
|
+
if (rows.length === 0) {
|
|
219
|
+
lines.push(chalk_1.default.yellow('No spans found for this trace.'));
|
|
220
|
+
return lines.join('\n');
|
|
221
|
+
}
|
|
222
|
+
const sessionId = trace.spans.find(span => span.sessionId)?.sessionId;
|
|
223
|
+
const first = rows[0].span;
|
|
224
|
+
lines.push(`Started: ${(0, formatUtils_1.formatLogTimestamp)(first.startTimestamp)}`, `Spans: ${rows.length}${trace.isTruncated ? ' (truncated)' : ''}`, `App version: ${first.appVersion} (${first.appBuildNumber})`, `Device: ${(0, terminalText_1.sanitizeTerminalText)(first.deviceModel)} · ${first.deviceOs} ${first.deviceOsVersion}`, `Session: ${sessionId ?? '-'}`, '');
|
|
225
|
+
const traceStartMs = Math.min(...trace.spans.map(span => new Date(span.startTimestamp).getTime()));
|
|
226
|
+
const headers = ['Offset', 'Duration', 'Name', 'Status', 'HTTP', 'URL'];
|
|
227
|
+
const tableRows = rows.map(({ span, depth }) => [
|
|
228
|
+
formatSpanDuration(new Date(span.startTimestamp).getTime() - traceStartMs),
|
|
229
|
+
formatSpanDuration(span.durationMs),
|
|
230
|
+
`${' '.repeat(depth)}${(0, terminalText_1.sanitizeTerminalText)(span.name)}`,
|
|
231
|
+
span.statusCode,
|
|
232
|
+
formatSpanHttpStatus(span),
|
|
233
|
+
(0, terminalText_1.sanitizeTerminalText)(span.http?.urlFull ?? '-'),
|
|
234
|
+
]);
|
|
235
|
+
lines.push((0, renderTextTable_1.default)(headers, tableRows));
|
|
236
|
+
if (trace.isTruncated) {
|
|
237
|
+
lines.push('', chalk_1.default.yellow('This trace has more spans than are shown.'));
|
|
238
|
+
}
|
|
239
|
+
if (sessionId) {
|
|
240
|
+
lines.push('', `Show the session timeline: eas observe:session ${sessionId}`);
|
|
241
|
+
}
|
|
242
|
+
return lines.join('\n');
|
|
243
|
+
}
|
|
244
|
+
function buildObserveTraceJson(trace) {
|
|
245
|
+
return {
|
|
246
|
+
id: trace.id,
|
|
247
|
+
isTruncated: trace.isTruncated,
|
|
248
|
+
spans: orderTraceSpans(trace.spans).map(({ span }) => buildObserveSpanJson(span)),
|
|
249
|
+
};
|
|
250
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AppObserveSpanKind, AppObserveSpanStatusCode } from '../graphql/generated';
|
|
2
|
+
export declare const allowedSpanKindFlagValues: string[];
|
|
3
|
+
export declare const allowedSpanStatusFlagValues: string[];
|
|
4
|
+
export declare function spanKindsFromFlag(values: string[] | undefined): AppObserveSpanKind[] | undefined;
|
|
5
|
+
export declare function spanStatusCodesFromFlag(values: string[] | undefined): AppObserveSpanStatusCode[] | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.allowedSpanStatusFlagValues = exports.allowedSpanKindFlagValues = void 0;
|
|
4
|
+
exports.spanKindsFromFlag = spanKindsFromFlag;
|
|
5
|
+
exports.spanStatusCodesFromFlag = spanStatusCodesFromFlag;
|
|
6
|
+
const generated_1 = require("../graphql/generated");
|
|
7
|
+
exports.allowedSpanKindFlagValues = Object.values(generated_1.AppObserveSpanKind).map(kind => kind.toLowerCase());
|
|
8
|
+
exports.allowedSpanStatusFlagValues = Object.values(generated_1.AppObserveSpanStatusCode).map(code => code.toLowerCase());
|
|
9
|
+
function spanKindsFromFlag(values) {
|
|
10
|
+
if (!values?.length) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
return values.map(value => {
|
|
14
|
+
const kind = Object.values(generated_1.AppObserveSpanKind).find(k => k.toLowerCase() === value);
|
|
15
|
+
if (!kind) {
|
|
16
|
+
throw new Error(`Unknown span kind flag value: "${value}"`);
|
|
17
|
+
}
|
|
18
|
+
return kind;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function spanStatusCodesFromFlag(values) {
|
|
22
|
+
if (!values?.length) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
return values.map(value => {
|
|
26
|
+
const code = Object.values(generated_1.AppObserveSpanStatusCode).find(c => c.toLowerCase() === value);
|
|
27
|
+
if (!code) {
|
|
28
|
+
throw new Error(`Unknown span status flag value: "${value}"`);
|
|
29
|
+
}
|
|
30
|
+
return code;
|
|
31
|
+
});
|
|
32
|
+
}
|