Skip to content
Roboto
Esc
↑↓navigate↵open⌘Jpreview
On this page

roboto.domain.metrics

Submodules

Package Contents

AggregateMetricsRequest

class roboto.domain.metrics.AggregateMetricsRequest(/, **data)#View Source

Bases: pydantic.BaseModel

Request payload for a numeric metric aggregation.

Parameters

data Any

Attributes

AggregateMetricsRequest.aggregation

aggregation NumericAggregation #

Aggregation function to apply to the values in each bucket.

AggregateMetricsRequest.condition

condition roboto.query.ConditionType | None = None #

Condition, or nested group of conditions, narrowing which data points are aggregated.

Applied to individual data points rather than to bucket results, so it changes each bucket’s value and total. A period whose data points are all filtered out yields no bucket at all, so a filtered aggregation can return fewer buckets than an unfiltered one over the same window. See condition for the accepted fields and the treatment of data points published without a device.

AggregateMetricsRequest.end_time_ns

end_time_ns int #

Exclusive end of the aggregation window, in Unix-epoch nanoseconds (UTC). Built from aggregate()’s end_time parameter the same way.

AggregateMetricsRequest.group_by

group_by str | None = None #

Field to split the aggregation by, in addition to the period bucket: one NumericAggregateMetricRecord per (period, distinct value) pair, each carrying the value it aggregated under group_key.

None aggregates every matching data point of a period into one bucket. Accepts device.device_id and String, Enum, or Boolean custom fields on sessions and devices (session.custom.<name>, device.custom.<name>); every other field of the vocabulary condition accepts is rejected, since a group key must be single-valued and low-cardinality to be a series. Data points carrying no value for the field are grouped under a null group_key rather than dropped, and the response is not capped: every distinct value with data in the window comes back.

AggregateMetricsRequest.include_device_ids

include_device_ids list[str] | roboto.sentinels.NotSetType | None #

Filter to observations from specific device IDs, None for null device_id only.

AggregateMetricsRequest.include_invocation_ids

include_invocation_ids list[str] | roboto.sentinels.NotSetType | None #

Filter to observations from specific invocation IDs, None for null invocation_id only.

AggregateMetricsRequest.include_session_ids

include_session_ids list[str] | roboto.sentinels.NotSetType #

Filter to observations for specific session IDs. None is not a valid value: metrics.session_id is non-nullable, so there is no “null session” subset to filter on. Omit (leave as NotSet) for no filter, or pass a list of IDs.

AggregateMetricsRequest.model_config

model_config #

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

AggregateMetricsRequest.name

name str #

Name of the metric to aggregate.

AggregateMetricsRequest.period

Calendar bucket size to group observations by.

AggregateMetricsRequest.start_time_ns

start_time_ns int #

Inclusive start of the aggregation window, in Unix-epoch nanoseconds (UTC). Built by aggregate() from its start_time parameter via to_epoch_nanoseconds().

AggregateMetricsRequest.time_filter

time_filter MetricTimeFilter #

Whether to filter by session start time or end time.

AggregationPeriod

class roboto.domain.metrics.AggregationPeriod#View Source

Bases: roboto.compat.StrEnum

Calendar bucket size used when grouping metric observations.

All aggregation start/end times are based on UTC time.

Attributes

AggregationPeriod.Daily

Daily = 'daily' #

One bucket per calendar day.

AggregationPeriod.Monthly

Monthly = 'monthly' #

One bucket per calendar month.

AggregationPeriod.Quarterly

Quarterly = 'quarterly' #

One bucket per calendar quarter (three months).

AggregationPeriod.Weekly

Weekly = 'weekly' #

One bucket per calendar week.

AggregationPeriod.Yearly

Yearly = 'yearly' #

One bucket per calendar year.

CreateMetricDefinitionRequest

class roboto.domain.metrics.CreateMetricDefinitionRequest(/, **data)#View Source

Bases: pydantic.BaseModel

Request payload to create a metric definition.

Parameters

data Any

Attributes

CreateMetricDefinitionRequest.description

description str | None = None #

Human-readable description of what the metric measures.

CreateMetricDefinitionRequest.name

name str #

Unique metric name.

CreateMetricDefinitionRequest.unit

unit MetricUnit | None = None #

Unit of measure for values recorded under this metric, e.g. "%", "ms". Capped at 63 characters. None means unitless.

MAX_METRIC_LIST_RESULTS

