VOOZH about

URL: https://deepwiki.com/hypervel/telescope/2.2-data-models

⇱ Data Models | hypervel/telescope | DeepWiki


Loading...
Last indexed: 7 February 2026 (146f77)
Menu

Data Models

This document covers the core data structures used to represent monitored entries throughout their lifecycle in Telescope. These models handle entry creation during recording, storage transformation, and retrieval for display in the web interface.

For information about how entries are persisted to storage, see Database Schema. For details on how watchers create entries, see Watchers System.

Overview

Telescope uses two primary data model classes to represent entries at different stages of their lifecycle:

ModelPurposeDirectionFile
IncomingEntryRepresents entries being recorded by watchers before storageWatchers → Storagesrc/IncomingEntry.php13-287
EntryResultRepresents entries retrieved from storage for API/UI displayStorage → API/UIsrc/EntryResult.php11-80

Sources: src/IncomingEntry.php src/EntryResult.php

IncomingEntry Structure

Core Properties

The IncomingEntry class serves as the data container for all monitored events as they flow from watchers to storage. Each instance represents a single recorded event with standardized metadata.

PropertyTypeDescriptionSet At
uuidstringUnique identifier for the entryConstruction src/IncomingEntry.php18-60
batchId?stringGroups related entries (e.g., all entries in one request)Via batchId() method src/IncomingEntry.php23-85
type?stringEntry type constant from EntryType classVia type() method src/IncomingEntry.php28-95
familyHash?stringHash for grouping similar entries (e.g., same SQL query)Via withFamilyHash() method src/IncomingEntry.php33-105
usermixedCurrently authenticated user objectVia user() method src/IncomingEntry.php38-125
contentarray|stringEntry-specific data payloadConstruction src/IncomingEntry.php43-64
tagsarraySearchable tags for filteringVia tags() method src/IncomingEntry.php48-135
recordedAtDateTimeInterfaceTimestamp when entry was createdConstruction src/IncomingEntry.php53-62

Sources: src/IncomingEntry.php13-67

Builder Pattern Implementation

The IncomingEntry class uses a fluent builder pattern, allowing watchers to construct entries incrementally. All setter methods return $this for method chaining.

Construction Example from CommandWatcher:


Builder Methods:

MethodParametersPurposeReturns
make()mixed ...$argumentsStatic factory constructorIncomingEntry src/IncomingEntry.php72-75
batchId()string $batchIdAssigns batch identifier$this src/IncomingEntry.php80-85
type()string $typeSets entry type (e.g., EntryType::REQUEST)$this src/IncomingEntry.php90-95
withFamilyHash()?string $familyHashSets family grouping hash$this src/IncomingEntry.php100-105
user()Authenticatable $userAttaches authenticated user with auto-tagging$this src/IncomingEntry.php110-125
tags()array $tagsMerges additional tags$this src/IncomingEntry.php130-135

The user() method performs three operations: sets the $user property, merges user data into content, and automatically adds an Auth:{id} tag src/IncomingEntry.php110-125

Sources: src/IncomingEntry.php72-135 src/Watchers/CommandWatcher.php35-40

Type Classification Methods

The class provides type-checking predicates used throughout the system for conditional logic and filtering.


Type Predicate Methods:

MethodEntry Type CheckedAdditional LogicLine Reference
isRequest()EntryType::REQUESTNonesrc/IncomingEntry.php154-157
isFailedRequest()EntryType::REQUESTResponse status >= 500src/IncomingEntry.php162-166
isQuery()EntryType::QUERYNonesrc/IncomingEntry.php171-174
isSlowQuery()EntryType::QUERYcontent['slow'] flag setsrc/IncomingEntry.php179-182
isEvent()EntryType::EVENTNonesrc/IncomingEntry.php187-190
isCache()EntryType::CACHENonesrc/IncomingEntry.php195-198
isGate()EntryType::GATENonesrc/IncomingEntry.php203-206
isFailedJob()EntryType::JOBcontent['status'] === 'failed'src/IncomingEntry.php211-215
isLog()EntryType::LOGNonesrc/IncomingEntry.php244-247
isScheduledTask()EntryType::SCHEDULED_TASKNonesrc/IncomingEntry.php252-255
isClientRequest()EntryType::CLIENT_REQUESTNonesrc/IncomingEntry.php260-263

Methods isReportableException(), isException(), and isDump() are defined but return false src/IncomingEntry.php220-239 likely placeholders for future implementation.

Sources: src/IncomingEntry.php154-263

Tag Management and Monitoring

The entry tracks tags for filtering and includes monitoring detection capability:

Tag Operations:

Monitoring Check: The hasMonitoredTag() method queries the repository to determine if any of the entry's tags are being actively monitored src/IncomingEntry.php140-149:


Sources: src/IncomingEntry.php122-149

Storage Transformation

The toArray() method serializes the entry for database persistence src/IncomingEntry.php276-286:


Transformation Details:

  • Property names are converted to snake_case for database columns
  • recordedAt DateTime is formatted as string via toDateTimeString()
  • content array includes hostname from construction src/IncomingEntry.php64
  • Tags are stored separately in a junction table (not included in this array)

Sources: src/IncomingEntry.php276-286

EntryResult Structure

Core Properties

The EntryResult class represents entries retrieved from storage, formatted for JSON serialization and API responses.


Constructor Parameters src/EntryResult.php30-40:

ParameterTypeDescription
idmixedDatabase primary key
sequencemixedEntry sequence number
batchIdstringBatch identifier
typestringEntry type constant
familyHash?stringFamily grouping hash
contentarrayEntry data payload
createdAtCarbonInterfaceTimestamp
tagsarrayAssociated tags (private)

Sources: src/EntryResult.php11-40

Avatar Generation

The generateAvatar() method creates a Gravatar-style avatar URL for the entry's user src/EntryResult.php45-54:


Implementation Details:

  1. Extracts user data from content['user'], defaulting to empty array if not an array src/EntryResult.php47-49
  2. Calls Avatar::url() to generate avatar URL
  3. Stores result in protected $avatar property src/EntryResult.php51
  4. Returns $this for method chaining

Sources: src/EntryResult.php45-54

JSON Serialization

The jsonSerialize() method implements the JsonSerializable interface, providing structured output for API responses src/EntryResult.php59-79:


Serialization Process:

  1. Creates a Collection with all base properties src/EntryResult.php61-70
  2. Conditionally merges avatar URL into content.user.avatar if set using when() src/EntryResult.php70-78
  3. Returns array representation via all() src/EntryResult.php78

Output Structure:


Sources: src/EntryResult.php59-79

Data Lifecycle Flow


Key Transformation Points:

  1. Creation: Watchers instantiate IncomingEntry with event-specific content
  2. Enrichment: Builder methods add metadata (batch ID, type, user, tags)
  3. Classification: Type predicates enable conditional processing
  4. Serialization: toArray() converts to database-compatible format
  5. Persistence: Repository stores entry and tags
  6. Retrieval: Query methods reconstruct entries as EntryResult instances
  7. Presentation: JSON serialization prepares data for web interface

Sources: src/IncomingEntry.php src/EntryResult.php src/Watchers/CommandWatcher.php35-40