Skip to content

Commit

Permalink
Merge branch 'master' into drop-old-go
Browse files Browse the repository at this point in the history
  • Loading branch information
axw authored Jan 13, 2022
2 parents 8197da7 + 4f4d32c commit 2d0a8ce
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 244 deletions.
16 changes: 0 additions & 16 deletions modelwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"go.elastic.co/apm/internal/ringbuffer"
"go.elastic.co/apm/model"
"go.elastic.co/apm/stacktrace"
"go.elastic.co/fastjson"
)

Expand Down Expand Up @@ -162,7 +161,6 @@ func (w *modelWriter) buildModelSpan(out *model.Span, span *Span, sd *SpanData)

w.modelStacktrace = appendModelStacktraceFrames(w.modelStacktrace, sd.stacktrace)
out.Stacktrace = w.modelStacktrace
w.setStacktraceContext(out.Stacktrace)
}

func (w *modelWriter) buildModelError(out *model.Error, e *ErrorData) {
Expand Down Expand Up @@ -197,7 +195,6 @@ func (w *modelWriter) buildModelError(out *model.Error, e *ErrorData) {
if len(e.logStacktrace) != 0 {
w.modelStacktrace = appendModelStacktraceFrames(w.modelStacktrace, e.logStacktrace)
}
w.setStacktraceContext(w.modelStacktrace)

var modelStacktraceOffset int
if e.exception.message != "" {
Expand Down Expand Up @@ -262,19 +259,6 @@ func stacktraceCulprit(frames []model.StacktraceFrame) string {
return ""
}

func (w *modelWriter) setStacktraceContext(stack []model.StacktraceFrame) {
if w.cfg.contextSetter == nil || len(stack) == 0 {
return
}
err := stacktrace.SetContext(w.cfg.contextSetter, stack, w.cfg.preContext, w.cfg.postContext)
if err != nil {
if w.cfg.logger != nil {
w.cfg.logger.Debugf("setting context failed: %v", err)
}
w.stats.Errors.SetContext++
}
}

func normalizeOutcome(outcome string) string {
switch outcome {
case "success", "failure", "unknown":
Expand Down
100 changes: 0 additions & 100 deletions stacktrace/context.go

This file was deleted.

99 changes: 0 additions & 99 deletions stacktrace/context_test.go

This file was deleted.

36 changes: 10 additions & 26 deletions tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,11 @@ import (
"go.elastic.co/apm/internal/ringbuffer"
"go.elastic.co/apm/internal/wildcard"
"go.elastic.co/apm/model"
"go.elastic.co/apm/stacktrace"
"go.elastic.co/apm/transport"
"go.elastic.co/fastjson"
)

const (
defaultPreContext = 3
defaultPostContext = 3
gracePeriodJitter = 0.1 // +/- 10%
tracerEventChannelCap = 1000
)
Expand Down Expand Up @@ -503,8 +500,6 @@ func newTracer(opts TracerOptions) *Tracer {
cfg.requestDuration = opts.requestDuration
cfg.requestSize = opts.requestSize
cfg.disabledMetrics = opts.disabledMetrics
cfg.preContext = defaultPreContext
cfg.postContext = defaultPostContext
cfg.metricsGatherers = []MetricsGatherer{newBuiltinMetricsGatherer(t)}
if apmlog.DefaultLogger != nil {
cfg.logger = apmlog.DefaultLogger
Expand All @@ -519,18 +514,16 @@ func newTracer(opts TracerOptions) *Tracer {
// tracerConfig holds the tracer's runtime configuration, which may be modified
// by sending a tracerConfigCommand to the tracer's configCommands channel.
type tracerConfig struct {
recording bool
requestSize int
requestDuration time.Duration
metricsInterval time.Duration
logger WarningLogger
metricsGatherers []MetricsGatherer
contextSetter stacktrace.ContextSetter
preContext, postContext int
disabledMetrics wildcard.Matchers
cpuProfileDuration time.Duration
cpuProfileInterval time.Duration
heapProfileInterval time.Duration
recording bool
requestSize int
requestDuration time.Duration
metricsInterval time.Duration
logger WarningLogger
metricsGatherers []MetricsGatherer
disabledMetrics wildcard.Matchers
cpuProfileDuration time.Duration
cpuProfileInterval time.Duration
heapProfileInterval time.Duration
}

type tracerConfigCommand func(*tracerConfig)
Expand Down Expand Up @@ -604,15 +597,6 @@ func (t *Tracer) SetMetricsInterval(d time.Duration) {
})
}

// SetContextSetter sets the stacktrace.ContextSetter to be used for
// setting stacktrace source context. If nil (which is the initial
// value), no context will be set.
func (t *Tracer) SetContextSetter(setter stacktrace.ContextSetter) {
t.sendConfigCommand(func(cfg *tracerConfig) {
cfg.contextSetter = setter
})
}

// SetLogger sets the Logger to be used for logging the operation of
// the tracer.
//
Expand Down
3 changes: 0 additions & 3 deletions tracer_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ type TracerStats struct {

// TracerStatsErrors holds error statistics for a Tracer.
type TracerStatsErrors struct {
SetContext uint64
SendStream uint64
}

Expand All @@ -43,7 +42,6 @@ func (s TracerStats) isZero() bool {
// accumulate updates the stats by accumulating them with
// the values in rhs.
func (s *TracerStats) accumulate(rhs TracerStats) {
atomic.AddUint64(&s.Errors.SetContext, rhs.Errors.SetContext)
atomic.AddUint64(&s.Errors.SendStream, rhs.Errors.SendStream)
atomic.AddUint64(&s.ErrorsSent, rhs.ErrorsSent)
atomic.AddUint64(&s.ErrorsDropped, rhs.ErrorsDropped)
Expand All @@ -57,7 +55,6 @@ func (s *TracerStats) accumulate(rhs TracerStats) {
func (s *TracerStats) copy() TracerStats {
return TracerStats{
Errors: TracerStatsErrors{
SetContext: atomic.LoadUint64(&s.Errors.SetContext),
SendStream: atomic.LoadUint64(&s.Errors.SendStream),
},
ErrorsSent: atomic.LoadUint64(&s.ErrorsSent),
Expand Down

0 comments on commit 2d0a8ce

Please sign in to comment.