# fuchsia.legacymetrics

<br />

Added: 7

## **PROTOCOLS**

## MetricsRecorder

*Defined in [fuchsia.legacymetrics/metrics_recorder.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.legacymetrics/metrics_recorder.fidl;l=12)*

Accepts metrics events and uploads them to UMA servers for analysis. Metrics
events are batched and uploaded at a regular interval. If this service is
unable to upload events, it will try persisting them for later re-upload.
For similar behavior, see Chromium's MetricsService:
https://chromium.googlesource.com/chromium/src.git/+/HEAD/components/metrics/metrics_service.cc

<br />

### OnCloseSoon

Indicates that this service will close all connections soon. Upon
receiving this event, each client should call Record() once for any
available metrics and close its connection to this sevice. Otherwise,
this service will close all incoming connections after a predefined
timeout starting from the moment it broadcasts this event.

#### Response

\<EMPTY\>

### Record

Processes and enqueues a batch of events for upload. Returns after the
provided metrics are successfully processed by the service. Clients
should wait for a completion callback before sending subsequent Record()
requests.

#### Request

| Name | Type |
|---|---|
| `events` | `vector<https://fuchsia.dev/reference/fidl/fuchsia.legacymetrics#Event>` |

#### Response

\<EMPTY\>

## **STRUCTS**

### HistogramBucket

*Defined in [fuchsia.legacymetrics/event.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.legacymetrics/event.fidl;l=40)*

| Field | Type | Description | Default |
|---|---|---|---|
| `min` | `int64` |   | No default |
| `max` | `int64` |   | No default |
| `count` | `int64` |   | No default |

## **TABLES**

### Histogram

*Defined in [fuchsia.legacymetrics/event.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.legacymetrics/event.fidl;l=26)*

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `name` | `string` | Required histogram identifier. See these guidelines for more info: https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histograms/README.md#naming-your-histogram |
| ### 2 | `buckets` | `vector<https://fuchsia.dev/reference/fidl/fuchsia.legacymetrics#HistogramBucket>` |   |
| ### 3 | `sum` | `int64` |   |

### ImplementationDefinedEvent

*Defined in [fuchsia.legacymetrics/event.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.legacymetrics/event.fidl;l=51)*

A custom event defined by the MetricsRecorder service. Refer to your
MetricsRecorder implementation for more details on the payload structure.

<br />

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `data` | `vector<uint8>` | Custom binary payload whose structure is defined by the MetricsRecorder implementation. For example, it can represent a custom event protocol buffer serialized to its wire format. |
| ### 2 | `name` | `string` | Event identifier required if it's not already included in binary `data`. This field takes precedence over any equivalent name included in binary `data`, if both are provided. |

### UserActionEvent

*Defined in [fuchsia.legacymetrics/event.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.legacymetrics/event.fidl;l=18)*

Event that occurs in response to a user action. See
https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/actions/README.md

<br />

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `name` | `string` |   |
| ### 2 | `time` | `https://fuchsia.dev/reference/zx//https://fuchsia.dev/reference/zx#Time` | Required timestamp of the event occurrence. See TimeTicks in https://cs.chromium.org/chromium/src/base/time/time.h |

## **UNIONS**

### Event [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.legacymetrics/event.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.legacymetrics/event.fidl;l=10)*

A single metric event to be recorded and sent to the UMA backend.

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `user_action_event` | `https://fuchsia.dev/reference/fidl/fuchsia.legacymetrics#UserActionEvent` |   |
| ### 2 | `histogram` | `https://fuchsia.dev/reference/fidl/fuchsia.legacymetrics#Histogram` |   |
| ### 3 | `impl_defined_event` | `https://fuchsia.dev/reference/fidl/fuchsia.legacymetrics#ImplementationDefinedEvent` |   |

<br />