All recording, configuration, and capture operations must run on Unity's main thread.
C# caller attributes supply the calling file, member, and line automatically. The default category is the part of eventName before its first .; names without a separator use General.
Add recording points to game code or event-bus adapters explicitly; the package does not intercept every C# event. Pass the returned session-aware TraceId as parentId to asynchronous and coroutine follow-up work. Causality is not inferred from timestamps.
Recording works in the Editor and Development Builds. Regular release builds return an invalid TraceId. Since method arguments are evaluated before Record is called, guard expensive DTO creation with if (EventTrace.IsEnabled).
| API | Behavior |
|---|---|
EventTrace.Configure(options) |
Validates and copies settings; resizing retains the newest records |
EventTrace.StartSession(name, metadata) |
Creates a session ID, snapshots metadata, and clears the buffer |
EventTrace.Record(...) |
Stores a payload snapshot, caller location, explicit parent ID, and optional call stack |
EventTrace.GetSnapshot() |
Returns the current immutable records in a new array |
EventTrace.Capture() |
Returns a detached capture of the session, records, and dropped count |
EventTrace.Clear() |
Clears the buffer without resetting the session ID or sequence counter |
TraceCapture.ToJson() |
Exports format version 1 JSON |
TraceCapture.FromJson(json) |
Validates format, IDs, sequence, and parent links, then returns a detached capture |
TraceRecord exposes read-only properties. GetSnapshot() returns records in buffer order. Source objects are held through weak references; destroyed objects and imported captures cannot be selected. Runtime object IDs are not persistent identifiers across sessions.
| Setting | Default | Allowed values |
|---|---|---|
enabled |
true |
Enable or disable recording |
captureCaller |
true |
Capture caller file/member/line |
captureStackTrace |
false |
Capture recording-time call stacks |
maxEvents |
10000 |
1–100,000 |
maxPayloadCharacters |
4096 |
128–65,536 |
maxStackTraceCharacters |
8192 |
128–65,536 |
maxBufferCharacters |
4 * 1024 * 1024 |
At least one maximum-sized payload, up to 64M characters |
The buffer evicts the oldest records when either the event-count or character budget is exceeded. DroppedCount includes records discarded by either limit. The character budget limits managed string lengths, not exact process memory; record objects, arrays, rendering, stack formatting, and JSON export need additional memory.
Payload snapshots copy public fields and readable public properties, with a default depth limit of 4 and at most 32 collection or object entries. Unity objects store only name, ID, and type. Oversized payloads use valid JSON: {"$truncated":true}. Cycles become <cycle>, excessive depth becomes <max-depth>, and unreadable properties become <unreadable: ...>. Getter execution time is not bounded, so use small data objects.
If a parent is evicted or belongs to another session, the UI indicates this rather than linking to an unrelated event with the same sequence number.
Caller location and call stack capture are independent. Caller location is enabled by default and stores one file/member/line. Stack capture is disabled by default.
The stack is captured inside Record, before payload getters are evaluated, and omits the recorder's own frame. It represents the synchronous managed call chain at that moment. File names and line numbers are included when debug symbols are available; optimized or IL2CPP builds can provide less detail. Async and coroutine continuations do not recreate earlier execution stacks.
maxStackTraceCharacters defaults to 8,192 and accepts 128–65,536. Longer stacks are truncated. Stored stack characters count toward maxBufferCharacters; a record larger than the entire buffer budget is dropped. The limit bounds retained stack text, not the temporary allocation used to build the string.
JSON contains session ID, name, start UTC, metadata, event and parent IDs, elapsed time and frame, category and severity, payload, source name and object ID, caller location, and optional stack trace. Unity object references are not exported. The optional stack field preserves format version 1 compatibility with older files.
The Editor uses .etr by default. TraceCaptureImporter imports files in Assets as TraceCaptureAsset objects. Its inspector displays a summary and preview and can open the full capture in the browser. Runtime ToJson and FromJson methods do not depend on the file extension.
Imports accept at most 16M characters and 100,000 records. The browser also checks a 16MB file-size limit before reading. Large exports may exceed these limits, so reduce capture limits or split captures.
To run the package's EditMode tests in a consuming project, install Unity Test Framework and add "testables": ["com.achive.event-tracer"] to Packages/manifest.json. The runtime package does not depend on Test Framework or Play Bookmarks.