opentelemetry-java icon indicating copy to clipboard operation
opentelemetry-java copied to clipboard

More implementation for io.opentelemetry.api.common.AttributeKey

Open 123liuziming opened this issue 9 months ago • 2 comments

Currently, we have only one implementation io.opentelemetry.api.internal.InternalAttributeKeyImpl for io.opentelemetry.api.common.AttributeKey, and we may have more implementation for that, for example:

  1. Make the all attributes in io.opentelemetry.semconv.trace.attributes.SemanticAttributes SemanticAttributeImpl
public class SemanticAttributeImpl<T> implements AttributeKey<T> {}
  1. Make the SemanticAttributes that can be recored into metrics MetricsSemanticAttributes
public class MetricsSemanticAttributes<T> extends SemanticAttributeImpl {}
  1. Make the other attributes CustomAttributeImpl

If AttributeKey is classified, we can do a lot of performance optimisation. For example, we can filter out MetricsAttributes of SemanticAttributes by just calling xx.getclass().equals(MetricsAttributes) instead of traversing it.

123liuziming avatar Mar 05 '25 12:03 123liuziming

Is this an issue for the core SDK? Would anything need to change in the way we currently define the interface to make this possible? If not, please close this and open it in the semantic conventions repository. thanks!

jkwatson avatar Mar 06 '25 15:03 jkwatson

we discussed this in the APAC SIG meeting this yesterday and I think @123liuziming is going to explore a different option for optimizations he is looking at, will wait for him to update here though

trask avatar Mar 06 '25 16:03 trask