[−][src]Macro glean_ffi::define_metric
Define the global handle map, constructor and destructor functions and any user-defined functions for a new metric
This allows to define most common functionality and simple operations for a metric type. More complex operations should be written as plain functions directly.
Arguments
$metric_type
- metric type to use from glean_core, e.g.CounterMetric
.$metric_map
- name to use for the global name, should be all uppercase, e.g.COUNTER_METRICS
.$new_fn(...)
- (optional) name of the constructor function, followed by all additional (non-common) arguments.$test_get_num_recorded_errors
- (optional) name of the test_get_num_recorded_errors function$destroy
- name of the destructor function.
Additional simple functions can be define as a mapping $op -> $op_fn
:
$op
- function on the metric type to call.$op_fn
- FFI function name for the operation, followed by its arguments. Arguments are converted into the target type usingTryFrom::try_from
.