open-policy-agent/opa

Include minimum compatible version check to telemetry reports

tsandall opened this issue · 0 comments

It would be useful to have visibility into the adoption of the if/contains keywords that are planned as required for 1.0 as well as any other language features that have been released recently. To do this, we could extend the telemetry report to include the minimum compatible version of policies loaded into OPA. This way we can see what era of Rego people are writing policies for without disclosing anything interesting about the policies themselves. Since there are a variety of ways that policies can be loaded into OPA, we could scope them to two cases:

  1. Policies loaded via filesystem (e.g., opa run -s ./path/to/policy.rego)
  2. Policies loaded via bundles (e.g., opa run -s -c config.yaml) where bundles are configured statically or dynamically via discovery config

Policies loaded via the v1/policies API are out of scope.

I think it should be possible to handle both of these by sending the telemetry report in a separate goroutine here. Note, we need to send the report asynchronously w.r.t. the onCommit function because we can't block the server waiting while waiting for the response. I think we should avoid sending the telemetry report on every compile update because this could be too chatty (so the plugin manager should include logic to send the report at most once per hour.) Lastly, it would be nice if OPA did not send reports unnecessarily, e.g., if a report will be sent once the policies are loaded, do not automatically send one on startup.