Skip to content

Commit 92e18bf

Browse files
authored
Merge pull request #1037 from iRevive/feature/seal-public-traits
2 parents b878abd + d42df76 commit 92e18bf

File tree

185 files changed

+693
-549
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+693
-549
lines changed

benchmarks/src/main/scala/org/typelevel/otel4s/benchmarks/BatchSpanProcessorBenchmark.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ object BatchSpanProcessorBenchmark {
155155
import org.typelevel.otel4s.sdk.trace.exporter.SpanExporter
156156
import org.typelevel.otel4s.sdk.trace.processor.BatchSpanProcessor
157157

158-
val exporter: SpanExporter[IO] = new SpanExporter[IO] {
158+
val exporter: SpanExporter[IO] = new SpanExporter.Unsealed[IO] {
159159
def name: String = s"DelayExporter($delay)"
160160
def exportSpans[G[_]: Foldable](spans: G[SpanData]): IO[Unit] = IO.sleep(delay)
161161
def flush: IO[Unit] = IO.unit

benchmarks/src/main/scala/org/typelevel/otel4s/benchmarks/MultiSpanProcessorBenchmark.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ object MultiSpanProcessorBenchmark {
109109
import org.typelevel.otel4s.sdk.trace.data.{SpanData, StatusData}
110110
import org.typelevel.otel4s.sdk.trace.processor.SpanProcessor
111111

112-
val processor: SpanProcessor[IO] = new SpanProcessor[IO] {
112+
val processor: SpanProcessor[IO] = new SpanProcessor.Unsealed[IO] {
113113
def name: String = "Noop"
114-
val onStart: SpanProcessor.OnStart[IO] = (_, _) => IO.unit
115-
val onEnd: SpanProcessor.OnEnd[IO] = _ => IO.unit
114+
val onStart: SpanProcessor.OnStart[IO] = SpanProcessor.OnStart((_, _) => IO.unit)
115+
val onEnd: SpanProcessor.OnEnd[IO] = SpanProcessor.OnEnd(_ => IO.unit)
116116
def forceFlush: IO[Unit] = IO.unit
117117
}
118118

buildscripts/semantic-convention/templates/registry/otel4s/metrics/SemanticMetrics.scala.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ object {{ object_name }} {
166166
{%- elif params.stable_only == false and metric is stable %}
167167
@deprecated("Use stable `{{ stableRef(metric) }}` instead.", "")
168168
{%- endif %}
169-
object {{ objectName(metric) }} extends MetricSpec {
169+
object {{ objectName(metric) }} extends MetricSpec.Unsealed {
170170
{%- if params.stable_only == false -%}
171171
{%- set metric_attributes = metric.attributes %}
172172
{% else %}

core/all/src/main/scala/org/typelevel/otel4s/Otel4s.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import org.typelevel.otel4s.context.propagation.ContextPropagators
2222
import org.typelevel.otel4s.metrics.MeterProvider
2323
import org.typelevel.otel4s.trace.TracerProvider
2424

25-
trait Otel4s[F[_]] {
25+
sealed trait Otel4s[F[_]] {
2626

2727
/** The type of context used by telemetry components. */
2828
type Ctx
@@ -42,3 +42,7 @@ trait Otel4s[F[_]] {
4242
/** A utility for accessing and modifying [[baggage.Baggage `Baggage`]]. */
4343
def baggageManager: BaggageManager[F]
4444
}
45+
46+
object Otel4s {
47+
private[otel4s] trait Unsealed[F[_]] extends Otel4s[F]
48+
}

core/common/src/main/scala/org/typelevel/otel4s/baggage/BaggageManager.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import cats.mtl.Local
3434
* BaggageManager[F].modifiedScope(_.updated("user_id", "uid"))(io)
3535
* }}}
3636
*/
37-
trait BaggageManager[F[_]] {
37+
sealed trait BaggageManager[F[_]] {
3838

3939
// TODO: remove after finishing migrating away from Local
4040
protected def applicative: Applicative[F]
@@ -73,6 +73,8 @@ trait BaggageManager[F[_]] {
7373
}
7474

7575
object BaggageManager {
76+
private[otel4s] trait Unsealed[F[_]] extends BaggageManager[F]
77+
7678
def apply[F[_]](implicit ev: BaggageManager[F]): BaggageManager[F] = ev
7779

7880
@deprecated("BaggageManager no longer extends Local", since = "otel4s 0.13.0")

core/common/src/main/scala/org/typelevel/otel4s/context/Contextual.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package org.typelevel.otel4s
1818
package context
1919

20-
trait Contextual[C] { outer =>
20+
sealed trait Contextual[C] { outer =>
2121

2222
/** The type of [[context.Key `Key`]] used by contexts of type `C`. */
2323
type Key[A] <: context.Key[A]
@@ -60,6 +60,7 @@ trait Contextual[C] { outer =>
6060
}
6161

6262
object Contextual {
63+
private[otel4s] trait Unsealed[C] extends Contextual[C]
6364

6465
/** A type alias for a [[`Contextual`]] explicitly parameterized by its [[Contextual.Key `Key`]] type.
6566
*/

core/common/src/main/scala/org/typelevel/otel4s/context/Key.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import cats.Show
2424
* @note
2525
* Implementations MUST treat different instances as non-equal.
2626
*/
27-
trait Key[A] {
27+
sealed trait Key[A] {
2828

2929
/** The debug name of the key. */
3030
val name: String
@@ -33,19 +33,21 @@ trait Key[A] {
3333
}
3434

3535
object Key {
36+
private[otel4s] trait Unsealed[A] extends Key[A]
3637

3738
/** Something that provides context keys.
3839
*
3940
* @tparam K
4041
* the type of keys
4142
*/
42-
trait Provider[F[_], K[X] <: Key[X]] {
43+
sealed trait Provider[F[_], K[X] <: Key[X]] {
4344

4445
/** Creates a unique key with the given (debug) name. */
4546
def uniqueKey[A](name: String): F[K[A]]
4647
}
4748

4849
object Provider {
50+
private[otel4s] trait Unsealed[F[_], K[X] <: Key[X]] extends Provider[F, K]
4951

5052
/** Summons a [[`Provider`]] that is available implicitly. */
5153
def apply[F[_], K[X] <: Key[X]](implicit

core/common/src/main/scala/org/typelevel/otel4s/context/LocalProvider.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@ val provider = LocalProvider[${F}, ${Ctx}]
4949
5050
val provider = LocalProvider[IO, ${Ctx}]
5151
""")
52-
trait LocalProvider[F[_], Ctx] {
52+
sealed trait LocalProvider[F[_], Ctx] {
5353

5454
/** Creates a [[cats.mtl.Local Local]] instance. The method is invoked once per creation of the Otel4s instance.
5555
*/
5656
def local: F[Local[F, Ctx]]
5757
}
5858

5959
object LocalProvider extends LocalProviderLowPriority {
60+
private[otel4s] trait Unsealed[F[_], Ctx] extends LocalProvider[F, Ctx]
6061

6162
def apply[F[_], C](implicit ev: LocalProvider[F, C]): LocalProvider[F, C] = ev
6263

core/common/src/main/scala/org/typelevel/otel4s/context/propagation/PassThroughPropagator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import org.typelevel.otel4s.context.syntax._
2323
/** A [[TextMapPropagator]] that extracts a specified collection of fields and stores them in a context, and extracts
2424
* them from a context later for injection. It does not interact with telemetry.
2525
*/
26-
final class PassThroughPropagator[Ctx, K[X] <: Key[X]] private (
26+
private final class PassThroughPropagator[Ctx, K[X] <: Key[X]] private (
2727
val fields: Iterable[String],
2828
entriesKey: K[List[(String, String)]]
2929
)(implicit c: Contextual.Keyed[Ctx, K])

core/common/src/test/scala/org/typelevel/otel4s/context/vault/VaultContext.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ object VaultContext {
5151
final class Key[A] private (
5252
val name: String,
5353
private[VaultContext] val underlying: VaultKey[A]
54-
) extends context.Key[A]
54+
) extends context.Key.Unsealed[A]
5555

5656
object Key {
5757

@@ -60,15 +60,15 @@ object VaultContext {
6060
VaultKey.newKey[F, A].map(new Key[A](name, _))
6161

6262
implicit def provider[F[_]: Functor: Unique]: context.Key.Provider[F, Key] =
63-
new context.Key.Provider[F, Key] {
63+
new context.Key.Provider.Unsealed[F, Key] {
6464
def uniqueKey[A](name: String): F[Key[A]] = unique(name)
6565
}
6666
}
6767

6868
/** The root [[`VaultContext`]], from which all other contexts are derived. */
6969
val root: VaultContext = new VaultContext(Vault.empty)
7070

71-
implicit object Contextual extends context.Contextual[VaultContext] {
71+
implicit object Contextual extends context.Contextual.Unsealed[VaultContext] {
7272
type Key[A] = VaultContext.Key[A]
7373

7474
def get[A](ctx: VaultContext)(key: Key[A]): Option[A] =

0 commit comments

Comments
 (0)