Skip to main content

Interval Based Fields

Sometimes, you'd like to measure a time interval, as opposed to a simple point in time. Causal provides an @elapsed directive to handle these cases.

You may put an @elapsed field on any feature output or event field as follows:

feature ElapsedExample
{
output {
fromImpressionUntilEnd : Int! @elapsed(kind: "session_end")
}
event SessionEndEvent
{
fromEventUntilEnd : Int! @elapsed(kind: "session_end")
}
}

You must always put the @elapsed directing on a non-nullable integer field. Any field, once annotated, will be automatically filled in by the system once the ending event occurs. The value assigned is the duration in milliseconds between when the field was created and the ending event. Before the ending event occurs, the value of the field is -1.

So the fromImpressionUntilEnd field will contain the duration in millseconds between the feature impression and the end of the session. FromEventUntilEnd will contain the duration between the event time and the end of the session.

The currently valid values for the "kind" parameter in an @elapsed annotation are:

  • "session_end": the time of the last activity on the session (not the session expiration time)
  • "impression_end": the time of the last event that occurs on this feature impression.
  • "until": the time difference between a specified downstream action and the original event time. The list of downstream actions is specified in the path attribute. See the next section for more details.

Elapsed Until:

The elapsed until option allows more fine-grained timing of specific actions. In the example below, the clock starts when a “StartEvent” is fired. If causal then receives either an impression of the ElapsedUntilExample feature or a EndEvent event then the time difference between the two actions is written to first StartEvent’s duration field. The list of paths can be any feature or feature event in the FDL.

feature ElapsedUntilExample
{
event StartEvent
{
duration : Int! @elapsed(kind: "until", path: ["ElapsedUntilExample","ElapsedUntilExample.EndEvent"])
}
event EndEvent
{
someValue: String!
}
}

Reach out on your Causal slack channel if you are interested in these, or any other intervals you may need for your metrics.