Skip to content

builtins: deprecate the trace built-in function #5621

Open
@anderseknert

Description

@anderseknert

With the introduction of the print function, there's not much motivating the use of trace. The print function has a number of advantages over trace:

  • Gracefully deals with undefined values
  • Varargs - not required to use sprintf for printing multiple variables or values
  • Does not require special flags to opa eval or query params for opa run
  • Elided by compiler in production (i.e. when running the server with --log-level=error)

Having two built-ins with nearly identical purpose however isn't ideal, and we'd rather have users go use print for the purpose of debugging. Tracing is of course still available for when that is needed — the trace function simply adds a note in the trace.

Creating an issue here for discussion, as there could be use cases for this I haven't thought of. And just to be clear: deprecation does not mean removal, but simply that we'd delist it from the docs, or even list it as deprecated with a pointer to use print instead, and that an error will be emitted by the compiler when --strict-mode is enabled.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions