Skip to content

Commit

Permalink
pdatagen - Add MoveTo method for struct types (#4240)
Browse files Browse the repository at this point in the history
* [pdatagen] Add MoveTo method for struct types

* [pdatagen] Add MoveTo method for struct types - regenerate

* [batchprocessor] Split benchmarks rework

- Fix metric split benchmark
- Ignore clone counters in split benchmarks

* [batchprocessor] Use MoveTo in split

* [batchprocessor] Skip long running split benchmarks

* [batchprocessor] Improve coverage
  • Loading branch information
trasc committed Oct 27, 2021
1 parent 9488d4c commit fd61bbb
Show file tree
Hide file tree
Showing 17 changed files with 620 additions and 43 deletions.
15 changes: 15 additions & 0 deletions model/internal/cmd/pdatagen/internal/base_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ func new${structName}(orig *${originName}) ${structName} {
// This must be used only in testing code since no "Set" method available.
func New${structName}() ${structName} {
return new${structName}(&${originName}{})
}
// MoveTo moves all properties from the current struct to dest
// reseting the current instance to its zero value
func (ms ${structName}) MoveTo(dest ${structName}) {
*dest.orig = *ms.orig
*ms.orig = ${originName}{}
}`

const messageValueCopyToHeaderTemplate = `// CopyTo copies all properties from the current struct to the dest.
Expand All @@ -48,6 +55,14 @@ func (ms ${structName}) CopyTo(dest ${structName}) {`
const messageValueCopyToFooterTemplate = `}`

const messageValueTestTemplate = `
func Test${structName}_MoveTo(t *testing.T) {
ms := generateTest${structName}()
dest := New${structName}()
ms.MoveTo(dest)
assert.EqualValues(t, New${structName}(), ms)
assert.EqualValues(t, generateTest${structName}(), dest)
}
func Test${structName}_CopyTo(t *testing.T) {
ms := New${structName}()
generateTest${structName}().CopyTo(ms)
Expand Down
7 changes: 7 additions & 0 deletions model/pdata/generated_common.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions model/pdata/generated_common_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions model/pdata/generated_log.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions model/pdata/generated_log_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

105 changes: 105 additions & 0 deletions model/pdata/generated_metrics.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fd61bbb

Please sign in to comment.