diff --git a/processor/probabilisticsamplerprocessor/README.md b/processor/probabilisticsamplerprocessor/README.md index 0e124bcddb0c..9040283a09f6 100644 --- a/processor/probabilisticsamplerprocessor/README.md +++ b/processor/probabilisticsamplerprocessor/README.md @@ -1,11 +1,20 @@ # Probabilistic Sampling Processor -| Status | | -| ------------------------ | ----------------------------------------------- | -| Stability | traces [beta] | -| | logs [alpha] | -| Supported pipeline types | traces, logs | -| Distributions | [core], [contrib], [observiq], [splunk], [sumo] | + +| Status | | +| ------------- |-----------| +| Stability | [alpha]: logs | +| | [beta]: traces | +| Distributions | [core], [contrib], [observiq], [splunk], [sumo] | + +[alpha]: https://github.com/open-telemetry/opentelemetry-collector#alpha +[beta]: https://github.com/open-telemetry/opentelemetry-collector#beta +[core]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol +[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib +[observiq]: https://github.com/observIQ/observiq-otel-collector +[splunk]: https://github.com/signalfx/splunk-otel-collector +[sumo]: https://github.com/SumoLogic/sumologic-otel-collector + The probabilistic sampler supports two types of sampling for traces: @@ -80,11 +89,3 @@ processors: Refer to [config.yaml](./testdata/config.yaml) for detailed examples on using the processor. - -[alpha]: https://github.com/open-telemetry/opentelemetry-collector#alpha -[beta]: https://github.com/open-telemetry/opentelemetry-collector#beta -[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib -[core]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol -[splunk]: https://github.com/signalfx/splunk-otel-collector -[observiq]: https://github.com/observIQ/observiq-otel-collector -[sumo]: https://github.com/SumoLogic/sumologic-otel-collector diff --git a/processor/probabilisticsamplerprocessor/config_test.go b/processor/probabilisticsamplerprocessor/config_test.go index 9680f0ba4cae..90711d343552 100644 --- a/processor/probabilisticsamplerprocessor/config_test.go +++ b/processor/probabilisticsamplerprocessor/config_test.go @@ -12,6 +12,8 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/confmap/confmaptest" "go.opentelemetry.io/collector/otelcol/otelcoltest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/processor/probabilisticsamplerprocessor/internal/metadata" ) func TestLoadConfig(t *testing.T) { @@ -21,7 +23,7 @@ func TestLoadConfig(t *testing.T) { expected component.Config }{ { - id: component.NewIDWithName(typeStr, ""), + id: component.NewIDWithName(metadata.Type, ""), expected: &Config{ SamplingPercentage: 15.3, HashSeed: 22, @@ -29,7 +31,7 @@ func TestLoadConfig(t *testing.T) { }, }, { - id: component.NewIDWithName(typeStr, "logs"), + id: component.NewIDWithName(metadata.Type, "logs"), expected: &Config{ SamplingPercentage: 15.3, HashSeed: 22, @@ -65,7 +67,7 @@ func TestLoadInvalidConfig(t *testing.T) { require.NoError(t, err) factory := NewFactory() - factories.Processors[typeStr] = factory + factories.Processors[metadata.Type] = factory _, err = otelcoltest.LoadConfigAndValidate(filepath.Join("testdata", "invalid.yaml"), factories) require.ErrorContains(t, err, "negative sampling rate: -15.30") diff --git a/processor/probabilisticsamplerprocessor/factory.go b/processor/probabilisticsamplerprocessor/factory.go index 74ab6bc9b952..6659aabd6dad 100644 --- a/processor/probabilisticsamplerprocessor/factory.go +++ b/processor/probabilisticsamplerprocessor/factory.go @@ -1,6 +1,8 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +//go:generate mdatagen metadata.yaml + package probabilisticsamplerprocessor // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/probabilisticsamplerprocessor" import ( @@ -12,13 +14,8 @@ import ( "go.opentelemetry.io/collector/config/configtelemetry" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/processor" -) -const ( - // The value of "type" trace-samplers in configuration. - typeStr = "probabilistic_sampler" - // The stability level of the processor. - stability = component.StabilityLevelBeta + "github.com/open-telemetry/opentelemetry-collector-contrib/processor/probabilisticsamplerprocessor/internal/metadata" ) var onceMetrics sync.Once @@ -31,10 +28,10 @@ func NewFactory() processor.Factory { }) return processor.NewFactory( - typeStr, + metadata.Type, createDefaultConfig, - processor.WithTraces(createTracesProcessor, stability), - processor.WithLogs(createLogsProcessor, component.StabilityLevelAlpha)) + processor.WithTraces(createTracesProcessor, metadata.TracesStability), + processor.WithLogs(createLogsProcessor, metadata.LogsStability)) } func createDefaultConfig() component.Config { diff --git a/processor/probabilisticsamplerprocessor/internal/metadata/generated_status.go b/processor/probabilisticsamplerprocessor/internal/metadata/generated_status.go new file mode 100644 index 000000000000..ce209dc8878e --- /dev/null +++ b/processor/probabilisticsamplerprocessor/internal/metadata/generated_status.go @@ -0,0 +1,13 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package metadata + +import ( + "go.opentelemetry.io/collector/component" +) + +const ( + Type = "probabilistic_sampler" + LogsStability = component.StabilityLevelAlpha + TracesStability = component.StabilityLevelBeta +) diff --git a/processor/probabilisticsamplerprocessor/metadata.yaml b/processor/probabilisticsamplerprocessor/metadata.yaml new file mode 100644 index 000000000000..8485d194bcd2 --- /dev/null +++ b/processor/probabilisticsamplerprocessor/metadata.yaml @@ -0,0 +1,8 @@ +type: probabilistic_sampler + +status: + class: processor + stability: + beta: [traces] + alpha: [logs] + distributions: [core, contrib, observiq, splunk, sumo] diff --git a/processor/probabilisticsamplerprocessor/metrics.go b/processor/probabilisticsamplerprocessor/metrics.go index be5a75b3cc76..3d89b74d662a 100644 --- a/processor/probabilisticsamplerprocessor/metrics.go +++ b/processor/probabilisticsamplerprocessor/metrics.go @@ -9,6 +9,8 @@ import ( "go.opencensus.io/tag" "go.opentelemetry.io/collector/config/configtelemetry" "go.opentelemetry.io/collector/obsreport" + + "github.com/open-telemetry/opentelemetry-collector-contrib/processor/probabilisticsamplerprocessor/internal/metadata" ) // Variables related to metrics specific to tail sampling. @@ -28,14 +30,14 @@ func SamplingProcessorMetricViews(level configtelemetry.Level) []*view.View { sampledTagKeys := []tag.Key{tagPolicyKey, tagSampledKey} countTracesSampledView := &view.View{ - Name: obsreport.BuildProcessorCustomMetricName(typeStr, statCountTracesSampled.Name()), + Name: obsreport.BuildProcessorCustomMetricName(metadata.Type, statCountTracesSampled.Name()), Measure: statCountTracesSampled, Description: statCountTracesSampled.Description(), TagKeys: sampledTagKeys, Aggregation: view.Sum(), } countLogsSampledView := &view.View{ - Name: obsreport.BuildProcessorCustomMetricName(typeStr, statCountLogsSampled.Name()), + Name: obsreport.BuildProcessorCustomMetricName(metadata.Type, statCountLogsSampled.Name()), Measure: statCountLogsSampled, Description: statCountLogsSampled.Description(), TagKeys: sampledTagKeys,