2 unstable releases

new 0.2.0 Feb 11, 2025
0.1.0 Feb 7, 2025

#743 in Network programming

Download history 145/week @ 2025-02-04

145 downloads per month

Apache-2.0

74KB
2K SLoC

detsys-ids-client

A client for install.determinate.systems, in particular the feature flagging/configuration and event collection. The event collection data is explicitly PostHog compatible.

The collected properties are not identifying. You can see our privacy policy at https://determinate.systems/policies/privacy/.

Architecture

flowchart TD
    Recorder --> Collator
    ConfigurationProxy --> Recorder

    subgraph Worker
        Collator --> Submitter
        SystemSnapshotter --> Collator
        Submitter --> Transport
        Transport --> ConfigurationProxy
    end

    Transport --> Backend["File / HTTP Backend"]

Components:

  • Recorder is the user-interface and cheap to clone, doing all the work over channels.
  • ConfigurationProxy reads configuration and feature properties from the Transport.
  • Collator fetches a recent SystemSnapshot from the SystemSnapshotter and agggregates the total sum of facts and event data to enrich the basic event data from the Recorder. Those events are then sent to the Submitter.
  • SystemSnapshotter produces a fresh SystemSnapshot of the host. This may include properties that change frequently, like thermal state, so a SystemSnapshot must not be reused.
  • Submitter batches and sends events over the Transport on a schedule, or when the Recorder explicitly requests an immediate flush.
  • Transport handles the actual reading of configuration and writing of event data.

Transports

  • SrvHttp: The default if no endpoint is specified (ie: None is passed). The provided endpoint record will be queried for SRV records. Each server in the record will be used in rotation, and for fallback if the backend is not behaving. Beyond that, it behaves like the HTTP transport.

  • File: Will try to parse the endpoint as-is, or with file:// prefixed on it. With the File endpoint, the DETSYS_IDS_CHECKIN_FILE environment variable can point to a check-in configuration document to read. Note: You can pass an endpoint of file:///dev/stdout for interactive debugging.

  • HTTP: takes the configured endpoint and sets the URL path to /check-in for the checkin process, and /events for event submission.

Environment Variables

  • DETSYS_IDS_CHECKIN_FILE -- When using the File transport, this environment variable can point to a Checkin-compatible JSON file to specify features and options.
  • DETSYS_IDS_IN_CI -- Set to 1 to explicitly indicate this run is in CI.
  • DETSYS_CORRELATION -- A JSON blob that is set by detsys-ts and passes down some anonymized context about the GitHub Actions run. It can also contain an arbitrary set of event properties.

The correlation data is mixed in to the event data by the Collator, and:

  • $session_id is preferred over generating a new one.
  • $anon_distinct_id is preferred over generating a new one.
  • distinct_id is used if the user of the library doesn't explicitly pass a distinct ID.
  • $device_id is used instead of generating a new one if the user doesn't explicitly pass a device ID.
  • $groups is merged in to the user-provided groups.
  • Any additional property is appended to the user-provided facts.

To-do

Dependencies

~17–47MB
~729K SLoC