1 /* 2 * Copyright 2017, OpenCensus Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package io.opencensus.trace.samplers; 18 19 import io.opencensus.trace.Sampler; 20 import io.opencensus.trace.Span; 21 import io.opencensus.trace.SpanContext; 22 import io.opencensus.trace.SpanId; 23 import io.opencensus.trace.TraceId; 24 import java.util.List; 25 import javax.annotation.Nullable; 26 import javax.annotation.concurrent.Immutable; 27 28 /** Sampler that always makes a "no" decision on {@link Span} sampling. */ 29 @Immutable 30 final class NeverSampleSampler extends Sampler { 31 NeverSampleSampler()32 NeverSampleSampler() {} 33 34 // Returns always makes a "no" decision on {@link Span} sampling. 35 @Override shouldSample( @ullable SpanContext parentContext, @Nullable Boolean hasRemoteParent, TraceId traceId, SpanId spanId, String name, List<Span> parentLinks)36 public boolean shouldSample( 37 @Nullable SpanContext parentContext, 38 @Nullable Boolean hasRemoteParent, 39 TraceId traceId, 40 SpanId spanId, 41 String name, 42 List<Span> parentLinks) { 43 return false; 44 } 45 46 @Override getDescription()47 public String getDescription() { 48 return toString(); 49 } 50 51 @Override toString()52 public String toString() { 53 return "NeverSampleSampler"; 54 } 55 } 56