smart_city_data v3.0.2 SmartCity.Data.Timing View Source
Timing struct for adding timing metrics to SmartCity.Data messages
Link to this section Summary
Functions
Gets the current time. This function should always be used for generating times to be used in timings to ensure consistency across all services.
Wraps the results of a function call with measured timing information
Creates a new SmartCity.Data.Timing from opts.
Creates a new SmartCity.Data.Timing struct, passing in all fields.
Validate that all required keys are present and valid (not nil).
Validate that all required keys are present and valid (not nil).
Link to this section Types
t()
View Sourcet() :: %SmartCity.Data.Timing{
app: String.t(),
end_time: DateTime.t(),
label: String.t(),
start_time: DateTime.t()
}
Link to this section Functions
Gets the current time. This function should always be used for generating times to be used in timings to ensure consistency across all services.
Returns current UTC Time in ISO8601 format
Wraps the results of a function call with measured timing information
Returns {:ok, result, timing} on success, or {:error, reason} on failure
Creates a new SmartCity.Data.Timing from opts.
Returns a SmartCity.Data.Timing struct or raises ArgumentError
Parameters
opts: Keyword list or map containing struct attributes
Required keys: `app`, `label` See [`Kernel.struct!/2`](https://hexdocs.pm/elixir/Kernel.html#struct!/2).
new(app, label, start_time, end_time)
View Sourcenew(term(), term(), term(), term()) :: SmartCity.Data.Timing.t()
Creates a new SmartCity.Data.Timing struct, passing in all fields.
Returns a SmartCity.Data.Timing struct or raises ArgumentError.
Parameters
- app: application for which timing metrics are being measured
- label: description of timing measurement
- start_time: time when measurement has begun
- end_time: time when measurement has finished
Examples
iex> SmartCity.Data.Timing.new("foo", "bar", "not_validated", "not_validated")
%SmartCity.Data.Timing{
app: "foo",
label: "bar",
start_time: "not_validated",
end_time: "not_validated"
}
validate(timing)
View Sourcevalidate(SmartCity.Data.Timing.t()) :: {:ok, SmartCity.Data.Timing.t()} | {:error, String.t()}
Validate that all required keys are present and valid (not nil).
Set by @validate_keys module attribute.
Currently checks: app, label
Returns {:ok, timing} on success or {:error, reason} on failure
Parameters
- timing: The
SmartCity.Data.Timingstruct to validate
validate!(timing)
View Sourcevalidate!(SmartCity.Data.Timing.t()) :: SmartCity.Data.Timing.t()
Validate that all required keys are present and valid (not nil).
Returns timing on success, or raises ArgumentError on failure
See validate/1