pub trait ProfilerMarker {
    const MARKER_TYPE_NAME: &'static str;

    // Required methods
    fn schema() -> MarkerSchema;
    fn json_marker_data(&self) -> Value;
}
Expand description

The trait that all markers implement.

use fxprof_processed_profile::{ProfilerMarker, MarkerLocation, MarkerFieldFormat, MarkerSchema, MarkerDynamicField, MarkerSchemaField};
use serde_json::json;

/// An example marker type with some text content.
#[derive(Debug, Clone)]
pub struct TextMarker(pub String);

impl ProfilerMarker for TextMarker {
    const MARKER_TYPE_NAME: &'static str = "Text";

    fn json_marker_data(&self) -> serde_json::Value {
        json!({
            "type": Self::MARKER_TYPE_NAME,
            "name": self.0
        })
    }

    fn schema() -> MarkerSchema {
        MarkerSchema {
            type_name: Self::MARKER_TYPE_NAME,
            locations: vec![MarkerLocation::MarkerChart, MarkerLocation::MarkerTable],
            chart_label: Some("{marker.data.name}"),
            tooltip_label: None,
            table_label: Some("{marker.name} - {marker.data.name}"),
            fields: vec![MarkerSchemaField::Dynamic(MarkerDynamicField {
                key: "name",
                label: "Details",
                format: MarkerFieldFormat::String,
                searchable: true,
            })],
        }
    }
}

Required Associated Constants§

source

const MARKER_TYPE_NAME: &'static str

The name of the marker type.

Required Methods§

source

fn schema() -> MarkerSchema

A static method that returns a MarkerSchema, which contains all the information needed to stream the display schema associated with a marker type.

source

fn json_marker_data(&self) -> Value

A method that streams the marker payload data as a serde_json object.

Implementors§