2020-03-23 22:41:10 -07:00
|
|
|
// Copyright The OpenTelemetry Authors
|
2019-08-22 09:57:27 -07: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 (
|
2019-11-01 11:40:29 -07:00
|
|
|
"go.opentelemetry.io/otel/api/core"
|
2019-08-22 09:57:27 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2020-03-13 19:17:52 +00:00
|
|
|
alwaysOffSamplerDescription = "AlwaysOffSampler"
|
2019-08-22 09:57:27 -07:00
|
|
|
)
|
|
|
|
|
2020-03-13 19:17:52 +00:00
|
|
|
var alwaysOffSamplerDecision = Decision{Sampled: false}
|
2019-08-22 09:57:27 -07:00
|
|
|
|
2020-03-13 19:17:52 +00:00
|
|
|
type alwaysOffSampler struct{}
|
2019-08-22 09:57:27 -07: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 19:17:52 +00:00
|
|
|
func (ns alwaysOffSampler) ShouldSample(
|
2020-05-02 20:17:11 +08:00
|
|
|
_ SpanContext,
|
2019-08-22 09:57:27 -07:00
|
|
|
_ bool,
|
2020-05-02 20:17:11 +08:00
|
|
|
_ TraceID,
|
|
|
|
_ SpanID,
|
2019-08-22 09:57:27 -07:00
|
|
|
_ string,
|
2020-03-10 11:25:11 -04:00
|
|
|
_ SpanKind,
|
|
|
|
_ []core.KeyValue,
|
|
|
|
_ []Link,
|
2019-08-22 09:57:27 -07:00
|
|
|
) Decision {
|
2020-03-13 19:17:52 +00:00
|
|
|
return alwaysOffSamplerDecision
|
2019-08-22 09:57:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Description implements Sampler interface.
|
|
|
|
// It returns the description of this sampler.
|
2020-03-13 19:17:52 +00:00
|
|
|
func (ns alwaysOffSampler) Description() string {
|
|
|
|
return alwaysOffSamplerDescription
|
2019-08-22 09:57:27 -07:00
|
|
|
}
|
|
|
|
|
2020-03-13 19:17:52 +00:00
|
|
|
var _ Sampler = alwaysOffSampler{}
|
2019-08-22 09:57:27 -07:00
|
|
|
|
2020-03-13 19:17:52 +00:00
|
|
|
func AlwaysOffSampler() Sampler {
|
|
|
|
return alwaysOffSampler{}
|
2019-08-22 09:57:27 -07:00
|
|
|
}
|