Skip to content

Commit 52da71f

Browse files
1 parent dd0e32e commit 52da71f

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

Source/Service/TauriMainProcessService.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,27 @@ const _Trace = (Tag: string, Message: string): void => {
1919
try { performance.mark(`land:${Tag}:${Message}`); } catch {}
2020
};
2121

22+
// Timed trace - wraps an async operation with start/end marks + measure.
23+
// OTELBridge picks up the measure as a span with real duration.
24+
const _TimedTrace = async <T>(
25+
Tag: string,
26+
Label: string,
27+
Fn: () => Promise<T>,
28+
): Promise<T> => {
29+
const MarkName = `land:${Tag}:${Label}`;
30+
const StartMark = `${MarkName}:start`;
31+
try { performance.mark(StartMark); } catch {}
32+
try {
33+
const Result = await Fn();
34+
try { performance.measure(MarkName, StartMark); } catch {}
35+
return Result;
36+
} catch (Error) {
37+
try { performance.mark(`${MarkName}:error`, { detail: { error: String(Error) } }); } catch {}
38+
try { performance.measure(MarkName, StartMark); } catch {}
39+
throw Error;
40+
}
41+
};
42+
2243
// ============================================================================
2344
// Channel → Mountain Route Mapping
2445
// ============================================================================
@@ -172,7 +193,11 @@ class TauriChannel implements IChannel {
172193
Arg !== undefined ? (Array.isArray(Arg) ? Arg : [Arg]) : [];
173194

174195
try {
175-
const Result = await InvokeMountain(MountainMethod, Params);
196+
const Result = await _TimedTrace(
197+
"ipc",
198+
MountainMethod,
199+
() => InvokeMountain(MountainMethod, Params),
200+
);
176201

177202
if (
178203
FileSystemChannels.has(this.ChannelName) &&

0 commit comments

Comments
 (0)