-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[processor/tailsampling] Refactor internal telemetry (#33108)
This PR is the first step in refactoring the internal telemetry for the tail-sampling processor. There are no expected changes in user behavior between this and the current main, but all OpenCensus code is now isolated and can be replaced without affecting other parts of the code. Once this PR is merged, the next step is to create equivalent metrics using the OpenTelemetry Go API. Signed-off-by: Juraci Paixão Kröhling <[email protected]> --------- Signed-off-by: Juraci Paixão Kröhling <[email protected]>
- Loading branch information
1 parent
aee4b75
commit 3868323
Showing
7 changed files
with
160 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
processor/tailsamplingprocessor/internal/sampling/package_test.go
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
processor/tailsamplingprocessor/internal/telemetry/featureflag.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package telemetry // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor/internal/telemetry" | ||
|
||
import "go.opentelemetry.io/collector/featuregate" | ||
|
||
var metricStatCountSpansSampledFeatureGate = featuregate.GlobalRegistry().MustRegister( | ||
"processor.tailsamplingprocessor.metricstatcountspanssampled", | ||
featuregate.StageAlpha, | ||
featuregate.WithRegisterDescription("When enabled, a new metric stat_count_spans_sampled will be available in the tail sampling processor. Differently from stat_count_traces_sampled, this metric will count the number of spans sampled or not per sampling policy, where the original counts traces."), | ||
) | ||
|
||
func isMetricStatCountSpansSampledEnabled() bool { | ||
return metricStatCountSpansSampledFeatureGate.IsEnabled() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
processor/tailsamplingprocessor/internal/telemetry/telemetry.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package telemetry // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor/internal/telemetry" | ||
|
||
import ( | ||
"context" | ||
"sync" | ||
|
||
"go.opencensus.io/stats/view" | ||
"go.opentelemetry.io/collector/config/configtelemetry" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor/internal/sampling" | ||
) | ||
|
||
var onceTelemetry sync.Once | ||
|
||
type T struct { | ||
ContextForPolicy func(ctx context.Context, configName, format string) (context.Context, error) | ||
RecordPolicyLatency func(ctx context.Context, latencyMicroSec int64) | ||
RecordPolicyDecision func(ctx context.Context, sampled bool, numSpans int64) | ||
RecordNewTraceIDs func(ctx context.Context, count int64) | ||
RecordLateSpan func(ctx context.Context, ageSec int64) | ||
RecordTraceRemovalAge func(ctx context.Context, ageSec int64) | ||
RecordFinalDecision func(ctx context.Context, latencyMicroSec, droppedTooEarly, evaluationErrors, tracesOnMemory int64, decision sampling.Decision) | ||
} | ||
|
||
func New() *T { | ||
onceTelemetry.Do(func() { | ||
_ = view.Register(samplingProcessorMetricViews(configtelemetry.LevelNormal)...) | ||
}) | ||
|
||
return &T{ | ||
ContextForPolicy: contextForPolicyOC, | ||
RecordPolicyLatency: recordPolicyLatencyOC, | ||
RecordPolicyDecision: recordPolicyDecisionOC, | ||
RecordNewTraceIDs: recordNewTraceIDsOC, | ||
RecordLateSpan: recordLateSpanOC, | ||
RecordTraceRemovalAge: recordTraceRemovalAgeOC, | ||
RecordFinalDecision: recordFinalDecisionOC, | ||
} | ||
} |
Oops, something went wrong.