Skip to content

Commit

Permalink
Merge branch 'main' into ddyurchenko/add-profiler-run-on-regression
Browse files Browse the repository at this point in the history
  • Loading branch information
felixge committed Mar 17, 2023
2 parents 931246a + 96b9f30 commit 843d685
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 88 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/appsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ on:
- 'internal/appsec/**'
- 'appsec/**'
- 'contrib/**/appsec.go'
merge_group: # on merge groups touching appsec files
paths:
- '.github/workflows/appsec.yml'
- 'internal/appsec/**'
- 'appsec/**'
- 'contrib/**/appsec.go'
push:
branches: release-v*
env:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
merge_group:

jobs:
analyze:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/parametric-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
pull_request:
branches:
- "**"
merge_group:
workflow_dispatch: {}
schedule:
- cron: '00 04 * * 2-6'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches:
- "**"
merge_group:

concurrency:
group: ${{ github.ref }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/system-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
pull_request:
branches:
- "**"
merge_group:
workflow_dispatch: {}
schedule:
- cron: '00 04 * * 2-6'
Expand Down
2 changes: 1 addition & 1 deletion contrib/database/sql/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// We start by telling the package which driver we will be using. For example, if we are using "github.com/lib/pq",
// we would do as follows:
//
// sqltrace.Register("pq", pq.Driver{})
// sqltrace.Register("pq", &pq.Driver{})
// db, err := sqltrace.Open("pq", "postgres://pqgotest:password@localhost...")
//
// The rest of our application would continue as usual, but with tracing enabled.
Expand Down
55 changes: 29 additions & 26 deletions ddtrace/tracer/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"testing"

"gopkg.in/DataDog/dd-trace-go.v1/internal/globalconfig"
"gopkg.in/DataDog/dd-trace-go.v1/internal/log"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -19,20 +20,22 @@ import (
func TestStartupLog(t *testing.T) {
t.Run("basic", func(t *testing.T) {
assert := assert.New(t)
tp := new(testLogger)
tp := new(log.RecordLogger)
tp.Ignore("appsec: ")
tracer, _, _, stop := startTestTracer(t, WithLogger(tp))
defer stop()

tp.Reset()
logStartup(tracer)
lines := removeAppSec(tp.Lines())
require.Len(t, lines, 2)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)? INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"","service":"tracer\.test(\.exe)?","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":false,"analytics_enabled":false,"sample_rate":"NaN","sample_rate_limit":"disabled","sampling_rules":null,"sampling_rules_error":"","service_mappings":null,"tags":{"runtime-id":"[^"]*"},"runtime_metrics_enabled":false,"health_metrics_enabled":false,"profiler_code_hotspots_enabled":((false)|(true)),"profiler_endpoints_enabled":((false)|(true)),"dd_version":"","architecture":"[^"]*","global_service":"","lambda_mode":"false","appsec":((true)|(false)),"agent_features":{"DropP0s":((true)|(false)),"Stats":((true)|(false)),"StatsdPort":0}}`, lines[1])
require.Len(t, tp.Logs(), 2)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)? INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"","service":"tracer\.test(\.exe)?","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":false,"analytics_enabled":false,"sample_rate":"NaN","sample_rate_limit":"disabled","sampling_rules":null,"sampling_rules_error":"","service_mappings":null,"tags":{"runtime-id":"[^"]*"},"runtime_metrics_enabled":false,"health_metrics_enabled":false,"profiler_code_hotspots_enabled":((false)|(true)),"profiler_endpoints_enabled":((false)|(true)),"dd_version":"","architecture":"[^"]*","global_service":"","lambda_mode":"false","appsec":((true)|(false)),"agent_features":{"DropP0s":((true)|(false)),"Stats":((true)|(false)),"StatsdPort":0}}`, tp.Logs()[1])
})

t.Run("configured", func(t *testing.T) {
assert := assert.New(t)
tp := new(testLogger)
tp := new(log.RecordLogger)
tp.Ignore("appsec: ")

os.Setenv("DD_TRACE_SAMPLE_RATE", "0.123")
defer os.Unsetenv("DD_TRACE_SAMPLE_RATE")
tracer, _, _, stop := startTestTracer(t,
Expand All @@ -55,13 +58,13 @@ func TestStartupLog(t *testing.T) {

tp.Reset()
logStartup(tracer)
require.Len(t, tp.Lines(), 2)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)? INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"configuredEnv","service":"configured.service","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":true,"analytics_enabled":true,"sample_rate":"0\.123000","sample_rate_limit":"100","sampling_rules":\[{"service":"mysql","name":"","sample_rate":0\.75,"type":"trace\(0\)"}\],"sampling_rules_error":"","service_mappings":{"initial_service":"new_service"},"tags":{"runtime-id":"[^"]*","tag":"value","tag2":"NaN"},"runtime_metrics_enabled":true,"health_metrics_enabled":true,"profiler_code_hotspots_enabled":((false)|(true)),"profiler_endpoints_enabled":((false)|(true)),"dd_version":"2.3.4","architecture":"[^"]*","global_service":"configured.service","lambda_mode":"false","appsec":((true)|(false)),"agent_features":{"DropP0s":false,"Stats":false,"StatsdPort":0}}`, tp.Lines()[1])
require.Len(t, tp.Logs(), 2)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)? INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"configuredEnv","service":"configured.service","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":true,"analytics_enabled":true,"sample_rate":"0\.123000","sample_rate_limit":"100","sampling_rules":\[{"service":"mysql","name":"","sample_rate":0\.75,"type":"trace\(0\)"}\],"sampling_rules_error":"","service_mappings":{"initial_service":"new_service"},"tags":{"runtime-id":"[^"]*","tag":"value","tag2":"NaN"},"runtime_metrics_enabled":true,"health_metrics_enabled":true,"profiler_code_hotspots_enabled":((false)|(true)),"profiler_endpoints_enabled":((false)|(true)),"dd_version":"2.3.4","architecture":"[^"]*","global_service":"configured.service","lambda_mode":"false","appsec":((true)|(false)),"agent_features":{"DropP0s":false,"Stats":false,"StatsdPort":0}}`, tp.Logs()[1])
})

t.Run("limit", func(t *testing.T) {
assert := assert.New(t)
tp := new(testLogger)
tp := new(log.RecordLogger)
os.Setenv("DD_TRACE_SAMPLE_RATE", "0.123")
defer os.Unsetenv("DD_TRACE_SAMPLE_RATE")
os.Setenv("DD_TRACE_RATE_LIMIT", "1000.001")
Expand All @@ -86,68 +89,68 @@ func TestStartupLog(t *testing.T) {

tp.Reset()
logStartup(tracer)
require.Len(t, tp.Lines(), 2)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)? INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"configuredEnv","service":"configured.service","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":true,"analytics_enabled":true,"sample_rate":"0\.123000","sample_rate_limit":"1000.001","sampling_rules":\[{"service":"mysql","name":"","sample_rate":0\.75,"type":"trace\(0\)"}\],"sampling_rules_error":"","service_mappings":{"initial_service":"new_service"},"tags":{"runtime-id":"[^"]*","tag":"value","tag2":"NaN"},"runtime_metrics_enabled":true,"health_metrics_enabled":true,"profiler_code_hotspots_enabled":((false)|(true)),"profiler_endpoints_enabled":((false)|(true)),"dd_version":"2.3.4","architecture":"[^"]*","global_service":"configured.service","lambda_mode":"false","appsec":((true)|(false)),"agent_features":{"DropP0s":false,"Stats":false,"StatsdPort":0}}`, tp.Lines()[1])
require.Len(t, tp.Logs(), 2)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)? INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"configuredEnv","service":"configured.service","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":true,"analytics_enabled":true,"sample_rate":"0\.123000","sample_rate_limit":"1000.001","sampling_rules":\[{"service":"mysql","name":"","sample_rate":0\.75,"type":"trace\(0\)"}\],"sampling_rules_error":"","service_mappings":{"initial_service":"new_service"},"tags":{"runtime-id":"[^"]*","tag":"value","tag2":"NaN"},"runtime_metrics_enabled":true,"health_metrics_enabled":true,"profiler_code_hotspots_enabled":((false)|(true)),"profiler_endpoints_enabled":((false)|(true)),"dd_version":"2.3.4","architecture":"[^"]*","global_service":"configured.service","lambda_mode":"false","appsec":((true)|(false)),"agent_features":{"DropP0s":false,"Stats":false,"StatsdPort":0}}`, tp.Logs()[1])
})

