Remove components from tags. (#117)
This commit is contained in:
parent
cbe4187f84
commit
05bc59a273
|
|
@ -19,7 +19,6 @@ package openconsensus.tags;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import javax.annotation.concurrent.ThreadSafe;
|
||||
import openconsensus.context.NoopScope;
|
||||
import openconsensus.context.Scope;
|
||||
import openconsensus.internal.Utils;
|
||||
|
|
@ -27,7 +26,6 @@ import openconsensus.tags.data.TagKey;
|
|||
import openconsensus.tags.data.TagMetadata;
|
||||
import openconsensus.tags.data.TagValue;
|
||||
import openconsensus.tags.propagation.BinaryFormat;
|
||||
import openconsensus.tags.propagation.PropagationComponent;
|
||||
import openconsensus.tags.propagation.TextFormat;
|
||||
|
||||
/** No-op implementations of tagging classes. */
|
||||
|
|
@ -36,33 +34,18 @@ final class NoopTags {
|
|||
private NoopTags() {}
|
||||
|
||||
/**
|
||||
* Returns a {@code TagsComponent} that has a no-op implementation for {@link Tagger}.
|
||||
* Returns a {@code Tagger} that is a no-op implementation for {@link Tagger}.
|
||||
*
|
||||
* @return a {@code TagsComponent} that has a no-op implementation for {@code Tagger}.
|
||||
* @return a {@code Tagger} that is a no-op implementation for {@link Tagger}.
|
||||
*/
|
||||
static TagsComponent newNoopTagsComponent() {
|
||||
return new NoopTagsComponent();
|
||||
}
|
||||
|
||||
@ThreadSafe
|
||||
private static final class NoopTagsComponent extends TagsComponent {
|
||||
private static final PropagationComponent PROPAGATION_COMPONENT =
|
||||
new NoopPropagationComponent();
|
||||
private static final Tagger TAGGER = new NoopTagger();
|
||||
|
||||
@Override
|
||||
public Tagger getTagger() {
|
||||
return TAGGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropagationComponent getTagPropagationComponent() {
|
||||
return PROPAGATION_COMPONENT;
|
||||
}
|
||||
static Tagger newNoopTagger() {
|
||||
return new NoopTagger();
|
||||
}
|
||||
|
||||
@Immutable
|
||||
private static final class NoopTagger extends Tagger {
|
||||
private static final BinaryFormat BINARY_FORMAT = new NoopBinaryFormat();
|
||||
private static final TextFormat TEXT_FORMAT = new NoopTextFormat();
|
||||
private static final TagMap EMPTY = new NoopTagMap();
|
||||
|
||||
@Override
|
||||
|
|
@ -96,6 +79,16 @@ final class NoopTags {
|
|||
Utils.checkNotNull(tags, "tags");
|
||||
return NoopScope.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BinaryFormat getBinaryFormat() {
|
||||
return BINARY_FORMAT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextFormat getTextFormat() {
|
||||
return TEXT_FORMAT;
|
||||
}
|
||||
}
|
||||
|
||||
@Immutable
|
||||
|
|
@ -130,22 +123,6 @@ final class NoopTags {
|
|||
@Immutable
|
||||
private static final class NoopTagMap extends TagMap {}
|
||||
|
||||
@Immutable
|
||||
private static final class NoopPropagationComponent extends PropagationComponent {
|
||||
private static final BinaryFormat BINARY_FORMAT = new NoopBinaryFormat();
|
||||
private static final TextFormat TEXT_FORMAT = new NoopTextFormat();
|
||||
|
||||
@Override
|
||||
public BinaryFormat getBinaryFormat() {
|
||||
return BINARY_FORMAT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextFormat getTextFormat() {
|
||||
return TEXT_FORMAT;
|
||||
}
|
||||
}
|
||||
|
||||
@Immutable
|
||||
private static final class NoopBinaryFormat extends BinaryFormat {
|
||||
private static final TagMap EMPTY = new NoopTagMap();
|
||||
|
|
@ -170,7 +147,7 @@ final class NoopTags {
|
|||
|
||||
@Override
|
||||
public List<String> fields() {
|
||||
return Collections.<String>emptyList();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
package openconsensus.tags;
|
||||
|
||||
import openconsensus.context.Scope;
|
||||
import openconsensus.tags.propagation.BinaryFormat;
|
||||
import openconsensus.tags.propagation.TextFormat;
|
||||
|
||||
/**
|
||||
* Object for creating new {@link TagMap}s and {@code TagMap}s based on the current context.
|
||||
|
|
@ -84,4 +86,23 @@ public abstract class Tagger {
|
|||
* @since 0.1.0
|
||||
*/
|
||||
public abstract Scope withTagMap(TagMap tags);
|
||||
|
||||
/**
|
||||
* Returns the {@link BinaryFormat} for this implementation.
|
||||
*
|
||||
* @return the {@code BinaryFormat} for this implementation.
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public abstract BinaryFormat getBinaryFormat();
|
||||
|
||||
/**
|
||||
* Returns the {@link TextFormat} for this implementation.
|
||||
*
|
||||
* <p>Usually this will be the W3C Correlation Context as the HTTP text format. For more details,
|
||||
* see <a href="https://github.com/w3c/correlation-context">correlation-context</a>.
|
||||
*
|
||||
* @return the {@code TextFormat} for this implementation.
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public abstract TextFormat getTextFormat();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,15 +16,13 @@
|
|||
|
||||
package openconsensus.tags;
|
||||
|
||||
import openconsensus.tags.propagation.PropagationComponent;
|
||||
|
||||
/**
|
||||
* Class for accessing the default {@link TagsComponent}.
|
||||
* Class to access the global {@link Tagger}.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public final class Tags {
|
||||
private static final TagsComponent tagsComponent = NoopTags.newNoopTagsComponent();
|
||||
private static final Tagger TAGGER = NoopTags.newNoopTagger();
|
||||
|
||||
private Tags() {}
|
||||
|
||||
|
|
@ -35,16 +33,6 @@ public final class Tags {
|
|||
* @since 0.1.0
|
||||
*/
|
||||
public static Tagger getTagger() {
|
||||
return tagsComponent.getTagger();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default {@code PropagationComponent}.
|
||||
*
|
||||
* @return the default {@code PropagationComponent}.
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public static PropagationComponent getTagPropagationComponent() {
|
||||
return tagsComponent.getTagPropagationComponent();
|
||||
return TAGGER;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Copyright 2019, OpenConsensus 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 openconsensus.tags;
|
||||
|
||||
import openconsensus.tags.propagation.PropagationComponent;
|
||||
|
||||
/**
|
||||
* Class that holds the implementation for {@link Tagger} and {@link PropagationComponent}.
|
||||
*
|
||||
* <p>All objects returned by methods on {@code TagsComponent} are cacheable.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public abstract class TagsComponent {
|
||||
|
||||
/**
|
||||
* Returns the {@link Tagger} for this implementation.
|
||||
*
|
||||
* @return the {@link Tagger} for this implementation.
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public abstract Tagger getTagger();
|
||||
|
||||
/**
|
||||
* Returns the {@link PropagationComponent} for this implementation.
|
||||
*
|
||||
* @return the {@link PropagationComponent} for this implementation.
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public abstract PropagationComponent getTagPropagationComponent();
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* Copyright 2019, OpenConsensus 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 openconsensus.tags.propagation;
|
||||
|
||||
import openconsensus.tags.TagMap;
|
||||
|
||||
/**
|
||||
* Object containing all supported {@link TagMap} propagation formats.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public abstract class PropagationComponent {
|
||||
|
||||
/**
|
||||
* Returns the {@link BinaryFormat} for this implementation.
|
||||
*
|
||||
* @return the {@code BinaryFormat} for this implementation.
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public abstract BinaryFormat getBinaryFormat();
|
||||
|
||||
/**
|
||||
* Returns the {@link TextFormat} for this implementation.
|
||||
*
|
||||
* <p>Usually this will be the W3C Correlation Context as the HTTP text format. For more details,
|
||||
* see <a href="https://github.com/w3c/correlation-context">correlation-context</a>.
|
||||
*
|
||||
* @return the {@code TextFormat} for this implementation.
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public abstract TextFormat getTextFormat();
|
||||
}
|
||||
Loading…
Reference in New Issue