roboto.domain.metrics.MAX_METRIC_LIST_RESULTS: int = 10000#View Source

Upper bound on the page size accepted by metric query and list calls.

query() auto-paginates with this value as the default page size, so total result-set size is unbounded. Callers can request smaller pages by setting max_results.

get_by_session() does not paginate and is still capped at this many rows; sessions with more data points should use the paginated query() instead.

Metric

class roboto.domain.metrics.Metric(record, roboto_client)#View Source

A summary value recorded for one session under a metric definition.

Each Metric stores exactly one value per (metric, session) pair. Calling publish() a second time for the same metric name and session_id replaces the previous value (upsert semantics). This makes metrics suitable for recording per-session summary statistics that are computed once (or updated as reprocessing happens), not for streaming time-series data.

Recording a metric (publish()) stores the value under the MetricDefinition with the given name.

Querying metrics (query()) returns the data points with a session timestamp in the given range. Aggregating metrics (aggregate()) groups sessions by the calendar period their stored timestamp falls into and applies a summary function (sum, mean, max, min, or count) across the values in each period.

Metric.aggregate()

classmethod aggregate(name, period, aggregation, start_time, end_time, time_filter=MetricTimeFilter.EndTime, include_device_ids=NotSet, include_session_ids=NotSet, include_invocation_ids=NotSet, condition=None, group_by=None, owner_org_id=None, roboto_client=None)#View Source

Aggregate a metric across sessions, grouped by calendar period.

Sessions whose session_min_timestamp_ns or session_max_timestamp_ns (selected via time_filter) falls inside the [start_time, end_time) window are grouped into UTC calendar buckets sized by period, and the chosen NumericAggregation is applied to the values in each bucket.

The server snaps the requested window outward to whole-period boundaries to guarantee apples-to-apples comparisons. All time period buckets always cover their complete calendar period. For example, * a monthly aggregation requested between Jan 15 – Mar 15 will return aggregated data for all of January, February, and March. * a quarterly aggregation from Apr 27 - Dec 28 will return aggregated data for all of Q2, Q3, and Q4.

Parameters

name str

Name of the metric definition to aggregate.

Calendar bucket size to group observations by.

Function to apply to values in each bucket.

start_time roboto.time.Time

Inclusive start of the aggregation window. Accepts any Time value.

Exclusive end of the aggregation window. Same input shape as start_time.

Whether to match the window against each session’s start time or end time. Defaults to end time.

include_device_ids Optional[Union[list[str], roboto.sentinels.NotSetType]]

Restrict to specific device IDs, or None to match only rows with no device_id.

include_session_ids Union[list[str], roboto.sentinels.NotSetType]

Restrict to specific session IDs.

include_invocation_ids Optional[Union[list[str], roboto.sentinels.NotSetType]]

Restrict to specific invocation IDs, or None to match only rows with no invocation_id.

condition Optional[roboto.query.ConditionType]

Restrict the aggregated data points to those whose session, producing device, or session’s collections match this Condition or ConditionGroup. It narrows what each bucket aggregates without moving the window’s period boundaries; a bucket left with no matching data points is omitted from the result. See condition for the accepted fields, and for how collection conditions evaluate when a session belongs to several collections or to none.

group_by Optional[str]

Split each period bucket by the distinct values of this field, one record per (period, value) pair. Accepts device.device_id and String, Enum, or Boolean custom fields on sessions and devices (session.custom.<name>, device.custom.<name>); any other field is rejected. Data points carrying no value for the field come back under a null group_key rather than being dropped. Defaults to no split.

owner_org_id Optional[str]

Organization that owns the metric data. Defaults to the authenticated caller’s organization.

roboto_client Optional[roboto.http.RobotoClient]

Roboto client to use. Defaults to the client configured in the environment.

Returns

One NumericAggregateMetricRecord per period bucket that contains at least one observation, sorted by start_time ascending. Under group_by, one per (bucket, distinct value) pair instead, each naming its value in group_key.

Raises

No metric with this name exists in the organization.

condition references a field or comparator the request does not accept; condition or group_by references a custom field that is either undefined in your organization or defined but not in the Ready state; or group_by names a field that cannot be a series.

Usage

Daily max CPU usage over a month, passing datetime directly:

