-
Notifications
You must be signed in to change notification settings - Fork 40
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
sdk-common: add InstrumentationScope
#354
sdk-common: add InstrumentationScope
#354
Conversation
InstrumentationScope
InstrumentationScope
* @see | ||
* [[https://opentelemetry.io/docs/specs/otel/glossary/#instrumentation-scope Instrumentation Scope spec]] | ||
*/ | ||
sealed trait InstrumentationScope { |
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.
I guess the Java SDK calls this InstrumentationScopeInfo
, any commentary?
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.
The specification doesn't require this particular name.
Java SDK uses InstrumentationScopeInfo
, Go stands with Scope, Python uses InstrumentationInfo and Rust uses InstrumentationLibrary.
From what I see, InstrumentationScope is sufficient enough and not verbose.
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.
Python uses InstrumentationInfo
Wait a minute: Python has both an InstrumentationInfo
and an InstrumentationScope
. What's the difference? 🤔
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.
Spec-wise, perhaps they refer to InstrumentationLibrary and InstrumentationScope?
In JavaScript, there are both InstrumentationLibrary and InstrumetnationScope. InstrumentationLibrary is deprecated, though.
private final case class ScopeImpl( | ||
name: String, | ||
version: Option[String], | ||
schemaUrl: Option[String], | ||
attributes: Attributes | ||
) extends InstrumentationScope | ||
|
||
private final case class BuilderImpl( | ||
name: String, | ||
version: Option[String], | ||
schemaUrl: Option[String], | ||
attributes: Attributes | ||
) extends Builder { |
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.
Actually these can be combined into a single class, then we save an allocation in the build
method.
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.
I don't see reasons why we shouldn't :)
* @param version | ||
* the version to set | ||
*/ | ||
def setVersion(version: String): Builder |
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.
I don't want to be bikeshedding too much, it's not a big deal. And I guess otel4s already has some established idioms. But typically I associate set
with mutability and e.g. withVersion
would be more appropriate for an immutable builder like this one.
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.
Valid point. We primarily use with*
across the otel4s codebase.
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.
I've updated the code
should this be in bikeshedding that more: currently it only supports replacing the attributes. should we support adding additional attributes as well? instead? we could have |
I don't think so. For example, tracer builder public API does not require
Definitely. I forgot to rename it.
I didn't find such a use case (at least yet). Since it is supposed to be used by internals, we can always add it in the future. |
10eb7fe
to
b842e24
Compare
https://opentelemetry.io/docs/specs/otel/trace/api/#get-a-tracer
I started decoupling #325 into smaller changes to simplify the review process.