t.Run("errors", func(t *testing.T) {
assert := assert.New(t)
tp := new(testLogger)
tp := new(log.RecordLogger)
os.Setenv("DD_TRACE_SAMPLING_RULES", `[{"service": "some.service", "sample_rate": 0.234}, {"service": "other.service"}]`)
defer os.Unsetenv("DD_TRACE_SAMPLING_RULES")
tracer, _, _, stop := startTestTracer(t, WithLogger(tp))
defer stop()

tp.Reset()
logStartup(tracer)
require.Len(t, tp.Lines(), 2)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)? INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"","service":"tracer\.test(\.exe)?","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":false,"analytics_enabled":false,"sample_rate":"NaN","sample_rate_limit":"100","sampling_rules":\[{"service":"some.service","name":"","sample_rate":0\.234,"type":"trace\(0\)"}\],"sampling_rules_error":"\\n\\tat index 1: rate not provided","service_mappings":null,"tags":{"runtime-id":"[^"]*"},"runtime_metrics_enabled":false,"health_metrics_enabled":false,"profiler_code_hotspots_enabled":((false)|(true)),"profiler_endpoints_enabled":((false)|(true)),"dd_version":"","architecture":"[^"]*","global_service":"","lambda_mode":"false","appsec":((true)|(false)),"agent_features":{"DropP0s":((true)|(false)),"Stats":((true)|(false)),"StatsdPort":0}}`, tp.Lines()[1])
require.Len(t, tp.Logs(), 2)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)? INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"","service":"tracer\.test(\.exe)?","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":false,"analytics_enabled":false,"sample_rate":"NaN","sample_rate_limit":"100","sampling_rules":\[{"service":"some.service","name":"","sample_rate":0\.234,"type":"trace\(0\)"}\],"sampling_rules_error":"\\n\\tat index 1: rate not provided","service_mappings":null,"tags":{"runtime-id":"[^"]*"},"runtime_metrics_enabled":false,"health_metrics_enabled":false,"profiler_code_hotspots_enabled":((false)|(true)),"profiler_endpoints_enabled":((false)|(true)),"dd_version":"","architecture":"[^"]*","global_service":"","lambda_mode":"false","appsec":((true)|(false)),"agent_features":{"DropP0s":((true)|(false)),"Stats":((true)|(false)),"StatsdPort":0}}`, tp.Logs()[1])
})

t.Run("lambda", func(t *testing.T) {
assert := assert.New(t)
tp := new(testLogger)
tp := new(log.RecordLogger)
tracer, _, _, stop := startTestTracer(t, WithLogger(tp), WithLambdaMode(true))
defer stop()

tp.Reset()
logStartup(tracer)
assert.Len(tp.Lines(), 1)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)? INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"","service":"tracer\.test(\.exe)?","agent_url":"http://localhost:9/v0.4/traces","agent_error":"","debug":false,"analytics_enabled":false,"sample_rate":"NaN","sample_rate_limit":"disabled","sampling_rules":null,"sampling_rules_error":"","service_mappings":null,"tags":{"runtime-id":"[^"]*"},"runtime_metrics_enabled":false,"health_metrics_enabled":false,"profiler_code_hotspots_enabled":((false)|(true)),"profiler_endpoints_enabled":((false)|(true)),"dd_version":"","architecture":"[^"]*","global_service":"","lambda_mode":"true","appsec":((true)|(false)),"agent_features":{"DropP0s":false,"Stats":false,"StatsdPort":0}}`, tp.Lines()[0])
assert.Len(tp.Logs(), 1)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)? INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"","service":"tracer\.test(\.exe)?","agent_url":"http://localhost:9/v0.4/traces","agent_error":"","debug":false,"analytics_enabled":false,"sample_rate":"NaN","sample_rate_limit":"disabled","sampling_rules":null,"sampling_rules_error":"","service_mappings":null,"tags":{"runtime-id":"[^"]*"},"runtime_metrics_enabled":false,"health_metrics_enabled":false,"profiler_code_hotspots_enabled":((false)|(true)),"profiler_endpoints_enabled":((false)|(true)),"dd_version":"","architecture":"[^"]*","global_service":"","lambda_mode":"true","appsec":((true)|(false)),"agent_features":{"DropP0s":false,"Stats":false,"StatsdPort":0}}`, tp.Logs()[0])
})
}

func TestLogSamplingRules(t *testing.T) {
assert := assert.New(t)
tp := new(testLogger)
tp := new(log.RecordLogger)
tp.Ignore("appsec: ")
os.Setenv("DD_TRACE_SAMPLING_RULES", `[{"service": "some.service", "sample_rate": 0.234}, {"service": "other.service"}, {"service": "last.service", "sample_rate": 0.56}, {"odd": "pairs"}, {"sample_rate": 9.10}]`)
defer os.Unsetenv("DD_TRACE_SAMPLING_RULES")
_, _, _, stop := startTestTracer(t, WithLogger(tp))
defer stop()

lines := removeAppSec(tp.Lines())
assert.Len(lines, 1)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)? WARN: DIAGNOSTICS Error\(s\) parsing sampling rules: found errors:\n\tat index 1: rate not provided\n\tat index 3: rate not provided\n\tat index 4: ignoring rule {Service: Name: Rate:9\.10 MaxPerSecond:0}: rate is out of \[0\.0, 1\.0] range$`, lines[0])
assert.Len(tp.Logs(), 1)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)? WARN: DIAGNOSTICS Error\(s\) parsing sampling rules: found errors:\n\tat index 1: rate not provided\n\tat index 3: rate not provided\n\tat index 4: ignoring rule {Service: Name: Rate:9\.10 MaxPerSecond:0}: rate is out of \[0\.0, 1\.0] range$`, tp.Logs()[0])
}

func TestLogAgentReachable(t *testing.T) {
assert := assert.New(t)
tp := new(testLogger)
tp := new(log.RecordLogger)
tracer, _, _, stop := startTestTracer(t, WithLogger(tp))
defer stop()
tp.Reset()
logStartup(tracer)
require.Len(t, tp.Lines(), 2)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)? WARN: DIAGNOSTICS Unable to reach agent intake: Post`, tp.Lines()[0])
require.Len(t, tp.Logs(), 2)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)? WARN: DIAGNOSTICS Unable to reach agent intake: Post`, tp.Logs()[0])
}

func TestLogFormat(t *testing.T) {
assert := assert.New(t)
tp := new(testLogger)
tp := new(log.RecordLogger)
tracer := newTracer(WithLogger(tp), WithRuntimeMetrics(), WithDebugMode(true))
defer tracer.Stop()
tp.Reset()
tracer.StartSpan("test", ServiceName("test-service"), ResourceName("/"), WithSpanID(12345))
assert.Len(tp.Lines(), 1)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)? DEBUG: Started Span: dd.trace_id="12345" dd.span_id="12345", Operation: test, Resource: /, Tags: map.*, map.*`, tp.Lines()[0])
assert.Len(tp.Logs(), 1)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)? DEBUG: Started Span: dd.trace_id="12345" dd.span_id="12345", Operation: test, Resource: /, Tags: map.*, map.*`, tp.Logs()[0])
}
59 changes: 11 additions & 48 deletions ddtrace/tracer/spancontext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package tracer

import (
"context"
"strings"
"sync"
"testing"
"time"
Expand All @@ -33,7 +32,8 @@ func setupteardown(start, max int) func() {
func TestNewSpanContextPushError(t *testing.T) {
defer setupteardown(2, 2)()

tp := new(testLogger)
tp := new(log.RecordLogger)
tp.Ignore("appsec: ")
_, _, _, stop := startTestTracer(t, WithLogger(tp), WithLambdaMode(true))
defer stop()
parent := newBasicSpan("test1") // 1st span in trace
Expand All @@ -45,7 +45,7 @@ func TestNewSpanContextPushError(t *testing.T) {
child.context = newSpanContext(child, parent.context)

log.Flush()
assert.Contains(t, removeAppSec(tp.Lines())[0], "ERROR: trace buffer full (2)")
assert.Contains(t, tp.Logs()[0], "ERROR: trace buffer full (2)")
}

func TestAsyncSpanRace(t *testing.T) {
Expand Down Expand Up @@ -144,7 +144,8 @@ func TestSpanTracePushNoFinish(t *testing.T) {

assert := assert.New(t)

tp := new(testLogger)
tp := new(log.RecordLogger)
tp.Ignore("appsec: ")
_, _, _, stop := startTestTracer(t, WithLogger(tp), WithLambdaMode(true))
defer stop()

Expand All @@ -162,7 +163,7 @@ func TestSpanTracePushNoFinish(t *testing.T) {

<-time.After(time.Second / 10)
log.Flush()
assert.Len(removeAppSec(tp.Lines()), 0)
assert.Len(tp.Logs(), 0)
t.Logf("expected timeout, nothing should show up in buffer as the trace is not finished")
}

Expand Down Expand Up @@ -354,7 +355,8 @@ func TestSpanContextParent(t *testing.T) {
func TestSpanContextPushFull(t *testing.T) {
defer func(old int) { traceMaxSize = old }(traceMaxSize)
traceMaxSize = 2
tp := new(testLogger)
tp := new(log.RecordLogger)
tp.Ignore("appsec: ")
_, _, _, stop := startTestTracer(t, WithLogger(tp), WithLambdaMode(true))
defer stop()

Expand All @@ -366,13 +368,13 @@ func TestSpanContextPushFull(t *testing.T) {
assert := assert.New(t)
buffer.push(span1)
log.Flush()
assert.Len(removeAppSec(tp.Lines()), 0)
assert.Len(tp.Logs(), 0)
buffer.push(span2)
log.Flush()
assert.Len(removeAppSec(tp.Lines()), 0)
assert.Len(tp.Logs(), 0)
buffer.push(span3)
log.Flush()
assert.Contains(removeAppSec(tp.Lines())[0], "ERROR: trace buffer full (2)")
assert.Contains(tp.Logs()[0], "ERROR: trace buffer full (2)")
}

func TestSpanContextBaggage(t *testing.T) {
Expand Down Expand Up @@ -407,33 +409,6 @@ func TestSpanContextIteratorBreak(t *testing.T) {
assert.Len(t, got, 0)
}

// testLogger implements a mock Printer.
type testLogger struct {
mu sync.RWMutex
lines []string
}

// Print implements log.Printer.
func (tp *testLogger) Log(msg string) {
tp.mu.Lock()
defer tp.mu.Unlock()
tp.lines = append(tp.lines, msg)
}

// Lines returns the lines that were printed using this printer.
func (tp *testLogger) Lines() []string {
tp.mu.RLock()
defer tp.mu.RUnlock()
return tp.lines
}

// Reset resets the printer's internal buffer.
func (tp *testLogger) Reset() {
tp.mu.Lock()
defer tp.mu.Unlock()
tp.lines = tp.lines[:0]
}

func BenchmarkBaggageItemPresent(b *testing.B) {
ctx := spanContext{baggage: map[string]string{"key": "value"}, hasBaggage: 1}
for n := 0; n < b.N; n++ {
Expand All @@ -452,18 +427,6 @@ func BenchmarkBaggageItemEmpty(b *testing.B) {
}
}

// Remove the appsec logs from the given log lines
func removeAppSec(lines []string) []string {
res := make([]string, 0, len(lines))
for _, line := range lines {
if strings.Contains(line, "appsec:") {
continue
}
res = append(res, line)
}
return res
}

func TestSetSamplingPriorityLocked(t *testing.T) {
t.Run("NoPriorAndP0IsIgnored", func(t *testing.T) {
tr := trace{
Expand Down
Loading

0 comments on commit 843d685

Please sign in to comment.