import datetime
from roboto.domain.metrics import (
    AggregationPeriod,
    Metric,
    NumericAggregation,
)
for bucket in Metric.aggregate(
    name="cpu.usage_max",
    period=AggregationPeriod.Daily,
    aggregation=NumericAggregation.Max,
    start_time=datetime.datetime(2026, 5, 1, tzinfo=datetime.timezone.utc),
    end_time=datetime.datetime(2026, 6, 1, tzinfo=datetime.timezone.utc),
):
    print(bucket.start_time, bucket.value)

The same aggregation over data points published from a device in the delivery fleet. The Device custom field fleet must be defined by your organization and moved to Ready; the aggregation raises if it has not been. A data point published without a device carries no fleet, so Equals drops it, and NotEquals drops it too: only IsNull and NotExists match a data point with no device. See condition for the full field and comparator rules:

from roboto.query import Comparator, Condition
delivery_buckets = Metric.aggregate(
    name="cpu.usage_max",
    period=AggregationPeriod.Daily,
    aggregation=NumericAggregation.Max,
    start_time="2026-05-01T00:00:00Z",
    end_time="2026-06-01T00:00:00Z",
    condition=Condition(
        field="device.custom.fleet",
        comparator=Comparator.Equals,
        value="delivery",
    ),
)
for bucket in delivery_buckets:
    print(bucket.start_time, bucket.end_time, bucket.value, bucket.total)

One line per robot rather than one line for the fleet. Buckets aggregating data points published without a device come back with group_key set to None:

per_device = Metric.aggregate(
    name="cpu.usage_max",
    period=AggregationPeriod.Daily,
    aggregation=NumericAggregation.Max,
    start_time="2026-05-01T00:00:00Z",
    end_time="2026-06-01T00:00:00Z",
    group_by="device.device_id",
)
for bucket in per_device:
    print(bucket.group_key, bucket.start_time, bucket.value)

Properties

Metric.device_id

device_id str | None #
Return type: Optional[str]

Metric.get_by_session()

classmethod get_by_session(session_id, roboto_client=None)#View Source

Return every metric published to session_id.

Parameters

session_id str

Session whose metrics to fetch.

roboto_client Optional[roboto.http.RobotoClient]

Roboto client to use. Defaults to the client configured in the environment.

Returns

list[Metric]

One Metric per matching (metric_definition, session) pair. May be empty. Order is unspecified.

Usage

from roboto.domain.metrics import Metric
for m in Metric.get_by_session("ss_abc123"):
    print(m.metric_id, m.value)

Properties

Metric.group_key

group_key str | None #
Return type: Optional[str]

Metric.invocation_id

invocation_id str | None #
Return type: Optional[str]

Metric.max_timestamp_ns

max_timestamp_ns int | None #
Return type: Optional[int]

Metric.metric_id

metric_id str #
Return type: str

Metric.min_timestamp_ns

min_timestamp_ns int | None #
Return type: Optional[int]

Metric.name

name str #
Return type: str

Metric.org_id

org_id str #
Return type: str

Metric.publish()

classmethod publish(session_id, metrics, device_id=NotSet, caller_org_id=None, roboto_client=None)#View Source

Record metric values for a session in a single network call.

Each (metric, session) pair is upserted: republishing under the same name and session_id replaces the previous value. Repeating a metric name within one call stores the last value given for it that the platform accepted, and every accepted entry naming that metric reports the stored value.

A metric definition is created for any name the org does not already have one for. When called from within a Roboto action, every recorded value is linked to that action invocation.

Parameters

session_id str

Session to attach every published value to.

Metric names and values to record. An empty list returns an empty response without contacting the platform.

device_id Union[roboto.sentinels.NotSetType, Optional[str]]

Device to associate with every published value, or None to associate none. When omitted, Roboto infers the device from the session’s attached devices, which succeeds only when exactly one device is attached.

caller_org_id Optional[str]

Organization context for the request. Defaults to the authenticated caller’s organization.

roboto_client Optional[roboto.http.RobotoClient]

Roboto client to use. Defaults to the client configured in the environment.

Returns

A BatchResponse holding one element per entry, in request order, carrying either the recorded Metric or the exception the platform refused that entry with. An entry whose value is not finite, or whose name uses a character other than an ASCII letter, a digit, -, ., _, or ~, is refused on its own; the remaining entries are recorded. A database error while recording stores none of the entries and is reported on every entry not already refused.

Raises

session_id does not exist in the caller’s organization.

device_id was omitted and the session has no attached device or more than one.

Usage

Publish with an explicit device:

