Support trace event overflow.

This commit is contained in:
A.J. Beamon 2018-05-04 15:19:56 -07:00
parent 2a46fdb31d
commit 047563aa62
3 changed files with 7 additions and 2 deletions

View File

@ -119,6 +119,7 @@ FlowKnobs::FlowKnobs(bool randomize, bool isSimulated) {
init( TRACE_EVENT_METRIC_UNITS_PER_SAMPLE, 500 );
init( TRACE_EVENT_THROTLLER_SAMPLE_EXPIRY, 1800.0 ); // 30 mins
init( TRACE_EVENT_THROTTLER_MSG_LIMIT, 20000 );
init( TRACE_EVENT_MAX_SIZE, 4000 );
init( TRACE_LOG_MAX_PREOPEN_BUFFER, 1000000 );
//TDMetrics

View File

@ -141,6 +141,7 @@ public:
int TRACE_EVENT_METRIC_UNITS_PER_SAMPLE;
int TRACE_EVENT_THROTLLER_SAMPLE_EXPIRY;
int TRACE_EVENT_THROTTLER_MSG_LIMIT;
int TRACE_EVENT_MAX_SIZE;
int TRACE_LOG_MAX_PREOPEN_BUFFER;
//TDMetrics

View File

@ -879,9 +879,12 @@ TraceEvent& TraceEvent::detailImpl( std::string key, std::string value, bool wri
fields.addField(key, value);
length += key.size() + value.size();
// TODO: Overflow? buffer was first 300 bytes. TraceEvent(SevError, "TraceEventOverflow").detail("TraceFirstBytes", buffer);
if(writeEventMetricField) {
if(length > FLOW_KNOBS->TRACE_EVENT_MAX_SIZE) {
TraceEvent(SevError, "TraceEventOverflow").detail("TraceFirstBytes", fields.toString().substr(300));
enabled = false;
}
else if(writeEventMetricField) {
tmpEventMetric->setField(key.c_str(), Standalone<StringRef>(StringRef(value)));
}
}