Skip to content

Commit 65f002a

Browse files
committed
[json-format] add "any" value kind and fix a display bug
1 parent e00d7ca commit 65f002a

7 files changed

Lines changed: 17 additions & 13 deletions

docs/schemas/format-v1.schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@
401401
"struct",
402402
"quoted",
403403
"xml",
404-
"timestamp"
404+
"timestamp",
405+
"any"
405406
]
406407
},
407408
"collate": {

src/formats/mongodb_json_log.json

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,6 @@
197197
"hidden": true,
198198
"description": "Additional attributes for the log message"
199199
},
200-
"attr/action/outcome/errorMessage": {
201-
"kind": "string",
202-
"highlights": {
203-
"error": {
204-
"base-style": {
205-
"color": "Red"
206-
}
207-
}
208-
}
209-
},
210200
"attr/authenticationDatabase": {
211201
"kind": "string",
212202
"description": "The authenticating database for a connection"
@@ -217,7 +207,7 @@
217207
"highlights": {
218208
"delete": {
219209
"base-style": {
220-
"color": "red"
210+
"color": "Red"
221211
}
222212
}
223213
}
@@ -273,6 +263,7 @@
273263
}
274264
},
275265
"attr/error": {
266+
"kind": "any",
276267
"highlights": {
277268
"error": {
278269
"base-style": {

src/log_format.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ logline_value_meta::to_chart_type() const
370370
case value_kind_t::VALUE_FLOAT:
371371
retval = chart_type_t::spectro;
372372
break;
373+
case value_kind_t::VALUE_ANY:
373374
case value_kind_t::VALUE_XML:
374375
case value_kind_t::VALUE_JSON:
375376
case value_kind_t::VALUE_BOOLEAN:
@@ -435,6 +436,7 @@ logline_value::logline_value(logline_value_meta lvm,
435436
}
436437

437438
switch (this->lv_meta.lvm_kind) {
439+
case value_kind_t::VALUE_ANY:
438440
case value_kind_t::VALUE_JSON:
439441
case value_kind_t::VALUE_XML:
440442
case value_kind_t::VALUE_STRUCT:
@@ -518,6 +520,7 @@ logline_value::to_string() const
518520
case value_kind_t::VALUE_NULL:
519521
return "null";
520522

523+
case value_kind_t::VALUE_ANY:
521524
case value_kind_t::VALUE_JSON:
522525
case value_kind_t::VALUE_XML:
523526
case value_kind_t::VALUE_STRUCT:
@@ -592,6 +595,7 @@ logline_value::to_string_fragment(ArenaAlloc::Alloc<char>& alloc) const
592595
case value_kind_t::VALUE_NULL:
593596
return "null"_frag;
594597

598+
case value_kind_t::VALUE_ANY:
595599
case value_kind_t::VALUE_JSON:
596600
case value_kind_t::VALUE_XML:
597601
case value_kind_t::VALUE_STRUCT:
@@ -1463,6 +1467,10 @@ read_array_end(void* ctx)
14631467
if (field_name == jlu->jlu_format->elf_opid_field) {
14641468
jlu->jlu_opid_desc_frag = json_frag;
14651469
}
1470+
if (ypc->ypc_path_index_stack.size() > 1 && vd != nullptr) {
1471+
jlu->add_sub_lines_for(
1472+
vd, false, std::nullopt, nullptr, -1, nullptr);
1473+
}
14661474
}
14671475

14681476
return 1;

src/log_format_fwd.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ enum class value_kind_t : int {
523523
VALUE_W3C_QUOTED,
524524
VALUE_TIMESTAMP,
525525
VALUE_XML,
526+
VALUE_ANY,
526527

527528
VALUE__MAX
528529
};

src/log_format_loader.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ static constexpr json_path_handler_base::enum_value_t KIND_ENUM[] = {
583583
{"quoted"_frag, value_kind_t::VALUE_QUOTED},
584584
{"xml"_frag, value_kind_t::VALUE_XML},
585585
{"timestamp"_frag, value_kind_t::VALUE_TIMESTAMP},
586+
{"any"_frag, value_kind_t::VALUE_ANY},
586587

587588
json_path_handler_base::ENUM_TERMINATOR,
588589
};

src/log_vtab_impl.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ log_vtab_impl::logline_value_to_sqlite_type(value_kind_t kind)
247247
case value_kind_t::VALUE_W3C_QUOTED:
248248
case value_kind_t::VALUE_TIMESTAMP:
249249
case value_kind_t::VALUE_XML:
250+
case value_kind_t::VALUE_ANY:
250251
type = SQLITE3_TEXT;
251252
break;
252253
case value_kind_t::VALUE_FLOAT:
@@ -1369,6 +1370,7 @@ vt_column(sqlite3_vtab_cursor* cur, sqlite3_context* ctx, int col)
13691370
sqlite3_result_subtype(ctx, JSON_SUBTYPE);
13701371
break;
13711372
}
1373+
case value_kind_t::VALUE_ANY:
13721374
case value_kind_t::VALUE_STRUCT:
13731375
case value_kind_t::VALUE_TEXT:
13741376
case value_kind_t::VALUE_XML: {

test/expected/test_format_loader.sh_5992e2695b7e6cf1f3520dbb87af8fc2b8f27088.err

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
Description
9595
The type of data in the field
9696
Allowed Values
97-
string, integer, float, boolean, json, struct, quoted, xml, timestamp
97+
string, integer, float, boolean, json, struct, quoted, xml, timestamp, any
9898
✘ error: 'bad' is not a supported log format $schema version
9999
 --> {test_dir}/bad-config/formats/invalid-schema/format.json:2
100100
 |  "$schema": "bad" 

0 commit comments

Comments
 (0)