Skip to content

Commit

Permalink
Revert "Revert "pkg/trace: make changes to allow merging the reposito…
Browse files Browse the repository at this point in the history
…ry""

This reverts commit 7835571.
  • Loading branch information
gbbr committed Jan 23, 2019
1 parent 0a19a75 commit bafaf55
Show file tree
Hide file tree
Showing 59 changed files with 701 additions and 604 deletions.
28 changes: 28 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,6 @@ core,k8s.io/apiextensions-apiserver,Apache-2.0
core,github.com/docker/spdystream,Apache-2.0
core,gopkg.in/square/go-jose.v2,Apache-2.0
core,github.com/opencontainers/go-digest,Apache-2.0
core,github.com/philhofer/fwd,MIT
core,github.com/DataDog/datadog-go,MIT
core,github.com/tinylib/msgp,MIT
2 changes: 1 addition & 1 deletion cmd/trace-agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ func TestEventProcessorFromConfLegacy(t *testing.T) {
{name: "metrics/overrides/legacy", intakeSPS: 100, serviceName: "serviceC", opName: "opC", extractionRate: 1, priority: sampler.PriorityNone, expectedEPS: 100, deltaPct: 0.1, duration: 10 * time.Second},
} {
testEventProcessorFromConf(t, &config.AgentConfig{
MaxEPS: testMaxEPS,
MaxEPS: testMaxEPS,
AnalyzedRateByServiceLegacy: rateByService,
}, testCase)
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/trace-agent/main_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

var elog debug.Log

// ServiceName specifies the service name used in the operating system.
const ServiceName = "datadog-trace-agent"

type myservice struct{}
Expand Down Expand Up @@ -265,7 +266,7 @@ func exePath() (string, error) {
if !fi.Mode().IsDir() {
return p, nil
}
err = fmt.Errorf("%s is directory", p)
return "", fmt.Errorf("%s is directory", p)
}
}
return "", err
Expand Down
2 changes: 1 addition & 1 deletion cmd/trace-agent/sampler.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/DataDog/datadog-agent/pkg/trace/watchdog"
)

// Sampler chooses wich spans to write to the API
// Sampler chooses which spans to write to the API
type Sampler struct {
// For stats
keptTraceCount uint64
Expand Down
2 changes: 1 addition & 1 deletion cmd/trace-agent/service_mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (s *ServiceMapper) update(metadata pb.ServicesMetadata) {
continue
}

// We do this inside the for loop to avoid unecessary memory allocations.
// We do this inside the for loop to avoid unnecessary memory allocations.
// After few method executions, the cache will be warmed up and this section be skipped altogether.
if changes == nil {
changes = make(pb.ServicesMetadata)
Expand Down
12 changes: 6 additions & 6 deletions cmd/trace-agent/sublayers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ func TestExtractTopLevelSubtracesWithSimpleTrace(t *testing.T) {
}

expected := []Subtrace{
Subtrace{trace[0], trace},
Subtrace{trace[1], []*pb.Span{trace[1], trace[2], trace[3]}},
{trace[0], trace},
{trace[1], []*pb.Span{trace[1], trace[2], trace[3]}},
}

traceutil.ComputeTopLevel(trace)
Expand Down Expand Up @@ -50,8 +50,8 @@ func TestExtractTopLevelSubtracesShouldIgnoreLeafTopLevel(t *testing.T) {
}

expected := []Subtrace{
Subtrace{trace[0], trace},
Subtrace{trace[1], []*pb.Span{trace[1], trace[2]}},
{trace[0], trace},
{trace[1], []*pb.Span{trace[1], trace[2]}},
}

traceutil.ComputeTopLevel(trace)
Expand Down Expand Up @@ -79,8 +79,8 @@ func TestExtractTopLevelSubtracesWorksInSpiteOfCycles(t *testing.T) {
}

expected := []Subtrace{
Subtrace{trace[0], trace},
Subtrace{trace[1], []*pb.Span{trace[1], trace[2]}},
{trace[0], trace},
{trace[1], []*pb.Span{trace[1], trace[2]}},
}

traceutil.ComputeTopLevel(trace)
Expand Down
8 changes: 4 additions & 4 deletions pkg/trace/agent/normalizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ func TestNormalizeName(t *testing.T) {

func TestNormalizeNameFailure(t *testing.T) {
invalidNames := []string{
"", // Empty.
"/", // No alphanumerics.
"//", // Still no alphanumerics.
"", // Empty.
"/", // No alphanumerics.
"//", // Still no alphanumerics.
strings.Repeat("x", MaxNameLen+1), // Too long.
}
s := testSpan()
Expand Down Expand Up @@ -387,7 +387,7 @@ func TestNormalizeInvalidUTF8(t *testing.T) {
func BenchmarkNormalization(b *testing.B) {
b.ReportAllocs()

for i := 0; i < b.N; i += 1 {
for i := 0; i < b.N; i++ {
Normalize(testSpan())
}
}
3 changes: 3 additions & 0 deletions pkg/trace/agent/processed_trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/DataDog/datadog-agent/pkg/trace/sampler"
)

// ProcessedTrace represents a trace being processed in the agent.
type ProcessedTrace struct {
Trace pb.Trace
WeightedTrace WeightedTrace
Expand All @@ -14,13 +15,15 @@ type ProcessedTrace struct {
Sampled bool
}

// Weight returns the weight at the root span.
func (pt *ProcessedTrace) Weight() float64 {
if pt.Root == nil {
return 1.0
}
return sampler.Weight(pt.Root)
}

// GetSamplingPriority returns the sampling priority of the root span.
func (pt *ProcessedTrace) GetSamplingPriority() (sampler.SamplingPriority, bool) {
return sampler.GetSamplingPriority(pt.Root)
}
Loading

0 comments on commit bafaf55

Please sign in to comment.