from roboto.domain.metrics import Metric, MetricEntry
published = Metric.publish(
    session_id="ss_abc123",
    metrics=[MetricEntry(name="cpu.usage_max", value=87.2)],
    device_id="robot01",
)
len(published.succeeded)
# 1

Let the server infer the device from the session’s single attached device:

Metric.publish(
    session_id="ss_abc123",
    metrics=[MetricEntry(name="memory.peak_mb", value=2048.0)],
)

Record values that are not tied to any device:

Metric.publish(
    session_id="ss_abc123",
    metrics=[MetricEntry(name="run.duration_s", value=42.0)],
    device_id=None,
)

Properties

Metric.published

published datetime.datetime #
Return type: datetime.datetime

Metric.published_by

published_by str #
Return type: str

Metric.query()

classmethod query(name, start_time=None, end_time=None, time_filter=MetricTimeFilter.EndTime, max_results=MAX_METRIC_LIST_RESULTS, descending=False, include_device_ids=NotSet, include_session_ids=NotSet, include_invocation_ids=NotSet, condition=None, group_by=None, owner_org_id=None, roboto_client=None, sort_by=None)#View Source

Yield stored metric values whose session time falls in a range.

The time window is matched against either session_min_timestamp_ns or session_max_timestamp_ns on each metric row depending on time_filter.

This method auto-paginates: max_results is the page size (capped at MAX_METRIC_LIST_RESULTS), not a total result cap. The generator continues fetching pages until the server reports no more data.

Parameters

name str

Name of the metric definition to query.

start_time Optional[roboto.time.Time]

Inclusive start of the query window. Accepts any Time value (int Unix-epoch nanoseconds, datetime, ISO 8601 string, decimal seconds, etc.). Defaults to None (the Unix epoch).

end_time Optional[roboto.time.Time]

Exclusive end of the query window. Same input shape as start_time. Defaults to None (now).

Whether to match the window against the session’s start time or end time. Defaults to end time.

max_results int

Page size — number of data points per HTTP request. Total results are unbounded; pagination is automatic.

descending bool

Yield the largest sort_by values first instead of the smallest, so with the default sort_by the most recent sessions come first. Applies across the whole result set, not just within a page. Data points with no device_id or invocation_id then sort before every other value.

include_device_ids Optional[Union[list[str], roboto.sentinels.NotSetType]]

Restrict to specific device IDs, or None to match only rows with no device_id.

include_session_ids Union[list[str], roboto.sentinels.NotSetType]

Restrict to specific session IDs.

include_invocation_ids Optional[Union[list[str], roboto.sentinels.NotSetType]]

Restrict to specific invocation IDs, or None to match only rows with no invocation_id.

condition Optional[roboto.query.ConditionType]

Restrict to data points whose session, producing device, or session’s collections match this Condition or ConditionGroup. See condition for the accepted fields, and for how collection conditions evaluate when a session belongs to several collections or to none.

group_by Optional[str]

Field whose value each yielded data point carries under group_key, for separating the points into a series per distinct value. Does not change which data points are returned; see group_by for the accepted fields.

owner_org_id Optional[str]

Organization that owns the metric data. Defaults to the authenticated caller’s organization.

roboto_client Optional[roboto.http.RobotoClient]

Roboto client to use. Defaults to the client configured in the environment.

sort_by Optional[str]

Field to order the data points by. See sort_by for the accepted fields. Defaults to the session time selected by time_filter.

Yields

One Metric per matching session, sorted by sort_by — ascending by default, descending when descending is set — with session_id as a deterministic tiebreaker.

Raises

No metric with this name exists in the organization.

condition or group_by references a field or comparator the request does not accept, or a custom field that is either undefined in your organization or defined but not in the Ready state.

Return type

collections.abc.Generator[Metric, None, None]

Usage

Query a metric over a single day, passing datetime directly:

import datetime
from roboto.domain.metrics import Metric
for m in Metric.query(
    name="cpu.usage_max",
    start_time=datetime.datetime(2026, 5, 1, tzinfo=datetime.timezone.utc),
    end_time=datetime.datetime(2026, 5, 2, tzinfo=datetime.timezone.utc),
):
    print(m.session_id, m.value)

Or with an ISO 8601 string:

all_records = list(
    Metric.query(
        name="cpu.usage_max",
        start_time="2026-05-01T00:00:00Z",
        end_time="2026-05-02T00:00:00Z",
    )
)

Take just the 10 most recent sessions:

