Closed ChristopherDavenport closed 4 months ago
Seems like that should be relaxed.
I'm wondering whether backend
on Span
should be protected instead. It could still be implemented by third parties, but I'm not clear what the use case for calling it directly from a Span
handle would be.
Unfortunately, backend
must be public because it is used by macro: https://github.com/typelevel/otel4s/blob/main/core/trace/src/main/scala-2/org/typelevel/otel4s/trace/SpanMacro.scala#L139.
The unwrapped code is:
if (span.backend.meta.isEnabled) span.backend.meta.addAttributes(..$attributes)
else span.backend.meta.unit
Ah, right.
I wish protected[foo]
meant accessible within foo
or subclasses of whatever defined it: leave things open to implementation and guard who else can call it.
Anyway, I think we may be stuck making these public.
In the initial draft, end
was private because I had two types of span: Auto
and Manual
. And Manual
span exposed end
method publicly. Since we no longer have this separation, I do not see any obstacles toward making end
in Backend
public.
I wish
protected[foo]
meant accessible withinfoo
or subclasses of whatever defined it
I have good news for you @rossabaker! as long as foo
isn't this
, it does!
scala> class Demo[A] extends collection.mutable.ArrayBuffer[A]() {
| def foo: Array[AnyRef] = array
| }
class Demo
scala> (new Demo[String]).foo
val res0: Array[AnyRef] = Array(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null)
In general, the set of scopes from which protected[X]
is accessible is the union of the scopes from which private[X]
and protected
are accessible, with the exception of protected[this]
, which is... the intersection of the scopes of this
and protected
? I'm not entirely sure how to define that with set theory
https://github.com/typelevel/otel4s/blob/main/core/trace/src/main/scala/org/typelevel/otel4s/trace/Span.scala#L151-L152
These two lines make implementing a
Backend
which is necessary for creating aSpan
impossible out of this package.Quick backdoor I am using as an interrim in case others need similar.