-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add nesting depth limit to SpanFormatter #16
base: airbnb-main
Are you sure you want to change the base?
Changes from 1 commit
ced5c2e
8f211df
321fa57
3b218a1
95b9e19
594fb9a
d4a471b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ public class SpanFormatter { | |
|
||
public static final String DEFAULT_LOG_MESSAGE_TYPE = "INFO"; | ||
public static final String DEFAULT_INDEX_NAME = "unknown"; | ||
public static final int DEPTH_LIMIT = 3; | ||
|
||
public static Timestamp parseDate(String dateStr, Schema.SchemaFieldType type) { | ||
Instant instant; | ||
|
@@ -148,14 +149,24 @@ public static List<Trace.KeyValue> convertKVtoProto( | |
@VisibleForTesting | ||
public static List<Trace.KeyValue> convertKVtoProtoDefault( | ||
String key, Object value, Schema.IngestSchema schema) { | ||
return convertKVtoProtoDefault(key, value, schema, DEPTH_LIMIT - 1); | ||
} | ||
|
||
@VisibleForTesting | ||
public static List<Trace.KeyValue> convertKVtoProtoDefault( | ||
String key, Object value, Schema.IngestSchema schema, int depthLimit) { | ||
List<Trace.KeyValue> tags = new ArrayList<>(); | ||
if (value instanceof Map) { | ||
// todo - consider adding a depth param to prevent excessively nested fields | ||
if (depthLimit <= 0) { | ||
return tags; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of returning empty list of tags, can we instead return a string blob that is un-indexed? Since logging systems are often used as debugging systems, it would be ideal to ingest data where possible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. argh. Yeah. We'll need to do that now, but it'll be sort of broken. I'd assumed that the _source field would retain the original json, but this change here: https://github.com/slackhq/astra/pull/816/files#diff-3e3f1e6e9032267dd01c35b0f82f031bd633e1f08355002149316079bbe5711b broken that. It got rid of the code that reified the original document in favor of flattening everything. I'm not sure it was an intended because it isn't mentioned in the PR and there are no tests that cover the change. Kinda like this: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm. Maybe not exactly that PR, but certainly from that series of changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
((Map<?, ?>) value) | ||
.forEach( | ||
(key1, value1) -> { | ||
List<Trace.KeyValue> nestedValues = | ||
convertKVtoProtoDefault(String.format("%s.%s", key, key1), value1, schema); | ||
convertKVtoProtoDefault( | ||
String.format("%s.%s", key, key1), value1, schema, depthLimit - 1); | ||
tags.addAll(nestedValues); | ||
}); | ||
} else if (value instanceof String || value instanceof List) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add a TODO for now to move it to schema config.