import itertools
recent = list(itertools.islice(Metric.query(name="cpu.usage_max", descending=True), 10))

Take the 10 sessions with the highest value:

highest = list(
    itertools.islice(
        Metric.query(name="cpu.usage_max", sort_by="value", descending=True),
        10,
    )
)

Restrict to data points from production-tagged sessions that either ran in the EMEA region or were produced by a device at the Berlin site. Both custom fields, region on Sessions and site on Devices, must be defined by your organization and moved to Ready; the query raises if either has not been:

from roboto.query import Comparator, Condition, ConditionGroup, ConditionOperator
for m in Metric.query(
    name="cpu.usage_max",
    condition=ConditionGroup(
        operator=ConditionOperator.And,
        conditions=[
            Condition(
                field="session.tags",
                comparator=Comparator.Contains,
                value="production",
            ),
            ConditionGroup(
                operator=ConditionOperator.Or,
                conditions=[
                    Condition(
                        field="session.custom.region",
                        comparator=Comparator.Equals,
                        value="emea",
                    ),
                    Condition(
                        field="device.custom.site",
                        comparator=Comparator.Equals,
                        value="berlin",
                    ),
                ],
            ),
        ],
    ),
):
    print(m.session_id, m.value)

Separate the data points by the device that published them:

from collections import defaultdict
by_device = defaultdict(list)
for m in Metric.query(name="cpu.usage_max", group_by="device.device_id"):
    by_device[m.group_key].append(m.value)

Properties

Metric.session_id

session_id str #
Return type: str

Metric.unit

unit str | None #
Return type: Optional[str]

Metric.value

value float #
Return type: float

MetricDefinition

class roboto.domain.metrics.MetricDefinition(record, roboto_client)#View Source

A named schema for a metric tracked across sessions and devices.

Metric definitions are org-scoped schemas that describe a single measurable quantity. They act as the registry entry that all Metric data points reference. Every metric definition has a unique name within an organization, and an optional human-readable description.

Metric definitions are created once per org and reused across many sessions. Use create() to register a definition the first time, and update() to change its description later. for_org() lists all definitions that belong to an organization.

MetricDefinition.create()

classmethod create(name, description=None, unit=None, caller_org_id=None, roboto_client=None)#View Source

Create a new metric definition in the caller’s organization.

Parameters

name str

Unique metric name. Must contain only URL-safe characters (A–Z, a–z, 0–9, -, ., _, ~). Dots are conventional namespace separators, e.g. cpu.usage_pct.

description Optional[str]

Optional human-readable description of what the metric measures.

unit Optional[str]

Optional unit of measure for values recorded under this metric, e.g. "%", "ms", "m/s". Free-form and unvalidated. Omit for a unitless metric.

caller_org_id Optional[str]

Organization to create the definition in. Defaults to the authenticated caller’s organization.

roboto_client Optional[roboto.http.RobotoClient]

Roboto client to use. Defaults to the client configured in the environment.

Returns

Raises

A definition with this name already exists in the organization.

Usage

MetricDefinition.create(
    name="cpu.usage_max",
    description="Peak CPU usage recorded during the session.",
    unit="%",
)

MetricDefinition.delete()

delete()#View Source

Delete this metric definition and all of its associated data points.

Usage

definition = MetricDefinition.get("cpu.usage_max")
definition.delete()

Return type

None

Properties

MetricDefinition.description

description str | None #
Return type: Optional[str]

MetricDefinition.for_org()

classmethod for_org(owner_org_id, roboto_client=None)#View Source

Yield all metric definitions belonging to an organization.

Parameters

owner_org_id str

Organization that owns the metric definitions to enumerate.

roboto_client Optional[roboto.http.RobotoClient]

Roboto client to use. Defaults to the client configured in the environment.

Yields

Each MetricDefinition belonging to owner_org_id.

Return type

collections.abc.Generator[MetricDefinition, None, None]

Usage

for definition in MetricDefinition.for_org("og_myorg"):
    print(definition.name, "-", definition.description)

MetricDefinition.get()

classmethod get(name, owner_org_id=None, roboto_client=None)#View Source

Retrieve an existing metric definition by name.

Parameters

name str

Name of the metric definition to retrieve. Must match exactly (case-sensitive) the name used when the definition was created.

owner_org_id Optional[str]

Organization that owns the definition. Defaults to the authenticated caller’s organization.

roboto_client Optional[roboto.http.RobotoClient]

