Skip to content

Commit e9ebd26

Browse files
author
krastogi
committed
Adding log only flag
1 parent 49a7d9c commit e9ebd26

File tree

9 files changed

+19
-7
lines changed

9 files changed

+19
-7
lines changed

commons/src/main/scala/com/expedia/www/haystack/collector/commons/ProtoSpanExtractor.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ class ProtoSpanExtractor(extractorConfiguration: ExtractorConfiguration,
142142
if (valueToValidate > highestValidValue) {
143143
spanSizeLimitExceededMeter.mark()
144144
LOGGER.debug(msg.format(span.getServiceName, span.getOperationName, span.getTraceId, valueToValidate, getProbableTagsExceedingSizeLimit(span)))
145-
Success(truncateTags(span))
145+
if (extractorConfiguration.spanValidation.spanMaxSize.logOnly) {
146+
Success(span)
147+
} else {
148+
Success(truncateTags(span))
149+
}
146150
}
147151
else {
148152
Success(span)

commons/src/main/scala/com/expedia/www/haystack/collector/commons/config/ConfigurationLoader.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ object ConfigurationLoader {
154154
outputFormat = if (extractor.hasPath("output.format")) Format.withName(extractor.getString("output.format")) else Format.PROTO,
155155
spanValidation = SpanValidation(SpanMaxSize(
156156
maxSizeValidationConfig.getBoolean("enable"),
157+
maxSizeValidationConfig.getBoolean("log.only"),
157158
maxSizeValidationConfig.getInt("max.size.limit"),
158159
maxSizeValidationConfig.getString("message.tag.key"),
159160
maxSizeValidationConfig.getString("message.tag.value"),

commons/src/main/scala/com/expedia/www/haystack/collector/commons/config/ExtractorConfiguration.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ object Format extends Enumeration {
2929
case class SpanValidation(spanMaxSize: SpanMaxSize)
3030

3131
case class SpanMaxSize(enable: Boolean,
32+
logOnly: Boolean,
3233
maxSizeLimit: Int,
3334
infoTagKey: String,
3435
infoTagValue: String,

commons/src/test/scala/com/expedia/www/haystack/collector/commons/unit/KeyExtractorSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class KeyExtractorSpec extends FunSpec with Matchers with MetricsSupport {
3636
"trace-id-1" -> createSpan("trace-id-1", "spanId_1", "service_1", "operation", StartTimeMicros, DurationMicros),
3737
"trace-id-2" -> createSpan("trace-id-2", "spanId_2", "service_2", "operation", StartTimeMicros, DurationMicros))
3838

39-
val spanValidationConfig = SpanValidation(SpanMaxSize(enable = false, 5000, "", "", Seq(), Seq()))
39+
val spanValidationConfig = SpanValidation(SpanMaxSize(enable = false, logOnly = false, 5000, "", "", Seq(), Seq()))
4040

4141
spanMap.foreach(sp => {
4242
val kvPairs = new ProtoSpanExtractor(ExtractorConfiguration(Format.PROTO, spanValidationConfig), LoggerFactory.getLogger(classOf[ProtoSpanExtractor]), List()).extractKeyValuePairs(sp._2.toByteArray)
@@ -54,7 +54,7 @@ class KeyExtractorSpec extends FunSpec with Matchers with MetricsSupport {
5454
"trace-id-1" -> createSpan("trace-id-1", "spanId_1", "service_1", "operation", StartTimeMicros, 1),
5555
"trace-id-2" -> createSpan("trace-id-2", "spanId_2", "service_2", "operation", StartTimeMicros, 1))
5656

57-
val spanValidationConfig = SpanValidation(SpanMaxSize(enable = false, 5000, "", "", Seq(), Seq()))
57+
val spanValidationConfig = SpanValidation(SpanMaxSize(enable = false, logOnly = false, 5000, "", "", Seq(), Seq()))
5858

5959
spanMap.foreach(sp => {
6060
val kvPairs = new ProtoSpanExtractor(ExtractorConfiguration(Format.JSON, spanValidationConfig), LoggerFactory.getLogger(classOf[ProtoSpanExtractor]), List()).extractKeyValuePairs(sp._2.toByteArray)

commons/src/test/scala/com/expedia/www/haystack/collector/commons/unit/ProtoSpanExtractorSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ProtoSpanExtractorSpec extends FunSpec with Matchers with MockitoSugar {
3434
describe("Protobuf Span Extractor") {
3535
val mockLogger = mock[Logger]
3636

37-
val spanSizeValidationConfig = SpanValidation(SpanMaxSize(enable = true, SpanSizeLimit, "X-HAYSTACK-SPAN-INFO", "Tags Truncated", Seq("error"), Seq(SkipTagTruncationServiceName)))
37+
val spanSizeValidationConfig = SpanValidation(SpanMaxSize(enable = true, logOnly = false, SpanSizeLimit, "X-HAYSTACK-SPAN-INFO", "Tags Truncated", Seq("error"), Seq(SkipTagTruncationServiceName)))
3838
val protoSpanExtractor = new ProtoSpanExtractor(ExtractorConfiguration(Format.PROTO, spanSizeValidationConfig), mockLogger, List())
3939

4040
val largestInvalidStartTime = SmallestAllowedStartTimeMicros - 1

http/src/main/resources/config/base.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ extractor {
1313

1414
# Validate size of span. Truncate span tags when size exceeds spcified limit.
1515
# enable: true/false
16+
# log.only: if enabled, only logs such spans but doesn't truncate the tags
1617
# max.size.limit: maximum size allowed
1718
# message.tag.key: this tag key will be added when tags are truncated
1819
# message.tag.value: value of the above tag key indicating the truncation
1920
# skip.tags: truncate all span tags except these
2021
# skip.services: truncate span tags for all services except these
2122
max.size {
2223
enable = "false"
24+
log.only = "false"
2325
max.size.limit = 5000 // in bytes
2426
message.tag.key = "X-HAYSTACK-SPAN-INFO"
2527
message.tag.value = "Tags are truncated. REASON: Span Size Limit Exceeded. Please contact Haystack for more details"

kinesis/src/main/resources/config/base.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ extractor {
1818

1919
# Validate size of span. Truncate span tags when size exceeds spcified limit.
2020
# enable: true/false
21+
# log.only: if enabled, only logs such spans but doesn't truncate the tags
2122
# max.size.limit: maximum size allowed
2223
# message.tag.key: this tag key will be added when tags are truncated
2324
# message.tag.value: value of the above tag key indicating the truncation
2425
# skip.tags: truncate all span tags except these
2526
# skip.services: truncate span tags for all services except these
2627
max.size {
2728
enable = "false"
29+
log.only = "false"
2830
max.size.limit = 5000 // in bytes
2931
message.tag.key = "X-HAYSTACK-SPAN-INFO"
3032
message.tag.value = "Tags are truncated. REASON: Span Size Limit Exceeded. Please contact Haystack for more details"

kinesis/src/test/resources/config/base.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ extractor {
1515

1616
# Validate size of span. Truncate span tags when size exceeds spcified limit.
1717
# enable: true/false
18+
# log.only: if enabled, only logs such spans but doesn't truncate the tags
1819
# max.size.limit: maximum size allowed
1920
# message.tag.key: this tag key will be added when tags are truncated
2021
# message.tag.value: value of the above tag key indicating the truncation
2122
# skip.tags: truncate all span tags except these
2223
# skip.services: truncate span tags for all services except these
2324
max.size {
2425
enable = "false"
26+
log.only = "false"
2527
max.size.limit = 5000 // in bytes
2628
message.tag.key = "X-HAYSTACK-SPAN-INFO"
2729
message.tag.value = "Tags are truncated. REASON: Span Size Limit Exceeded. Please contact Haystack for more details"

kinesis/src/test/scala/com/expedia/www/haystack/kinesis/span/collector/unit/tests/RecordProcessorSpec.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class RecordProcessorSpec extends FunSpec with Matchers with EasyMockSugar with
7979
}.once()
8080

8181
whenExecuting(sink, checkpointer) {
82-
val spanValidationConfig = SpanValidation(SpanMaxSize(enable = false, 5000, "", "", Seq(), Seq()))
82+
val spanValidationConfig = SpanValidation(SpanMaxSize(enable = false, logOnly = false, 5000, "", "", Seq(), Seq()))
8383
val processor = new RecordProcessor(kinesisConfig, new ProtoSpanExtractor(ExtractorConfiguration(Format.PROTO, spanValidationConfig), LoggerFactory.getLogger(classOf[ProtoSpanExtractor]), List()), sink)
8484
val input = new ProcessRecordsInput().withRecords(List(record).asJava).withCheckpointer(checkpointer)
8585
processor.processRecords(input)
@@ -137,7 +137,7 @@ class RecordProcessorSpec extends FunSpec with Matchers with EasyMockSugar with
137137
}.once()
138138

139139
whenExecuting(sink, checkpointer) {
140-
val spanValidationConfig = SpanValidation(SpanMaxSize(enable = false, 5000, "", "", Seq(), Seq()))
140+
val spanValidationConfig = SpanValidation(SpanMaxSize(enable = false, logOnly = false, 5000, "", "", Seq(), Seq()))
141141
val processor = new RecordProcessor(kinesisConfig, new ProtoSpanExtractor(ExtractorConfiguration(Format.PROTO, spanValidationConfig), LoggerFactory.getLogger(classOf[ProtoSpanExtractor]), List()), sink)
142142
val input_1 = new ProcessRecordsInput().withRecords(List(record_1).asJava).withCheckpointer(checkpointer)
143143
processor.processRecords(input_1)
@@ -166,7 +166,7 @@ class RecordProcessorSpec extends FunSpec with Matchers with EasyMockSugar with
166166
}.once
167167

168168
whenExecuting(sink, checkpointer) {
169-
val spanValidationConfig = SpanValidation(SpanMaxSize(enable = false, 5000, "", "", Seq(), Seq()))
169+
val spanValidationConfig = SpanValidation(SpanMaxSize(enable = false, logOnly = false, 5000, "", "", Seq(), Seq()))
170170
val processor = new RecordProcessor(kinesisConfig, new ProtoSpanExtractor(ExtractorConfiguration(Format.PROTO, spanValidationConfig), LoggerFactory.getLogger(classOf[ProtoSpanExtractor]), List()), sink)
171171
val input = new ProcessRecordsInput().withRecords(List(record).asJava).withCheckpointer(checkpointer)
172172
processor.processRecords(input)

0 commit comments

Comments
 (0)