> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/holoscan/sdk-user-guide/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/holoscan/sdk-user-guide/_mcp/server.

# holoscan::MessageLabel

> Class to define a MessageLabel that is attached to every GXF Entity being communicated as a message between Operators in Holoscan, for Data Frame Flow Tracking.

Class to define a `MessageLabel` that is attached to every GXF Entity being communicated as a message between Operators in Holoscan, for Data Frame Flow Tracking.

A `MessageLabel` has a vector of paths, where each path is a vector of [Operator](operator) references and their publish and receive timestamps. It also stores frame numbers for root operators.

```cpp showLineNumbers={false}
#include <holoscan/messagelabel.hpp>
```

---

## Constructors

### MessageLabel \[#messagelabel]

#### Default

```cpp showLineNumbers={false}
holoscan::MessageLabel::MessageLabel()
```

#### Copy (with m)

```cpp showLineNumbers={false}
holoscan::MessageLabel::MessageLabel(
    const MessageLabel &m
)
```

#### Copy (with m paths)

explicit

```cpp showLineNumbers={false}
holoscan::MessageLabel::MessageLabel(
    const std::vector<TimestampedPath> &m_paths
)
```

Construct a new [Message](message) Label object from a vector of TimestampedPaths.

This constructor automatically fills the message\_path\_operators vector from the argument of the constructor.

**Parameters**

**`m_paths`** `const std::vector<TimestampedPath> &`

The vector of TimestampedPaths to create the `MessageLabel` from.

---

---

## Assignment operators

### operator= \[#operator\_assign]

```cpp showLineNumbers={false}
MessageLabel & holoscan::MessageLabel::operator=(
    const MessageLabel &m
)
```

---

## Methods

### num\_paths \[#numpaths]

```cpp showLineNumbers={false}
int holoscan::MessageLabel::num_paths() const
```

Get the number of paths in a `MessageLabel`.

**Returns:** The number of paths in a `MessageLabel`.

### get\_all\_path\_names \[#getallpathnames]

```cpp showLineNumbers={false}
std::vector<std::string> holoscan::MessageLabel::get_all_path_names()
```

Get all the names of the path in formatted string, which is comma-separated values of the [Operator](operator) names.

**Returns:** std::vector\<std::string> The vector of strings, where each string is a path name.

### paths \[#paths]

#### Mutable

```cpp showLineNumbers={false}
std::vector<TimestampedPath> & holoscan::MessageLabel::paths()
```

#### Const

const

```cpp showLineNumbers={false}
const std::vector<TimestampedPath> & holoscan::MessageLabel::paths() const
```

### get\_e2e\_latency \[#gete2elatency]

```cpp showLineNumbers={false}
int64_t holoscan::MessageLabel::get_e2e_latency(
    int index
)
```

Get the current end-to-end latency of a path in microseconds.

`MessageLabel` and the whole Data Flow Tracking component tracks the latency in microseconds, which is sufficient for our use-cases.

**Returns:** int64\_t The current end-to-end latency of the index path in microseconds

**Parameters**

**`index`** `int`

The index of the path for which to get the latency

---

### get\_e2e\_latency\_ms \[#gete2elatencyms]

```cpp showLineNumbers={false}
double holoscan::MessageLabel::get_e2e_latency_ms(
    int index
)
```

Get the current end-to-end latency of a path in milliseconds.

**Returns:** double The current end-to-end latency of the index path in milliseconds.

**Parameters**

**`index`** `int`

The index of the path for which to get the latency.

---

### get\_path \[#getpath]

```cpp showLineNumbers={false}
TimestampedPath holoscan::MessageLabel::get_path(
    int index
)
```

Get the Timestamped path at the given index.

**Returns:** TimestampedPath& The timestamped path at the given index

**Parameters**

**`index`** `int`

The index of the path to get

---

### get\_path\_name \[#getpathname]

```cpp showLineNumbers={false}
std::string holoscan::MessageLabel::get_path_name(
    int index
)
```

Get the path name string which is comma-separated values of the operator names.

**Returns:** The path name string

**Parameters**

**`index`** `int`

The index of the path to get

---

### get\_operator \[#getoperator]

```cpp showLineNumbers={false}
OperatorTimestampLabel & holoscan::MessageLabel::get_operator(
    int path_index,
    int op_index
)
```

Get the [OperatorTimestampLabel](../structs/operatortimestamplabel) at the given path and operator index.

**Returns:** [OperatorTimestampLabel](../structs/operatortimestamplabel)& The [Operator](operator) reference at the given path and operator index

**Parameters**

**`path_index`** `int`

The path index of the [OperatorTimestampLabel](../structs/operatortimestamplabel) to get

---

**`op_index`** `int`

The [Operator](operator) index of the [OperatorTimestampLabel](../structs/operatortimestamplabel) to get

---

### set\_operator\_pub\_timestamp \[#setoperatorpubtimestamp]

```cpp showLineNumbers={false}
void holoscan::MessageLabel::set_operator_pub_timestamp(
    int path_index,
    int op_index,
    int64_t pub_timestamp
)
```

Set an [Operator](operator)'s pub\_timestamp.

**Parameters**

**`path_index`** `int`

The path index of the [Operator](operator)

---

**`op_index`** `int`

The index of the [Operator](operator) in the path

---

**`pub_timestamp`** `int64_t`

The new pub\_timestamp to set

---

### set\_operator\_rec\_timestamp \[#setoperatorrectimestamp]

```cpp showLineNumbers={false}
void holoscan::MessageLabel::set_operator_rec_timestamp(
    int path_index,
    int op_index,
    int64_t rec_timestamp
)
```

Set an [Operator](operator)'s pub\_timestamp.

**Parameters**

**`path_index`** `int`

The path index of the [Operator](operator)

---

**`op_index`** `int`

The index of the [Operator](operator) in the path

---

**`rec_timestamp`** `int64_t`

The new rec\_timestamp to set

---

### has\_operator \[#hasoperator]

```cpp showLineNumbers={false}
std::vector<int> holoscan::MessageLabel::has_operator(
    const std::string &op_name
) const
```

Check if an operator is present in the `MessageLabel`.

Returns an empty vector if the operator is not present in any path.

**Returns:** List of path indexes where the operator is present

**Parameters**

**`op_name`** `const std::string &`

The name of the operator to check

---

### set\_frame\_number \[#setframenumber]

```cpp showLineNumbers={false}
void holoscan::MessageLabel::set_frame_number(
    const std::string &operator_name,
    const std::string &port_name,
    uint64_t frame_number
)
```

Set frame number for a specific root operator and port.

**Parameters**

**`operator_name`** `const std::string &`

The name of the root operator

---

**`port_name`** `const std::string &`

The name of the output port

---

**`frame_number`** `uint64_t`

The frame number to set

---

### get\_frame\_numbers \[#getframenumbers]

```cpp showLineNumbers={false}
FrameNumberMap holoscan::MessageLabel::get_frame_numbers() const
```

Get all frame numbers as a map.

**Returns:** Copy of the frame number map (thread-safe)

### add\_new\_op\_timestamp \[#addnewoptimestamp]

```cpp showLineNumbers={false}
void holoscan::MessageLabel::add_new_op_timestamp(
    const holoscan::OperatorTimestampLabel &o_timestamp
)
```

Add a new [Operator](operator) timestamp to all the paths in a message label.

**Parameters**

**`o_timestamp`** `const holoscan::OperatorTimestampLabel &`

The new operator timestamp to be added

---

### update\_last\_op\_publish \[#updatelastoppublish]

```cpp showLineNumbers={false}
void holoscan::MessageLabel::update_last_op_publish()
```

Update the publish timestamp of the last operator in all the paths in a message label.

### add\_new\_path \[#addnewpath]

#### Add a new path to the \`MessageLabel\`

```cpp showLineNumbers={false}
void holoscan::MessageLabel::add_new_path(
    const TimestampedPath &path
)
```

Add a new path to the `MessageLabel`.

**Parameters**

**`path`** `const TimestampedPath &`

The path to be added.

---

#### Overload 2

```cpp showLineNumbers={false}
void holoscan::MessageLabel::add_new_path(
    TimestampedPath &&path
)
```

Add a new path to the `MessageLabel` using move semantics.

**Parameters**

**`path`** `TimestampedPath &&`

The path to be moved into the `MessageLabel`.

---

### to\_string \[#tostring]

```cpp showLineNumbers={false}
std::string holoscan::MessageLabel::to_string() const
```

Convert the `MessageLabel` to a string.

**Returns:** std::string The formatted string representing the `MessageLabel` with all the paths and the Operators with their publish and receive timestamps.

### print\_all \[#printall]

```cpp showLineNumbers={false}
void holoscan::MessageLabel::print_all()
```

Print the to\_string() in the standard output with a heading for the `MessageLabel`.

---

## Static methods

### get\_path\_e2e\_latency\_ms \[#getpathe2elatencyms]

```cpp showLineNumbers={false}
static double holoscan::MessageLabel::get_path_e2e_latency_ms(
    const TimestampedPath &path
)
```

Get the end-to-end latency of a TimestampedPath in microseconds.

It is a utility function in the class and not dependent on the object of this class. Therefore, it's a static function.

**Returns:** The end-to-end latency of the path in ms

**Parameters**

**`path`** `const TimestampedPath &`

The path for which to get the latency

---

### to\_string \[#tostring]

```cpp showLineNumbers={false}
static std::string holoscan::MessageLabel::to_string(
    const TimestampedPath &path
)
```

---

## Types

### Typedefs

| Name              | Definition                              |
| ----------------- | --------------------------------------- |
| `TimestampedPath` | `std::vector< OperatorTimestampLabel >` |
| `PathOperators`   | `std::unordered_set< std::string >`     |
| `FrameNumberMap`  | `std::map< std::string, uint64_t >`     |

---

## Member variables

| Name                     | Type                             | Description                                                                                                                                             |
| ------------------------ | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `message_paths`          | `std::vector< TimestampedPath >` |                                                                                                                                                         |
| `message_path_operators` | `std::vector< PathOperators >`   | List of paths where each path is a set of name of the operators This variable is used to quickly check whether an operator is in a path.                |
| `frame_numbers_`         | `FrameNumberMap`                 | [Map](map) of root operator-port combinations to their frame numbers Keys are in format "operatorname-portname" to track frame numbers per output port. |
| `frame_numbers_mutex_`   | `std::mutex`                     | Mutex to protect concurrent access to frame\_numbers\_.                                                                                                 |