ForgeOpsTracker.Changes (forge_ops_tracker v0.13.0)

Copy Markdown View Source

Builds the two "what changed" payloads: one explicit change (ForgeOpsTracker.record_change/3, POSTed to /api/v1/changes) and the startup change snapshot (POSTed to /api/v1/change_snapshots), which describes what this node sees when it boots: the runtime, every loaded OTP application with its version, and, only when track_env_var_names is on, the names (never the values) of its environment variables. ForgeOps diffs each snapshot against the last one for the same project and environment and records what changed, so this module keeps no state between boots.

Both go through ForgeOpsTracker.DeliveryQueue, so neither blocks the caller, and a failed delivery (including the 403 a plan without change tracking gets) is dropped silently.

Summary

Functions

The change kinds ForgeOps accepts; anything else is sent as "other".

Sends the startup snapshot at most once per VM, from a separate unlinked Task so the caller (usually init/1 in an application's start/2) is never delayed and can never crash because of it. Does nothing while the client isn't enabled or detect_changes is off, and a later call once one was queued does nothing either.

Queues one explicit change for delivery. A no-op when the client isn't enabled, and never raises: see ForgeOpsTracker.record_change/3 for the options.

Functions

kinds()

@spec kinds() :: [String.t()]

The change kinds ForgeOps accepts; anything else is sent as "other".

maybe_send_snapshot()

@spec maybe_send_snapshot() :: :ok

Sends the startup snapshot at most once per VM, from a separate unlinked Task so the caller (usually init/1 in an application's start/2) is never delayed and can never crash because of it. Does nothing while the client isn't enabled or detect_changes is off, and a later call once one was queued does nothing either.

record(kind, title, opts \\ [])

@spec record(term(), term(), keyword()) :: :ok

Queues one explicit change for delivery. A no-op when the client isn't enabled, and never raises: see ForgeOpsTracker.record_change/3 for the options.