2020-03-24 07:41:10 +02:00
|
|
|
// Copyright The OpenTelemetry Authors
|
2019-08-22 18:57:27 +02:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package trace
|
|
|
|
|
|
|
|
import (
|
2020-05-14 01:06:03 +02:00
|
|
|
"go.opentelemetry.io/otel/api/kv"
|
2019-08-22 18:57:27 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2020-03-13 21:17:52 +02:00
|
|
|
alwaysOffSamplerDescription = "AlwaysOffSampler"
|
2019-08-22 18:57:27 +02:00
|
|
|
)
|
|
|
|
|
2020-03-13 21:17:52 +02:00
|
|
|
var alwaysOffSamplerDecision = Decision{Sampled: false}
|
2019-08-22 18:57:27 +02:00
|
|
|
|
2020-03-13 21:17:52 +02:00
|
|
|
type alwaysOffSampler struct{}
|
2019-08-22 18:57:27 +02:00
|
|
|
|
|
|
|
// ShouldSample implements Sampler interface.
|
|
|
|
// It always returns a Decision with Sampled value set to false
|
|
|
|
// and with Attributes set to an empty slice.
|
2020-03-13 21:17:52 +02:00
|
|
|
func (ns alwaysOffSampler) ShouldSample(
|
2020-05-02 14:17:11 +02:00
|
|
|
_ SpanContext,
|
2019-08-22 18:57:27 +02:00
|
|
|
_ bool,
|
2020-05-02 14:23:09 +02:00
|
|
|
_ ID,
|
2020-05-02 14:17:11 +02:00
|
|
|
_ SpanID,
|
2019-08-22 18:57:27 +02:00
|
|
|
_ string,
|
2020-03-10 17:25:11 +02:00
|
|
|
_ SpanKind,
|
2020-05-14 01:06:03 +02:00
|
|
|
_ []kv.KeyValue,
|
2020-03-10 17:25:11 +02:00
|
|
|
_ []Link,
|
2019-08-22 18:57:27 +02:00
|
|
|
) Decision {
|
2020-03-13 21:17:52 +02:00
|
|
|
return alwaysOffSamplerDecision
|
2019-08-22 18:57:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Description implements Sampler interface.
|
|
|
|
// It returns the description of this sampler.
|
2020-03-13 21:17:52 +02:00
|
|
|
func (ns alwaysOffSampler) Description() string {
|
|
|
|
return alwaysOffSamplerDescription
|
2019-08-22 18:57:27 +02:00
|
|
|
}
|
|
|
|
|
2020-03-13 21:17:52 +02:00
|
|
|
var _ Sampler = alwaysOffSampler{}
|
2019-08-22 18:57:27 +02:00
|
|
|
|
2020-03-13 21:17:52 +02:00
|
|
|
func AlwaysOffSampler() Sampler {
|
|
|
|
return alwaysOffSampler{}
|
2019-08-22 18:57:27 +02:00
|
|
|
}
|