Configurable Publisher Registry

The Telemetry service provides the Configurable Publisher Registry as a secondary means for data collection. Applications and services can register themselves as telemetry publishers at the registry, which in turn makes them available to the Telemetry service. See Data Sources for more information on the types of data sources we support.

Library

Telemetry communicates with Configurable Publisher Registry publishers through Binder. Instead of manually implementing the AIDL interfaces, we strongly recommend using the experimental Configurable Publisher Registry library that is part of our Telemetry SDK. The library abstracts away the AIDL interfaces and provides a clean, type-safe API for defining publishers, publishing telemetry data, and managing conversion of protobuf messages to their wire format.

For more information about using the library, see Configurable Publisher Registry library.

Manual publisher implementation and registration

If you prefer not to use the provided library, you can implement the necessary Binder interfaces manually. The following sections provide an overview of the steps needed to implement a publisher and register it at the Configurable Publisher Registry.

Registration

Unlike SDV services, which have their metadata, such as message structure, defined in VSIDL and available to the system, publishers using the Configurable Publisher Registry must explicitly provide their metadata. You provide this metadata through the PublisherInfo object during registration.

You register these publishers using the IConfigurablePublisherRegistry AIDL interface. As such, you can write the publishers in any language AIDL supports, including Java, C++, and Rust. The interface provides two methods:

  • Use the registerPublisher method to register a new publisher to the Telemetry service:

    void registerPublisher(in PublisherInfo publisherInfo, in IConfigurablePublisher publisher)
    
  • Use the unregisterPublisher method to unregister a previously registered publisher from the Telemetry service:

    void unregisterPublisher(in @utf8InCpp String serviceName)
    

The PublisherInfo object specifies the publisher's basic information:

Field Description
serviceName A user-defined name of the publisher. Use this name to refer to it from metrics configurations.
fileDescriptorSet A serialized google.protobuf.FileDescriptorSet (see Self-describing Messages for more information) that contains the message descriptor (named by the messageTypeName field) of the message this publisher publishes and all of its necessary dependencies. The Telemetry service uses the message descriptor to deserialize the data sent by the publisher. For more information about generating this at build time, see Java protobuf descriptor generator tool.
messageTypeName Full name of the protobuf messages that your publisher publishes. The message descriptor of this message must be declared in fileDescriptorSet.
supportsGet Indicates whether the publisher can provide the latest message without subscribing to it.

Implementation

Your custom publisher must implement the IConfigurablePublisher interface by providing the following methods:

  • The Telemetry service calls createSubscription to subscribe to a publisher if the connection_type of the data source for this publisher in the metrics configuration is set to SUBSCRIPTION. The ISubscriber argument passed to your publisher provides a sendData(in byte[] data) method, which you can use to stream protobuf messages to the Telemetry service.

    IConfigurablePublisherSubscription createSubscription(in ISubscriber subscriber, in @nullable byte[] configuration)
    
  • The Telemetry service calls getLatestMessage to fetch the latest message of a publisher if the connection_type of the data source for this publisher in the metrics configuration is set to ON_DEMAND. The Telemetry service uses this method only if the PublisherInfo of the publisher indicates supportsGet = true.

    @nullable byte[] getLatestMessage(in @nullable byte[] configuration)
    

The Telemetry service sets the configuration argument to the configuration option of the data source in the metrics configuration.