bloombox / bloombox.client.services.telemetry / TelemetryClient

TelemetryClient

class TelemetryClient : RPCClient, ServiceClient (source)

Telemetry API client, which allows developers to send telemetry event data to the Bloombox Telemetry service, so it may be considered with other built-in telemetry data during analytics and reporting calculations. Partners are also enabled to send their own arbitrary events and later perform analysis over them.

Types

EventContext

data class EventContext

Context for an event, with the opportunity to override settings and configuration for the telemetry client. This is different from other API clients and services, in that it offers many more settings than usual - these values (i.e. the 'userKey', 'deviceUUID', and so on) are automatically attached as "event context" to events sent with the resulting client object.

Constructors

<init>

TelemetryClient(host: String, port: Int, apiKey: String, timeout: Duration, transportMode: TransportMode = TransportMode.SECURE, clientAuth: ClientAuth = ClientAuth.NONE, clientCredentials: ClientCredentials? = null, clientAuthorityRoots: InputStream? = null, executor: Executor = Executors.newSingleThreadExecutor(), defaultPartner: String? = null, defaultLocation: String? = null, deviceUUID: String? = null)

Telemetry API client, which allows developers to send telemetry event data to the Bloombox Telemetry service, so it may be considered with other built-in telemetry data during analytics and reporting calculations. Partners are also enabled to send their own arbitrary events and later perform analysis over them.

Properties

apiKey

val apiKey: String

API key in use by this client. Identifies the implementing/integrating project that is operating this client. Can be obtained via the Bloombox Dashboard or a properly integrated Google Cloud Platform project.

channel

val channel: ManagedChannel

Channel for client->server traffic. Construction of this object is handled by the base RPC client class, which adds necessary items like base interceptors and crypto assets.

clientAuth

val clientAuth: ClientAuth

Client TLS auth mode. This specifies whether client auth is enabled or not for a given API client object. The default value is no client auth. Client authentication (mTLS) is required in some circumstances.

clientAuthorityRoots

val clientAuthorityRoots: InputStream?

Authority roots to accept from the client-side. Defaults to the embedded 'authority-roots.pem', which includes issuing authority certificates for all Bloombox endpoints.

clientCredentials

val clientCredentials: ClientCredentials?

Client credential information. This specifies the client-side portion of mTLS (Mutual Transport-Layer Security) credential data. In particular, this includes a private key and identity certificate chain. First position is the private client key, second is the certificate.

executor

val executor: Executor

Executor for followup and RPC client activities. Defaults to a single-threaded executor that conducts API requests and any related followup in a background thread.

host

val host: String

Host to send RPCs to. This is a regular hostname string, and can be a raw IP address (in the case of "127.0.0.1") or a DNS name.

port

val port: Int

Port to send RPCs to. In some circumstances this may be a service-specific value, and so it is specified here, but by and large RPC traffic occurs over ports 443 and 465.

timeout

val timeout: Duration

RPC request timeout to apply. After this duration, an in-flight RPC request with no server response data will be considered failed due to a "time-out."

transportMode

val transportMode: TransportMode

Transport mode setting. Available options are "INTERNAL" and "SECURE." In nearly all circumstances, including network-internal traffic, "SECURE" should be used, which enforces end-to-end SSL. "INTERNAL" mode is only useful during development and for machine-internal traffic.

Functions

event

fun event(collection: String, payload: Map<String, Value>? = null): Unit

Record a generic event. A "generic event" is any JSON-compatible payload, plus an "event collection," which is simply a string name.

fun event(collection: String, payload: Map<String, Value>? = null, context: EventContext? = null): Unit

Record a generic event. A "generic event" is any JSON-compatible payload, plus an "event collection," which is simply a string name. Additionally, context may be sent along with an event about how and where the event was recorded - i.e. native and browser-oriented device information, and so on.

fun event(collection: String, uuid: String? = null, occurred: Long? = null, payload: Map<String, Value>? = null, context: EventContext? = null): Unit

Record a generic event. A "generic event" is any JSON-compatible payload, plus an "event collection," which is simply a string name. Additionally, context may be sent along with an event about how and where the event was recorded - i.e. native and browser-oriented device information, and so on. This variant allows the additional specification of an explicit event UUID and occurrence timestamp.

ping

fun ping(callback: PingCallback? = null): Unit

Ping the service. This emits a lightweight message and asks the server to respond ASAP. In some cases, a telemetry ping may be used to establish session-level default context, by specifying global context in headers/trailers alongside the ping request.