Roboto client to use. Defaults to the client configured in the environment.

Returns

The MetricDefinition with the given name.

Raises

No definition with this name exists in the organization.

Usage

definition = MetricDefinition.get("cpu.usage_max")

Properties

MetricDefinition.metric_id

metric_id str #
Return type: str

MetricDefinition.name

name str #
Return type: str

MetricDefinition.org_id

org_id str #
Return type: str

MetricDefinition.unit

unit str | None #
Return type: Optional[str]

MetricDefinition.update()

update(description=NotSet, unit=NotSet)#View Source

Update the mutable attributes of this definition.

Parameters

description Optional[Union[roboto.sentinels.NotSetType, str]]

New human-readable description, None to clear, or NotSet to leave unchanged.

unit Optional[Union[roboto.sentinels.NotSetType, str]]

New unit of measure, None to clear, or NotSet to leave unchanged.

Return type

None

Usage

definition = MetricDefinition.get("cpu.usage_max")
definition.update(description="Peak CPU usage recorded during the session.", unit="%")

MetricDefinitionRecord

class roboto.domain.metrics.MetricDefinitionRecord(/, **data)#View Source

Bases: pydantic.BaseModel

A wire-transmissible representation of a metric definition.

Parameters

data Any

Attributes

MetricDefinitionRecord.created

created datetime.datetime #

Timestamp when this metric definition was created.

MetricDefinitionRecord.created_by

created_by str #

User or service account that created this metric definition.

MetricDefinitionRecord.description

description str | None = None #

Human-readable description of what the metric measures.

MetricDefinitionRecord.metric_id

metric_id str #

Unique identifier for this metric definition.

MetricDefinitionRecord.modified

modified datetime.datetime #

Timestamp when this metric definition was last modified.

MetricDefinitionRecord.modified_by

modified_by str #

User or service account that last modified this metric definition.

MetricDefinitionRecord.name

name str #

Unique name for this metric.

MetricDefinitionRecord.org_id

org_id str #

Organization that owns this metric definition.

MetricDefinitionRecord.unit

unit str | None = None #

Unit of measure for every value recorded under this metric, e.g. "%", "ms", "m/s". Free-form and unvalidated; None means unitless.

MetricEntry

class roboto.domain.metrics.MetricEntry(/, **data)#View Source

Bases: pydantic.BaseModel

A single name+value pair within a bulk metric publish.

Parameters

data Any

Attributes

MetricEntry.name

name str #

Name of the metric definition to record a value for. If the definition does not exist, it is auto-created.

MetricEntry.value

value float #

Observed numeric value.

MetricRecord

class roboto.domain.metrics.MetricRecord(/, **data)#View Source

Bases: pydantic.BaseModel

A wire-transmissible representation of a metric data point.

Parameters

data Any

Attributes

MetricRecord.device_id

device_id str | None = None #

Device that produced the data.

MetricRecord.group_key

group_key str | None = None #

Value of the field named by QueryMetricsRequest.group_by that this data point carries, rendered as text whatever the field’s type. None on every data point of an ungrouped query, and on a data point that carries no value for that field — one published without a device, or whose session or device has never been given a value for the custom field. Mirrors NumericAggregateMetricRecord.group_key, which splits buckets the same way.

MetricRecord.invocation_id

invocation_id str | None = None #

Action invocation that produced this data point, if any.

MetricRecord.max_timestamp_ns

max_timestamp_ns int | None = None #

Upper bound of the source session’s aggregate timestamps, in Unix-epoch nanoseconds. None until the session has at least one file contribution. Mirrors max_timestamp_ns.

MetricRecord.metric_id

metric_id str #

Identifier of the metric definition this data point belongs to.

MetricRecord.min_timestamp_ns

min_timestamp_ns int | None = None #

Lower bound of the source session’s aggregate timestamps, in Unix-epoch nanoseconds. None until the session has at least one file contribution. Mirrors min_timestamp_ns.

MetricRecord.name

name str #

Human-readable name of the metric definition this data point belongs to. Resolved server-side from the parent MetricDefinitionRecord so callers do not need a second lookup to display the metric name alongside the value.

MetricRecord.org_id

org_id str #

Organization that owns this metric data point.

MetricRecord.published

published datetime.datetime #

Timestamp when this data point was published to the platform.

MetricRecord.published_by

published_by str #

User or service account that published this data point.

MetricRecord.session_id

session_id str #

Session this metric is associated with.

MetricRecord.unit

