1 /* 2 * Copyright 2018, 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.implcore.trace; 18 19 import com.google.common.base.Preconditions; 20 import io.opencensus.trace.Annotation; 21 import io.opencensus.trace.AttributeValue; 22 import io.opencensus.trace.EndSpanOptions; 23 import io.opencensus.trace.Link; 24 import io.opencensus.trace.Span; 25 import io.opencensus.trace.SpanContext; 26 import io.opencensus.trace.Status; 27 import java.util.EnumSet; 28 import java.util.Map; 29 30 /** Implementation for the {@link Span} class that does not record trace events. */ 31 final class NoRecordEventsSpanImpl extends Span { 32 33 private static final EnumSet<Options> NOT_RECORD_EVENTS_SPAN_OPTIONS = 34 EnumSet.noneOf(Span.Options.class); 35 36 static NoRecordEventsSpanImpl create(SpanContext context) { 37 return new NoRecordEventsSpanImpl(context); 38 } 39 40 @Override 41 public void addAnnotation(String description, Map<String, AttributeValue> attributes) { 42 Preconditions.checkNotNull(description, "description"); 43 Preconditions.checkNotNull(attributes, "attribute"); 44 } 45 46 @Override 47 public void addAnnotation(Annotation annotation) { 48 Preconditions.checkNotNull(annotation, "annotation"); 49 } 50 51 @Override 52 public void putAttribute(String key, AttributeValue value) { 53 Preconditions.checkNotNull(key, "key"); 54 Preconditions.checkNotNull(value, "value"); 55 } 56 57 @Override 58 public void putAttributes(Map<String, AttributeValue> attributes) { 59 Preconditions.checkNotNull(attributes, "attributes"); 60 } 61 62 @Override 63 public void addMessageEvent(io.opencensus.trace.MessageEvent messageEvent) { 64 Preconditions.checkNotNull(messageEvent, "messageEvent"); 65 } 66 67 @Override 68 public void addLink(Link link) { 69 Preconditions.checkNotNull(link, "link"); 70 } 71 72 @Override 73 public void setStatus(Status status) { 74 Preconditions.checkNotNull(status, "status"); 75 } 76 77 @Override 78 public void end(EndSpanOptions options) { 79 Preconditions.checkNotNull(options, "options"); 80 } 81 82 private NoRecordEventsSpanImpl(SpanContext context) { 83 super(context, NOT_RECORD_EVENTS_SPAN_OPTIONS); 84 } 85 } 86