Skip to content

Commit

Permalink
ddtrace/tracer: hide TracerConf function
Browse files Browse the repository at this point in the history
  • Loading branch information
darccio committed Mar 25, 2024
1 parent 42807ee commit 8c59737
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ddtrace/mocktracer/mocktracer.go
Expand Up @@ -186,7 +186,7 @@ func (t *mocktracer) Inject(context *tracer.SpanContext, carrier interface{}) er
}).Inject(context, carrier)
}

func (t *mocktracer) TracerConf() tracer.TracerConf {
func (t *mocktracer) tracerConf() tracer.TracerConf {
return tracer.TracerConf{}
}

Expand Down
2 changes: 1 addition & 1 deletion ddtrace/tracer/globaltracer_test.go
Expand Up @@ -26,7 +26,7 @@ func (r *raceTestTracer) Stop() {
r.stopped = true
}

func (*raceTestTracer) TracerConf() TracerConf {
func (*raceTestTracer) tracerConf() TracerConf {
return TracerConf{}
}

Expand Down
2 changes: 1 addition & 1 deletion ddtrace/tracer/noop.go
Expand Up @@ -31,7 +31,7 @@ func (NoopTracer) Stop() {}

// TODO(kjn v2): These should be removed. They are here temporarily to facilitate
// the shift to the v2 API.
func (NoopTracer) TracerConf() TracerConf {
func (NoopTracer) tracerConf() TracerConf {
return TracerConf{}
}

Expand Down
4 changes: 2 additions & 2 deletions ddtrace/tracer/span.go
Expand Up @@ -641,7 +641,7 @@ func (s *Span) finish(finishTime int64) {

keep := true
if t := GetGlobalTracer(); t != nil {
tc := t.TracerConf()
tc := t.(*tracer).tracerConf()
if !tc.Disabled {
// we have an active tracer
if tc.CanComputeStats && shouldComputeStats(s) {
Expand Down Expand Up @@ -794,7 +794,7 @@ func (s *Span) Format(f fmt.State, c rune) {
fmt.Fprintf(f, "dd.service=%s ", svc)
}
if tr := GetGlobalTracer(); tr != nil {
tc := tr.TracerConf()
tc := tr.(*tracer).tracerConf()
if tc.EnvTag != "" {
fmt.Fprintf(f, "dd.env=%s ", tc.EnvTag)
} else if env := os.Getenv("DD_ENV"); env != "" {
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/tracer/spancontext.go
Expand Up @@ -481,7 +481,7 @@ func (t *trace) finishedOne(s *Span) {
if tr == nil {
return
}
tc := tr.TracerConf()
tc := tr.(*tracer).tracerConf()
setPeerService(s, tr)

// attach the _dd.base_service tag only when the globally configured service name is different from the
Expand Down Expand Up @@ -560,7 +560,7 @@ func (t *trace) finishChunk(tr Tracer, ch *Chunk) {
// setPeerService sets the peer.service, _dd.peer.service.source, and _dd.peer.service.remapped_from
// tags as applicable for the given span.
func setPeerService(s *Span, t Tracer) {
tc := t.TracerConf()
tc := t.(*tracer).tracerConf()
if _, ok := s.meta[ext.PeerService]; ok { // peer.service already set on the span
s.setMeta(keyPeerServiceSource, ext.PeerService)
} else { // no peer.service currently set
Expand Down
6 changes: 1 addition & 5 deletions ddtrace/tracer/tracer.go
Expand Up @@ -65,10 +65,6 @@ type Tracer interface {
// Stop stops the tracer. Calls to Stop should be idempotent.
Stop()

// TODO(kjn v2): These can be removed / consolidated. These are
// here temporarily as we figure out a sensible API.
TracerConf() TracerConf

SubmitStats(*Span)
SubmitAbandonedSpan(*Span, bool)
SubmitChunk(any) // This is a horrible signature. This will eventually become SubmitChunk(Chunk)
Expand Down Expand Up @@ -774,7 +770,7 @@ func (t *tracer) Extract(carrier interface{}) (*SpanContext, error) {
return t.config.propagator.Extract(carrier)
}

func (t *tracer) TracerConf() TracerConf {
func (t *tracer) tracerConf() TracerConf {
return TracerConf{
CanComputeStats: t.config.canComputeStats(),
CanDropP0s: t.config.canDropP0s(),
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/tracer/transport.go
Expand Up @@ -149,7 +149,7 @@ func (t *httpTransport) send(p *payload) (body io.ReadCloser, err error) {
req.Header.Set("Content-Length", strconv.Itoa(p.size()))
req.Header.Set(headerComputedTopLevel, "yes")
if t := GetGlobalTracer(); t != nil {
if t.TracerConf().CanComputeStats {
if t.(*tracer).tracerConf().CanComputeStats {
req.Header.Set("Datadog-Client-Computed-Stats", "yes")
}
droppedTraces := int(tracerstats.Count(tracerstats.AgentDroppedP0Traces))
Expand Down

0 comments on commit 8c59737

Please sign in to comment.