Skip to content

Commit

Permalink
metadata/modeldecoder: transaction decoding (#4205)
Browse files Browse the repository at this point in the history
* Add transaction intake structs for v2 and rumv3

* Generate decoder logic from structs

* Expand nullable types as required
  • Loading branch information
simitt authored Sep 22, 2020
1 parent e550b32 commit 2faeb96
Show file tree
Hide file tree
Showing 19 changed files with 4,130 additions and 839 deletions.
25 changes: 13 additions & 12 deletions model/modeldecoder/generator/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import (
const (
basePath = "github.com/elastic/apm-server"
modeldecoderPath = "model/modeldecoder"

pkgV2 = "v2"
pkgV3RUM = "rumv3"
)

var (
Expand All @@ -38,26 +41,24 @@ var (
)

func main() {
genV2Models()
genRUMV3Models()
genV2()
genRUMV3()
}

func genV2Models() {
pkg := "v2"
rootObjs := []string{"metadataRoot"}
out := filepath.Join(filepath.FromSlash(modeldecoderPath), pkg, "model_generated.go")
gen, err := generator.NewGenerator(importPath, pkg, typPath, rootObjs)
func genV2() {
rootObjs := []string{"metadataRoot", "transactionRoot"}
out := filepath.Join(filepath.FromSlash(modeldecoderPath), pkgV2, "model_generated.go")
gen, err := generator.NewGenerator(importPath, pkgV2, typPath, rootObjs)
if err != nil {
panic(err)
}
generate(gen, out)
}

func genRUMV3Models() {
pkg := "rumv3"
rootObjs := []string{"metadataRoot"}
out := filepath.Join(filepath.FromSlash(modeldecoderPath), pkg, "model_generated.go")
gen, err := generator.NewGenerator(importPath, pkg, typPath, rootObjs)
func genRUMV3() {
rootObjs := []string{"metadataRoot", "transactionRoot"}
out := filepath.Join(filepath.FromSlash(modeldecoderPath), pkgV3RUM, "model_generated.go")
gen, err := generator.NewGenerator(importPath, pkgV3RUM, typPath, rootObjs)
if err != nil {
panic(err)
}
Expand Down
Loading

0 comments on commit 2faeb96

Please sign in to comment.