Skip to content
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 MaxLogsPerSpan option #47

Merged
merged 1 commit into from
Oct 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
defaultReportTimeout = 30 * time.Second
defaultMaxLogKeyLen = 256
defaultMaxLogValueLen = 1024
defaultMaxLogsPerSpan = 500

// ParentSpanGUIDKey is the tag key used to record the relationship
// between child and parent spans.
Expand Down Expand Up @@ -117,6 +118,9 @@ type Options struct {
// variable-length value types (strings, interface{}, etc).
MaxLogValueLen int `yaml:"max_log_value_len"`

// MaxLogsPerSpan limits the number of logs in a single span.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remind me -- if someone sets this to 0, it would actually inherit the basictracer default, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we are setting options.MaxLogsPerSpan unconditionally after getting the DefaultOptions(). If we want that we can enclsoe that in a if MaxLogsPerSpan != 0

MaxLogsPerSpan int `yaml:"max_logs_per_span"`

// ReportingPeriod is the maximum duration of time between sending spans
// to a collector. If zero, the default will be used.
ReportingPeriod time.Duration `yaml:"reporting_period"`
Expand Down Expand Up @@ -150,6 +154,9 @@ func NewTracer(opts Options) ot.Tracer {
if opts.MaxLogValueLen == 0 {
opts.MaxLogValueLen = defaultMaxLogValueLen
}
if opts.MaxLogsPerSpan == 0 {
opts.MaxLogsPerSpan = defaultMaxLogsPerSpan
}
if opts.ReportingPeriod == 0 {
opts.ReportingPeriod = defaultMaxReportingPeriod
}
Expand Down Expand Up @@ -177,8 +184,9 @@ func NewTracer(opts Options) ot.Tracer {
ReportingPeriod: opts.ReportingPeriod,
ReportTimeout: opts.ReportTimeout,
DropSpanLogs: opts.DropSpanLogs,
MaxLogsPerSpan: opts.MaxLogsPerSpan,
Verbose: opts.Verbose,
MaxLogMessageLen: int(opts.MaxLogValueLen),
MaxLogMessageLen: opts.MaxLogValueLen,
}
r := thrift_rpc.NewRecorder(thriftOpts)
if r == nil {
Expand All @@ -187,6 +195,7 @@ func NewTracer(opts Options) ot.Tracer {
options.Recorder = r
}
options.DropAllLogs = opts.DropSpanLogs
options.MaxLogsPerSpan = opts.MaxLogsPerSpan
return basictracer.NewWithOptions(options)
}

Expand Down
4 changes: 4 additions & 0 deletions thrift_rpc/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ type Options struct {

// In place of Flags
MaxLogMessageLen int

// MaxLogsPerSpan limits the number of logs in a single span.
MaxLogsPerSpan int `yaml:"max_logs_per_span"`
}

// NewTracer returns a new Tracer that reports spans to a LightStep
Expand All @@ -106,6 +109,7 @@ func NewTracer(opts Options) ot.Tracer {
options.ShouldSample = func(_ uint64) bool { return true }
options.Recorder = NewRecorder(opts)
options.DropAllLogs = opts.DropSpanLogs
options.MaxLogsPerSpan = opts.MaxLogsPerSpan
return basictracer.NewWithOptions(options)
}

Expand Down