roboto.domain.metrics.record#
Module Contents#
- class roboto.domain.metrics.record.AggregateMetricRecord(/, **data)#
Bases:
pydantic.BaseModel- !!! abstract “Usage Documentation”
[Models](../concepts/models.md)
A base class for creating Pydantic models.
- Parameters:
data (Any)
- __class_vars__#
The names of the class variables defined on the model.
- __private_attributes__#
Metadata about the private attributes of the model.
- __signature__#
The synthesized __init__ [Signature][inspect.Signature] of the model.
- __pydantic_complete__#
Whether model building is completed, or if there are still undefined fields.
- __pydantic_core_schema__#
The core schema of the model.
- __pydantic_custom_init__#
Whether the model has a custom __init__ function.
- __pydantic_decorators__#
Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
- __pydantic_generic_metadata__#
A dictionary containing metadata about generic Pydantic models. The origin and args items map to the [__origin__][genericalias.__origin__] and [__args__][genericalias.__args__] attributes of [generic aliases][types-genericalias], and the parameter item maps to the __parameter__ attribute of generic classes.
- __pydantic_parent_namespace__#
Parent namespace of the model, used for automatic rebuilding of models.
- __pydantic_post_init__#
The name of the post-init method for the model, if defined.
- __pydantic_root_model__#
Whether the model is a [RootModel][pydantic.root_model.RootModel].
- __pydantic_serializer__#
The pydantic-core SchemaSerializer used to dump instances of the model.
- __pydantic_validator__#
The pydantic-core SchemaValidator used to validate instances of the model.
- __pydantic_fields__#
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
- __pydantic_computed_fields__#
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
- __pydantic_extra__#
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to ‘allow’.
- __pydantic_fields_set__#
The names of fields explicitly set during instantiation.
- __pydantic_private__#
Values of private attributes set on the model instance.
- end_time: int#
midnight in the request’s
time_zoneon the next period’s first day. A period in which that zone’s clocks change is longer or shorter by the size of the change, so a daily bucket can span 23 or 25 hours.- Type:
Exclusive end of this period bucket, in Unix-epoch nanoseconds
- metric_id: str#
Identifier of the aggregated metric definition.
- name: str#
Name of the aggregated metric.
- period: AggregationPeriod#
Calendar bucket size used for this aggregation.
- start_time: int#
midnight in the request’s
time_zoneon the period’s first day.- Type:
Inclusive start of this period bucket, in Unix-epoch nanoseconds
- total: int#
Number of raw observations that contributed to this bucket.
- class roboto.domain.metrics.record.AggregateMetricsRequest(/, **data)#
Bases:
pydantic.BaseModelRequest payload for a numeric metric aggregation.
- Parameters:
data (Any)
- aggregation: NumericAggregation#
Aggregation function to apply to the values in each bucket.
- 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
conditionfor the accepted fields and the treatment of data points published without a device.
- end_time_ns: int#
Exclusive end of the aggregation window, in Unix-epoch nanoseconds (UTC). Built from
aggregate()’send_timeparameter the same way.
- group_by: str | None = None#
one
NumericAggregateMetricRecordper (period, distinct value) pair, each carrying the value it aggregated undergroup_key.Noneaggregates every matching data point of a period into one bucket. Acceptsdevice.device_idand String, Enum, or Boolean custom fields on sessions and devices (session.custom.<name>,device.custom.<name>); every other field of the vocabularyconditionaccepts 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 nullgroup_keyrather than dropped. At mostMAX_METRIC_GROUPSnamed values come back — those with the most sessions in the requested window — plus the null group; the response reports the full count inNumericAggregateMetricsResponse.total_groups.- Type:
Field to split the aggregation by, in addition to the period bucket
- include_device_ids: list[str] | roboto.sentinels.NotSetType | None#
Filter to observations from specific device IDs,
Nonefor null device_id only.
- include_invocation_ids: list[str] | roboto.sentinels.NotSetType | None#
Filter to observations from specific invocation IDs,
Nonefor null invocation_id only.
- include_session_ids: list[str] | roboto.sentinels.NotSetType#
Filter to observations for specific session IDs.
Noneis not a valid value:metrics.session_idis non-nullable, so there is no “null session” subset to filter on. Omit (leave asNotSet) for no filter, or pass a list of IDs.
- model_config#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str#
Name of the metric to aggregate.
- period: AggregationPeriod#
Calendar bucket size to group observations by.
- start_time_ns: int#
Inclusive start of the aggregation window, in Unix-epoch nanoseconds (UTC). Built by
aggregate()from itsstart_timeparameter viato_epoch_nanoseconds().
- time_filter: MetricTimeFilter#
Whether to filter by session start time or end time.
- time_zone: str = 'UTC'#
IANA name of the time zone in which each period starts at midnight, such as
"America/Los_Angeles". The periods, and the window whenwiden_to_whole_periodswidens it, are cut in this zone, and a day on which the zone’s clocks change is longer or shorter than 24 hours. A name not in the IANA time zone database raisesRobotoIllegalArgumentException, as doCET,EET,MET, andWET, which the service would read as fixed UTC offsets without daylight saving time; name such a zone by area and location instead, such as"Europe/Paris"forCET.
- week_start: DayOfWeek#
The day each week starts on when
periodisAggregationPeriod.Weekly. Other periods ignore it.
- widen_to_whole_periods: bool = True#
Whether to widen the window to whole periods. When true, the service moves
start_time_nsback to the start of its period andend_time_nsforward to the end of its period, so the first and last buckets aggregate every data point of their period, including those of sessions outside the requested window. When false, a bucket aggregates only the data points inside [start_time_ns,end_time_ns), the same data points aQueryMetricsRequestwith the same window,time_filterand filters returns, so the first and last buckets can hold part of their period. Either way, each bucket’sstart_timeandend_timeare the bounds of its whole period.
- class roboto.domain.metrics.record.AggregationPeriod#
Bases:
roboto.compat.StrEnumCalendar bucket size used when grouping metric observations.
Each period starts at midnight in
AggregateMetricsRequest.time_zone, and each week starts onAggregateMetricsRequest.week_start.- Daily = 'daily'#
One bucket per calendar day.
- Monthly = 'monthly'#
One bucket per calendar month.
- Quarterly = 'quarterly'#
One bucket per calendar quarter (three months).
- Weekly = 'weekly'#
One bucket per calendar week.
- Yearly = 'yearly'#
One bucket per calendar year.
- class roboto.domain.metrics.record.CreateMetricDefinitionRequest(/, **data)#
Bases:
pydantic.BaseModelRequest payload to create a metric definition.
- Parameters:
data (Any)
- description: str | None = None#
Human-readable description of what the metric measures.
- name: str#
Unique metric name.
- unit: MetricUnit | None = None#
Unit of measure for values recorded under this metric, e.g.
"%","ms". Capped at 63 characters.Nonemeans unitless.
- class roboto.domain.metrics.record.DayOfWeek#
Bases:
roboto.compat.StrEnumA day of the week, such as the day an aggregation’s weeks start on.
- Friday = 'friday'#
- Monday = 'monday'#
- Saturday = 'saturday'#
- Sunday = 'sunday'#
- Thursday = 'thursday'#
- Tuesday = 'tuesday'#
- Wednesday = 'wednesday'#
- roboto.domain.metrics.record.MAX_METRIC_GROUPS: int = 100#
The most named groups a grouped metrics read returns.
A read with
group_bykeeps the named values with the most sessions (data points) in the requested window, ties broken alphabetically by value, and drops every data point of the rest. The null group (data points with no value for the field) is never dropped and does not count toward the cap. The ranking does not depend on the aggregation, the period, or which page of a raw query is read, so the same window always keeps the same groups. Responses report the full count intotal_groupsand whether anything was dropped ingroups_truncated.
- roboto.domain.metrics.record.MAX_METRIC_LIST_RESULTS: int = 10000#
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 settingmax_results.get_by_session()does not paginate and is still capped at this many rows; sessions with more data points should use the paginatedquery()instead.
- class roboto.domain.metrics.record.MetricDefinitionRecord(/, **data)#
Bases:
pydantic.BaseModelA wire-transmissible representation of a metric definition.
- Parameters:
data (Any)
- created: datetime.datetime#
Timestamp when this metric definition was created.
- created_by: str#
User or service account that created this metric definition.
- description: str | None = None#
Human-readable description of what the metric measures.
- metric_id: str#
Unique identifier for this metric definition.
- modified: datetime.datetime#
Timestamp when this metric definition was last modified.
- modified_by: str#
User or service account that last modified this metric definition.
- name: str#
Unique name for this metric.
- org_id: str#
Organization that owns this metric definition.
- unit: str | None = None#
Unit of measure for every value recorded under this metric, e.g.
"%","ms","m/s". Free-form and unvalidated;Nonemeans unitless.
- class roboto.domain.metrics.record.MetricEntry(/, **data)#
Bases:
pydantic.BaseModelA single name+value pair within a bulk metric publish.
- Parameters:
data (Any)
- name: str#
Name of the metric definition to record a value for. If the definition does not exist, it is auto-created.
- value: float#
Observed numeric value.
- class roboto.domain.metrics.record.MetricQueryPage#
Bases:
roboto.http.response.PaginatedList[MetricRecord]One page of raw metric data points, from
query().Carries the same group summary on every page of one read.
- groups_truncated: bool = False#
Whether
total_groupsexceedsMAX_METRIC_GROUPS, so data points under the named values with the fewest sessions were dropped from every page.
- total_groups: int | None = None#
How many distinct named values of
QueryMetricsRequest.group_byhave data in the queried window, counting none for data points with no value.Noneon an ungrouped query.
- class roboto.domain.metrics.record.MetricRecord(/, **data)#
Bases:
pydantic.BaseModelA wire-transmissible representation of a metric data point.
- Parameters:
data (Any)
- device_id: str | None = None#
Device that produced the data.
- group_key: str | None = None#
Value of the field named by
QueryMetricsRequest.group_bythat this data point carries, rendered as text whatever the field’s type.Noneon 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. MirrorsNumericAggregateMetricRecord.group_key, which splits buckets the same way.
- invocation_id: str | None = None#
Action invocation that produced this data point, if any.
- max_timestamp_ns: int | None = None#
Latest time covered by the data point’s session, in Unix-epoch nanoseconds: that session’s
max_timestamp_ns.Nonein the same cases asmin_timestamp_ns.
- metric_id: str#
Identifier of the metric definition this data point belongs to.
- min_timestamp_ns: int | None = None#
Earliest time covered by the data point’s session, in Unix-epoch nanoseconds: that session’s
min_timestamp_ns.Nonewhile the session has no start or end time, because none of its files gives it timestamped data (for example, before it holds any file).
- name: str#
Human-readable name of the metric definition this data point belongs to. Resolved server-side from the parent
MetricDefinitionRecordso callers do not need a second lookup to display the metric name alongside the value.
- org_id: str#
Organization that owns this metric data point.
- published: datetime.datetime#
Timestamp when this data point was published to the platform.
- published_by: str#
User or service account that published this data point.
- session_end_time_ns: int | None = None#
The time a
time_filterofMetricTimeFilter.EndTimeplaces this data point at, in Unix-epoch nanoseconds: the session’smax_timestamp_ns, or the time the session was created while it has no start or end time. Used assession_start_time_nsis.Noneonly on a record from a service older than this field.
- session_id: str#
Session this metric is associated with.
- session_start_time_ns: int | None = None#
The time a
time_filterofMetricTimeFilter.StartTimeplaces this data point at, in Unix-epoch nanoseconds: the session’smin_timestamp_ns, or the time the session was created while it has no start or end time. A query or aggregation window holds the data point when it holds this time, and an aggregation counts it in the period that holds this time.Noneonly on a record from a service older than this field.
- unit: str | None = None#
Unit of measure for
value. Resolved server-side from the parentMetricDefinitionRecord, likename, so callers can label a value without a second lookup.Nonemeans unitless.
- value: float#
Observed numeric value.
- class roboto.domain.metrics.record.MetricTimeFilter#
Bases:
roboto.compat.StrEnumEnum where members are also (and must be) strings
- EndTime = 'end_time'#
- StartTime = 'start_time'#
- roboto.domain.metrics.record.MetricUnit#
- class roboto.domain.metrics.record.NumericAggregateMetricRecord(/, **data)#
Bases:
AggregateMetricRecordA wire-transmissible representation of one period bucket in a numeric metric aggregation.
- Parameters:
data (Any)
- aggregation: NumericAggregation#
Aggregation function that was applied to produce this record.
- group_key: str | None = None#
Value of the field named by
AggregateMetricsRequest.group_bythat this bucket’s data points share, rendered as text whatever the field’s type.Noneon 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.
- unit: str | None = None#
Unit of measure for
value, resolved from the aggregated metric’s definition alongsidename.Nonemeans unitless.
- value: float#
Aggregated result for this bucket.
- class roboto.domain.metrics.record.NumericAggregateMetricsResponse(/, **data)#
Bases:
pydantic.BaseModelResponse payload for a numeric metric aggregation request.
- Parameters:
data (Any)
- aggregation: NumericAggregation#
Aggregation function that was applied.
- groups_truncated: bool = False#
Whether
total_groupsexceedsMAX_METRIC_GROUPS, so only the named groups with the most sessions in the window (plus the null group) came back. SeeAggregateMetricsRequest.group_by.
- records: list[NumericAggregateMetricRecord]#
Period buckets returned by the aggregation, sorted by start_time ascending.
- total_groups: int | None = None#
How many distinct named values of
AggregateMetricsRequest.group_byhave data in the returned periods, counting none for data points with no value. WhenAggregateMetricsRequest.widen_to_whole_periodsis true, the periods can reach past the requested window to whole-period bounds, so this includes a value whose data falls only in that margin.Noneon an ungrouped aggregation.
- class roboto.domain.metrics.record.NumericAggregation#
Bases:
roboto.compat.StrEnumAggregation function applied to numeric metric values within each period bucket.
- Count = 'count'#
Count of observations in the bucket.
- Max = 'max'#
Maximum value observed in the bucket.
- Mean = 'mean'#
Arithmetic mean of all values in the bucket.
- Min = 'min'#
Minimum value observed in the bucket.
- Sum = 'sum'#
Sum of all values in the bucket.
- class roboto.domain.metrics.record.PublishMetricsRequest(/, **data)#
Bases:
pydantic.BaseModelRequest payload to insert multiple metric data points in a single call.
- Parameters:
data (Any)
- 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 orNoneto skip inference.
- metrics: list[MetricEntry]#
Metric data points to insert.
- model_config#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- session_id: str#
Session all metrics in this batch will be attached to.
- class roboto.domain.metrics.record.QueryMetricsRequest(/, **data)#
Bases:
pydantic.BaseModelRequest payload to query raw metric data points.
Exactly one of
nameandnamesselects the metrics to read.- Parameters:
data (Any)
- 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
nameis rejected. The available fields are:session.<field>:session_id(aliasid),name,min_timestamp_ns(aliasstart_time),max_timestamp_ns(aliasend_time),duration,created,created_by,modified,modified_by,tags. The two timestamp bounds accept anythingto_epoch_nanoseconds()converts;durationtakes an integer count of nanoseconds.device.<field>:device_id(aliasid),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 theReadystate.collection.collection_id(aliascollection.id): the data point’s session belongs to that collection.EqualsandNotEqualsonly.
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.IsNullandNotExistslikewise 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 underIsNullandNotExists. Every other comparator asks what the device’s field holds,NotEquals,NotContains, andNotLikeincluded, so a data point with no device, or a device carrying no value for the field, is excluded. Writedevice.<field> NotEquals x OR device.<field> IsNullto match both.Any other field, a comparator the field’s type does not accept, a value the field cannot convert, or a
Notgroup raisesRobotoIllegalArgumentException.
- descending: bool = False#
Order data points from the largest
sort_byvalue to the smallest, instead of smallest first.With the default
sort_by, this returns the most recent data points first.
- end_time_ns: int | None = None#
Exclusive end of the query window, in Unix-epoch nanoseconds (UTC). Built from
query()’send_timeparameter the same way. Defaults toNone(now).
- 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 add rows: 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.NoneleavesMetricRecord.group_keynull on every data point. Accepts the same vocabulary the aggregation does —device.device_idand String, Enum, or Boolean custom fields on sessions and devices (session.custom.<name>,device.custom.<name>) — and rejects every other field ofcondition’s vocabulary withRobotoIllegalArgumentException. A data point carrying no value for the field gets a nullgroup_keyrather than being dropped.Grouping can drop rows, though: at most
MAX_METRIC_GROUPSnamed values are kept across every page, those with the most sessions in the queried window, and data points under the rest are dropped. EachMetricQueryPagereports the full count intotal_groupsand whether any were dropped ingroups_truncated.
- include_device_ids: list[str] | roboto.sentinels.NotSetType | None#
Filter to observations from specific device IDs,
Nonefor null device_id only.
- include_invocation_ids: list[str] | roboto.sentinels.NotSetType | None#
Filter to observations from specific invocation IDs,
Nonefor null invocation_id only.
- include_session_ids: list[str] | roboto.sentinels.NotSetType#
Filter to observations for specific session IDs.
Noneis not a valid value:metrics.session_idis non-nullable, so there is no “null session” subset to filter on. Omit (leave asNotSet) for no filter, or pass a list of IDs.
- max_results: int#
Maximum number of data points to return. Must be between 1 and
MAX_METRIC_LIST_RESULTS(10,000).
- model_config#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str | None = None#
Name of the metric to query.
- names: list[str] | None = None#
namesmay change or be removed without notice.Names of the metrics to read together as one paginated result: at least one, none repeated. Each returned
MetricRecordcarries its ownnameandmetric_id, which tell the rows of different metrics apart. A list of one name reads and pages asnamedoes.Replay a page token only with the list of names it was issued under. A token issued under
nameor a one-name list is rejected withRobotoInvalidRequestExceptionwhen replayed with two or more names, and a token issued under two or more names is rejected when replayed with one.- Type:
Experimental
- sort_by: str | None = None#
Field to order data points by, with
session_idas a deterministic tiebreaker and, whennameslists several metrics,metric_idafter it.One of
time(the session time selected bytime_filter),value,published,device_id,session_id,invocation_id, orgroup_key(the value ofgroup_by, carried onMetricRecord.group_key, and accepted only whengroup_byis set); any other field is rejected withRobotoInvalidRequestException. Data points with nodevice_id,invocation_idor group key sort after every other value. Defaults totime.
- start_time_ns: int | None = None#
Inclusive start of the query window, in Unix-epoch nanoseconds (UTC). Built by
query()from itsstart_timeparameter viato_epoch_nanoseconds(). Defaults toNone(the Unix epoch).
- time_filter: MetricTimeFilter#
Whether to filter by session start time or end time.
- class roboto.domain.metrics.record.UpdateMetricDefinitionRequest(/, **data)#
Bases:
pydantic.BaseModelRequest payload to update a metric definition.
- Parameters:
data (Any)
- description: roboto.sentinels.NotSetType | str | None#
New description,
Noneto clear, orNotSetto leave unchanged.
- model_config#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- unit: roboto.sentinels.NotSetType | MetricUnit | None#
New unit of measure (max 63 characters),
Noneto clear, orNotSetto leave unchanged.