SDK compatibility beacon
When you ship a new version of an API, the people using your generated SDK are the first to find out whether it still works for them. The SDK compatibility beacon lets them tell you, if they choose to. It counts each call by operation and outcome, without sending anything else.
The beacon is off by default. A generated client never reports anything unless the person using it turns telemetry on. Today the beacon is built into the Go client in the downloadable SDK kit (Get SDK in Browse).
What a report contains
Each report counts calls per operation and outcome. It carries only:
| Field | Example | Where it comes from |
|---|---|---|
sdk_name, sdk_version | pets-go, 1.4.0 | The generated client |
api_version, spec_revision_id | 1.2.0, the published revision's id | Baked into the client from the kit's manifest |
operation_id | getPet, or GET /pets/{petId} | The kit manifest's operation id (its method-and-path key when the id has characters the beacon doesn't accept) |
outcome | ok, client_error, server_error, network, incompatible | How the call ended |
count | 12 | How many calls |
incompatible means the API answered with success, but the client couldn't read the response
against the contract it was generated from. That's the clearest sign of a breaking release.
client_error is a 4xx, server_error a 5xx, and network means no response arrived.
A report never carries a request or response body, a header, a URL or host, a status code, a latency, the caller's credentials, or anything that identifies the caller. Apiome refuses any other field and any value that isn't shaped like a version or an id. Counts are filed under the day Apiome received them, never a time the client sends.
Turn it on for your API (owner)
-
Create an
sdk_beaconusage source for the project. Creating sources from the app comes in a later release; until then an operator creates one in the database:INSERT INTO apiome.usage_source (tenant_id, project_id, kind, environment)SELECT p.tenant_id, p.id, 'sdk_beacon', 'prod'FROM apiome.projects p WHERE p.slug = 'pets'RETURNING id; -
Create a reporting key. Use a workspace API key with the Usage source preset (the
usage:ingestscope; see API keys). It can send reports and call nothing else, so it is safe to hand to SDK users. -
Give your SDK users the endpoint
https://<your-apiome>/v1/tenants/<tenant>/usage/sdk-beacon, the key and the source id. Ask them to opt in.
To switch it off, set the source's enabled to false. Reports are then refused with
403 usage-source-disabled and nothing more is counted. Counts are deleted after your plan's usage
retention (usage_rollup_retention_days, 90 days by default), with the rest of the
usage index.
Opt in (SDK user)
In the Go client from the kit, pass WithTelemetry with what the API owner gave you, and flush
before your program exits:
client := pets.NewClient(pets.WithTelemetry(pets.TelemetryConfig{
Endpoint: "https://apiome.example.com/v1/tenants/acme/usage/sdk-beacon",
APIKey: os.Getenv("APIOME_BEACON_KEY"),
SourceID: "6f1c…",
}))
defer client.FlushTelemetry(context.Background())
- Without
WithTelemetry, or with an incomplete config, nothing is sent. - Reports go out in the background every 100 calls (
FlushEvery) and onFlushTelemetry. - Reports use their own HTTP client and the reporting key. Your API credentials and headers are never sent to Apiome.
- A failed report is dropped. Telemetry never fails or slows an API call.
The client's README.md (Telemetry (opt-in)) says the same.
Read the counts (owner)
GET /v1/tenants/{tenant}/usage/sdk-beacons?project=pets&days=30 returns the counts grouped by
spec_revision_id, api_version, sdk_name, sdk_version, operation_id and outcome. It needs
Consumer contracts: view.
Those are the keys of the SDK compatibility manifest and of the SDK kit's manifest.json: provenance.version_record_id is the
revision, and operations[].operation_id the operation. So you can line every count up with the
manifest of the release it came from. For example, a rise in incompatible for getPet on
revision 1.3.0 points at the change that broke it.
With the REST API
Both endpoints are under usage in the REST reference:
| Endpoint | Does |
|---|---|
POST /v1/tenants/{tenant}/usage/sdk-beacon | Accepts a report (apiome.sdk.beacon/v1, at most 500 events). 202 with accepted, calls and rejected (an event naming a revision that isn't a published revision of the source's project is rejected as revision-unknown). |
GET /v1/tenants/{tenant}/usage/sdk-beacons | Reads the grouped counts. |
| Error | Means |
|---|---|
400 usage-source-required | No source named (X-Apiome-Usage-Source header or source_id). |
403 usage-ingest-key-required | Reported with a signed-in session instead of a key. |
403 usage-source-disabled | The owner switched the source off. |
404 usage-source-not-found | Unknown source. |
409 usage-source-kind-mismatch | The source isn't an sdk_beacon source. |
422 | A field outside the contract, or a value that isn't version- or id-shaped. |