All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.opentelemetry.api.common.AttributeKey Maven / Gradle / Ivy

There is a newer version: 2.0.0.0-RC3
Show newest version
/*
 * Copyright The OpenTelemetry Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package io.opentelemetry.api.common;

import io.opentelemetry.api.internal.InternalAttributeKeyImpl;
import java.util.List;
import javax.annotation.concurrent.Immutable;

/**
 * This interface provides a handle for setting the values of {@link Attributes}. The type of value
 * that can be set with an implementation of this key is denoted by the type parameter.
 *
 * 

Implementations MUST be immutable, as these are used as the keys to Maps. * * @param The type of value that can be set with the key. */ @SuppressWarnings("rawtypes") @Immutable public interface AttributeKey { /** Returns the underlying String representation of the key. */ String getKey(); /** Returns the type of attribute for this key. Useful for building switch statements. */ AttributeType getType(); /** Returns a new AttributeKey for String valued attributes. */ static AttributeKey stringKey(String key) { return InternalAttributeKeyImpl.create(key, AttributeType.STRING); } /** Returns a new AttributeKey for Boolean valued attributes. */ static AttributeKey booleanKey(String key) { return InternalAttributeKeyImpl.create(key, AttributeType.BOOLEAN); } /** Returns a new AttributeKey for Long valued attributes. */ static AttributeKey longKey(String key) { return InternalAttributeKeyImpl.create(key, AttributeType.LONG); } /** Returns a new AttributeKey for Double valued attributes. */ static AttributeKey doubleKey(String key) { return InternalAttributeKeyImpl.create(key, AttributeType.DOUBLE); } /** Returns a new AttributeKey for List<String> valued attributes. */ static AttributeKey> stringArrayKey(String key) { return InternalAttributeKeyImpl.create(key, AttributeType.STRING_ARRAY); } /** Returns a new AttributeKey for List<Boolean> valued attributes. */ static AttributeKey> booleanArrayKey(String key) { return InternalAttributeKeyImpl.create(key, AttributeType.BOOLEAN_ARRAY); } /** Returns a new AttributeKey for List<Long> valued attributes. */ static AttributeKey> longArrayKey(String key) { return InternalAttributeKeyImpl.create(key, AttributeType.LONG_ARRAY); } /** Returns a new AttributeKey for List<Double> valued attributes. */ static AttributeKey> doubleArrayKey(String key) { return InternalAttributeKeyImpl.create(key, AttributeType.DOUBLE_ARRAY); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy