Skip to content

Commit

Permalink
Merge branch 'main' into resourcedetection-local-cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
odubajDT authored Jan 8, 2025
2 parents fbdac2f + 49b729d commit ebf2c3d
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 16 deletions.
27 changes: 27 additions & 0 deletions .chloggen/tailsamplingprocessor-decision-cache-logging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: tailsamplingprocessor

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Added debug logging to the sampling decision caches.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [37038]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
27 changes: 27 additions & 0 deletions .chloggen/tailsamplingprocessor-fixed-batch-debug-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: tailsamplingprocessor

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Fixed sampling policy evaluation debug logging batch metrics (e.g. sampled).

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [37040]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
11 changes: 10 additions & 1 deletion processor/tailsamplingprocessor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,13 @@ func (tsp *tailSamplingSpanProcessor) makeDecision(id pcommon.TraceID, trace *sa
finalDecision = sampling.Sampled
}

switch finalDecision {
case sampling.Sampled:
metrics.decisionSampled++
case sampling.NotSampled:
metrics.decisionNotSampled++
}

return finalDecision
}

Expand Down Expand Up @@ -443,6 +450,7 @@ func (tsp *tailSamplingSpanProcessor) processTraces(resourceSpans ptrace.Resourc
for id, spans := range idToSpansAndScope {
// If the trace ID is in the sampled cache, short circuit the decision
if _, ok := tsp.sampledIDCache.Get(id); ok {
tsp.logger.Debug("Trace ID is in the sampled cache", zap.Stringer("id", id))
traceTd := ptrace.NewTraces()
appendToTraces(traceTd, resourceSpans, spans)
tsp.releaseSampledTrace(tsp.ctx, id, traceTd)
Expand All @@ -453,6 +461,7 @@ func (tsp *tailSamplingSpanProcessor) processTraces(resourceSpans ptrace.Resourc
}
// If the trace ID is in the non-sampled cache, short circuit the decision
if _, ok := tsp.nonSampledIDCache.Get(id); ok {
tsp.logger.Debug("Trace ID is in the non-sampled cache", zap.Stringer("id", id))
tsp.telemetry.ProcessorTailSamplingEarlyReleasesFromCacheDecision.
Add(tsp.ctx, int64(len(spans)), attrSampledFalse)
continue
Expand Down Expand Up @@ -546,7 +555,7 @@ func (tsp *tailSamplingSpanProcessor) dropTrace(traceID pcommon.TraceID, deletio
tsp.numTracesOnMap.Add(^uint64(0))
}
if trace == nil {
tsp.logger.Debug("Attempt to delete traceID not on table")
tsp.logger.Debug("Attempt to delete trace ID not on table", zap.Stringer("id", traceID))
return
}

Expand Down
40 changes: 40 additions & 0 deletions processor/tailsamplingprocessor/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,46 @@ func TestDuplicatePolicyName(t *testing.T) {
assert.Equal(t, err, errors.New(`duplicate policy name "always_sample"`))
}

func TestDecisionPolicyMetrics(t *testing.T) {
traceIDs, batches := generateIDsAndBatches(10)
policy := []PolicyCfg{
{
sharedPolicyCfg: sharedPolicyCfg{
Name: "test-policy",
Type: Probabilistic,
ProbabilisticCfg: ProbabilisticCfg{SamplingPercentage: 50},
},
},
}
cfg := Config{
DecisionWait: defaultTestDecisionWait,
NumTraces: uint64(2 * len(traceIDs)),
ExpectedNewTracesPerSec: 64,
PolicyCfgs: policy,
}
sp, _ := newTracesProcessor(context.Background(), processortest.NewNopSettings(), consumertest.NewNop(), cfg)
tsp := sp.(*tailSamplingSpanProcessor)
require.NoError(t, tsp.Start(context.Background(), componenttest.NewNopHost()))
defer func() {
require.NoError(t, tsp.Shutdown(context.Background()))
}()
metrics := &policyMetrics{}

for i, id := range traceIDs {
sb := &sampling.TraceData{
ArrivalTime: time.Now(),
ReceivedBatches: batches[i],
}

_ = tsp.makeDecision(id, sb, metrics)
}

assert.EqualValues(t, 5, metrics.decisionSampled)
assert.EqualValues(t, 5, metrics.decisionNotSampled)
assert.EqualValues(t, 0, metrics.idNotFoundOnMapCount)
assert.EqualValues(t, 0, metrics.evaluateErrorCount)
}

func collectSpanIDs(trace ptrace.Traces) []pcommon.SpanID {
var spanIDs []pcommon.SpanID

Expand Down
2 changes: 1 addition & 1 deletion receiver/azureblobreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22.0

require (
github.com/Azure/azure-event-hubs-go/v3 v3.6.2
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.0
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.5.0
github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent v0.117.0
Expand Down
4 changes: 2 additions & 2 deletions receiver/azureblobreceiver/go.sum

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

8 changes: 4 additions & 4 deletions receiver/azuremonitorreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azurem
go 1.22.0

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.0
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor v0.11.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0
Expand Down Expand Up @@ -60,9 +60,9 @@ require (
go.opentelemetry.io/otel/sdk v1.32.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/grpc v1.69.2 // indirect
Expand Down
16 changes: 8 additions & 8 deletions receiver/azuremonitorreceiver/go.sum

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

0 comments on commit ebf2c3d

Please sign in to comment.