-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POC Global Attributes implementation #1181
base: feature/next-gen
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look
val attributes: List<Attribute> get() = _attributes // Expose as immutable list | ||
|
||
// this method definitely can be streamlined | ||
operator fun set(key: Any, value: Any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, it would be better to write a function for each type. These "Any functions" are often leads into issues.
operator fun set(key: String, value: String) {
remove(key)
_attributes += Attribute.String(key, value)
}
} | ||
|
||
fun remove(key: String) { | ||
_attributes.removeAll { it.name == key } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There will be always at most one element with the key
.
for (i in _attributes.indices)
if (_attributes[i].name == key) {
_attributes.removeAt(i)
break
}
|
||
override fun onStart(parentContext: Context, span: ReadWriteSpan) { | ||
// Fetch the current attributes from GlobalAttributes and apply them to the span | ||
GlobalAttributes.instance.attributes.forEach { attribute -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use forEachFast
import io.opentelemetry.sdk.trace.ReadableSpan | ||
import io.opentelemetry.sdk.trace.SpanProcessor | ||
|
||
class GlobalAttributeSpanProcessor2 : SpanProcessor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove GlobalAttributeSpanProcessor
if possible
Thanks for the comments @TomasChladekSL , This is just a rough proof of concept to ensure everybody is on board with the approach, and not the final implementation. But I'll be sure to incorporate those things in the actual PR |
POC Implementation of global attributes feature.