---
title: "encode(to:)"
framework: evaluations
role: symbol
role_heading: Instance Method
path: "evaluations/aggregationoperation/encode(to:)"
---

# encode(to:)

Encodes the operation as a keyed container with a type discriminator and either metric (the metric name) or label (for custom operations).

## Declaration

```swift
func encode(to encoder: any Encoder) throws
```
