Skip to content

Commit

Permalink
fix(backend): change names of exception columns
Browse files Browse the repository at this point in the history
change column name of `exception.exceptions` & `exception.threads`
to `exception_exceptions` & `exception_threads` as clickhouse otherwise
treats the dot separated fields as a nested data structure (because the
value are arrays) and tries to put `SIZES_OF_ARRAYS_DONT_MATCH` constraints.
what we desire here is not a nested field but rather 2 separate fields that
facilitates simple writes & reads.

closes #46
  • Loading branch information
detj committed Sep 26, 2023
1 parent 9afbbcd commit 5aabfb1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
22 changes: 19 additions & 3 deletions measure-backend/measure-go/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ var columns = []string{
"resource.measure_sdk_version",
"exception.thread_name",
"exception.handled",
"exception.exceptions",
"exception.threads",
"exception_exceptions",
"exception_threads",
"string.severity_text",
"string.string",
"gesture_long_click.target",
Expand Down Expand Up @@ -116,7 +116,23 @@ type Frame struct {
}

func (f *Frame) encode() string {
return fmt.Sprintf("(%d, %d, '%s', '%s', '%s', '%s')", f.LineNum, f.ColNum, f.ModuleName, f.FileName, f.ClassName, f.MethodName)
moduleName := f.ModuleName
fileName := f.FileName
className := f.ClassName
methodName := f.MethodName
if f.ModuleName == "" {
moduleName = "__blank__"
}
if f.FileName == "" {
fileName = "__blank__"
}
if f.ClassName == "" {
className = "__blank__"
}
if f.MethodName == "" {
methodName = "__blank__"
}
return fmt.Sprintf("(%d, %d, '%s', '%s', '%s', '%s')", f.LineNum, f.ColNum, moduleName, fileName, className, methodName)
}

type Frames []Frame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ create table if not exists events_test_2
/* exceptions */
`exception.thread_name` LowCardinality(String),
`exception.handled` Bool,
`exception.exceptions` Array(Tuple(LowCardinality(String), LowCardinality(String), Array(Tuple(Int32, Int32, LowCardinality(String), LowCardinality(String), LowCardinality(String), LowCardinality(String))))),
`exception.threads` Array(Tuple(LowCardinality(String), Array(Tuple(Int32, Int32, LowCardinality(String), LowCardinality(String), LowCardinality(String), LowCardinality(String))))),
/* uses undescore because clickhouse treats dot as a nested data structure and tries to match the length of exception.exceptions & exception.threads */
`exception_exceptions` Array(Tuple(LowCardinality(String), LowCardinality(String), Array(Tuple(Int32, Int32, LowCardinality(String), LowCardinality(String), LowCardinality(String), LowCardinality(String))))),
`exception_threads` Array(Tuple(LowCardinality(String), Array(Tuple(Int32, Int32, LowCardinality(String), LowCardinality(String), LowCardinality(String), LowCardinality(String))))),
/* string */
`string.severity_text` LowCardinality(FixedString(10)),
`string.string` String,
Expand Down

0 comments on commit 5aabfb1

Please sign in to comment.