/* * Copyright 2016-17, OpenCensus Authors * * 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 io.opencensus.trace; import io.opencensus.internal.Utils; import java.util.Map; import javax.annotation.concurrent.Immutable; /** * The {@code BlankSpan} is a singleton class, which is the default {@link Span} that is used when * no {@code Span} implementation is available. All operations are no-op. * *
Used also to stop tracing, see {@link Tracer#withSpan}.
*
* @since 0.5
*/
@Immutable
public final class BlankSpan extends Span {
/**
* Singleton instance of this class.
*
* @since 0.5
*/
public static final BlankSpan INSTANCE = new BlankSpan();
private BlankSpan() {
super(SpanContext.INVALID, null);
}
/** No-op implementation of the {@link Span#putAttribute(String, AttributeValue)} method. */
@Override
public void putAttribute(String key, AttributeValue value) {
Utils.checkNotNull(key, "key");
Utils.checkNotNull(value, "value");
}
/** No-op implementation of the {@link Span#putAttributes(Map)} method. */
@Override
public void putAttributes(Map