unit str | None = None #

Unit of measure for value. Resolved server-side from the parent MetricDefinitionRecord, like name, so callers can label a value without a second lookup. None means unitless.

MetricRecord.value

value float #

Observed numeric value.

MetricTimeFilter

class roboto.domain.metrics.MetricTimeFilter#View Source

Bases: roboto.compat.StrEnum

Enum where members are also (and must be) strings

Attributes

MetricTimeFilter.EndTime

EndTime = 'end_time' #

MetricTimeFilter.StartTime

StartTime = 'start_time' #

NumericAggregateMetricRecord

class roboto.domain.metrics.NumericAggregateMetricRecord(/, **data)#View Source

Bases: AggregateMetricRecord

A wire-transmissible representation of one period bucket in a numeric metric aggregation.

Parameters

data Any

Attributes

NumericAggregateMetricRecord.aggregation

aggregation NumericAggregation #

Aggregation function that was applied to produce this record.

NumericAggregateMetricRecord.group_key

group_key str | None = None #

Value of the field named by AggregateMetricsRequest.group_by that this bucket’s data points share, rendered as text whatever the field’s type. None on every bucket of an ungrouped aggregation, and on the bucket collecting the grouped data points that carry no value for that field — a data point published without a device, or a session or device that has never been given a value for the custom field.

NumericAggregateMetricRecord.unit

unit str | None = None #

Unit of measure for value, resolved from the aggregated metric’s definition alongside name. None means unitless.

NumericAggregateMetricRecord.value

value float #

Aggregated result for this bucket.

NumericAggregateMetricsResponse

class roboto.domain.metrics.NumericAggregateMetricsResponse(/, **data)#View Source

Bases: pydantic.BaseModel

Response payload for a numeric metric aggregation request.

Parameters

data Any

Attributes

NumericAggregateMetricsResponse.aggregation

aggregation NumericAggregation #

Aggregation function that was applied.

NumericAggregateMetricsResponse.records

Period buckets returned by the aggregation, sorted by start_time ascending.

NumericAggregation

class roboto.domain.metrics.NumericAggregation#View Source

Bases: roboto.compat.StrEnum

Aggregation function applied to numeric metric values within each period bucket.

Attributes

NumericAggregation.Count

Count = 'count' #

Count of observations in the bucket.

NumericAggregation.Max

Max = 'max' #

Maximum value observed in the bucket.

NumericAggregation.Mean

Mean = 'mean' #

Arithmetic mean of all values in the bucket.

NumericAggregation.Min

Min = 'min' #

Minimum value observed in the bucket.

NumericAggregation.Sum

Sum = 'sum' #

Sum of all values in the bucket.

PublishMetricsRequest

class roboto.domain.metrics.PublishMetricsRequest(/, **data)#View Source

Bases: pydantic.BaseModel

Request payload to insert multiple metric data points in a single call.

Parameters

data Any

Attributes

PublishMetricsRequest.device_id

device_id roboto.sentinels.NotSetType | str | None #

Device that produced the data. When absent (NotSet), the server infers the device from the session’s attached devices: the request succeeds if exactly one device is attached and is rejected otherwise. Pass an explicit device ID or None to skip inference.

PublishMetricsRequest.metrics

metrics list[MetricEntry] #

Metric data points to insert.

PublishMetricsRequest.model_config

model_config #

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

PublishMetricsRequest.session_id

session_id str #

Session all metrics in this batch will be attached to.

QueryMetricsRequest

class roboto.domain.metrics.QueryMetricsRequest(/, **data)#View Source

Bases: pydantic.BaseModel

Request payload to query raw metric data points.

Parameters

data Any

Attributes

QueryMetricsRequest.condition

condition roboto.query.ConditionType | None = None #

Condition, or nested group of conditions, narrowing which data points are returned.

Every field must be prefixed with the entity it filters on, singular or plural; a bare field name such as name is rejected. The available fields are:

  • session.<field>: session_id (alias id), name, min_timestamp_ns (alias start_time), max_timestamp_ns (alias end_time), duration, created, created_by, modified, modified_by, tags. The two timestamp bounds accept anything to_epoch_nanoseconds() converts; duration takes an integer count of nanoseconds.
  • device.<field>: device_id (alias id), tags, created, created_by, modified, modified_by, metadata (including dotted paths beneath it). Reads the device that published the data point, not the devices attached to its session.
  • session.custom.<name> / device.custom.<name> / collection.custom.<name>: a custom field in the Ready state.
  • collection.collection_id (alias collection.id): the data point’s session belongs to that collection. Equals and NotEquals only.

A session belongs to any number of collections, so a collection.* condition quantifies over that set: a data point matches when its session belongs to at least one collection satisfying the condition. A negated comparator (NotEquals, NotContains, NotLike) means the session belongs to no collection satisfying the positive form, so a session in no collection at all matches every negated collection condition. IsNull and NotExists likewise mean no collection the session belongs to carries a value for the field.

A data point published without a device matches a device.* condition only under IsNull and NotExists. Every other comparator asks what the device’s field holds, NotEquals, NotContains, and NotLike included, so a data point with no device, or a device carrying no value for the field, is excluded. Write device.<field> NotEquals x OR device.<field> IsNull to match both.

Any other field, a comparator the field’s type does not accept, a value the field cannot convert, or a Not group raises RobotoIllegalArgumentException.

QueryMetricsRequest.descending

descending bool = False #

Order data points from the largest sort_by value to the smallest, instead of smallest first.

With the default sort_by, this returns the most recent data points first.

QueryMetricsRequest.end_time_ns

end_time_ns int | None = None #

Exclusive end of the query window, in Unix-epoch nanoseconds (UTC). Built from query()’s end_time parameter the same way. Defaults to None (now).

QueryMetricsRequest.group_by

group_by str | None = None #

Field whose value each returned data point should carry, under MetricRecord.group_key.

Unlike AggregateMetricsRequest.group_by, this does not change which rows come back or how many: a raw query already returns one data point per session, so there is nothing to split. It projects the field’s value onto each one, which is what lets a caller separate the points into a series per distinct value without resolving the field itself.

None leaves MetricRecord.group_key null on every data point. Accepts the same vocabulary the aggregation does — device.device_id and String, Enum, or Boolean custom fields on sessions and devices (session.custom.<name>, device.custom.<name>) — and rejects every other field of condition’s vocabulary with RobotoIllegalArgumentException. A data point carrying no value for the field gets a null group_key rather than being dropped.

QueryMetricsRequest.include_device_ids

include_device_ids list[str] | roboto.sentinels.NotSetType | None #

Filter to observations from specific device IDs, None for null device_id only.

QueryMetricsRequest.include_invocation_ids

include_invocation_ids list[str] | roboto.sentinels.NotSetType | None #

Filter to observations from specific invocation IDs, None for null invocation_id only.

QueryMetricsRequest.include_session_ids

include_session_ids list[str] | roboto.sentinels.NotSetType #

Filter to observations for specific session IDs. None is not a valid value: metrics.session_id is non-nullable, so there is no “null session” subset to filter on. Omit (leave as NotSet) for no filter, or pass a list of IDs.

QueryMetricsRequest.max_results

max_results int = None #

Maximum number of data points to return. Must be between 1 and MAX_METRIC_LIST_RESULTS (10,000).

QueryMetricsRequest.model_config

model_config #

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

QueryMetricsRequest.name

name str #

Name of the metric to query.

QueryMetricsRequest.sort_by

sort_by str | None = None #

Field to order data points by, with session_id as a deterministic tiebreaker.

One of time (the session time selected by time_filter), value, published, device_id, session_id or invocation_id; any other field is rejected with RobotoInvalidRequestException. Data points with no device_id or invocation_id sort after every other value. Defaults to time.

QueryMetricsRequest.start_time_ns

start_time_ns int | None = None #

Inclusive start of the query window, in Unix-epoch nanoseconds (UTC). Built by query() from its start_time parameter via to_epoch_nanoseconds(). Defaults to None (the Unix epoch).

QueryMetricsRequest.time_filter

time_filter MetricTimeFilter #

Whether to filter by session start time or end time.

UpdateMetricDefinitionRequest

class roboto.domain.metrics.UpdateMetricDefinitionRequest(/, **data)#View Source

Bases: pydantic.BaseModel

Request payload to update a metric definition.

Parameters

data Any

Attributes

UpdateMetricDefinitionRequest.description

description roboto.sentinels.NotSetType | str | None #

New description, None to clear, or NotSet to leave unchanged.

UpdateMetricDefinitionRequest.model_config

model_config #

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

UpdateMetricDefinitionRequest.unit

New unit of measure (max 63 characters), None to clear, or NotSet to leave unchanged.

Was this page helpful?