Skip to content
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

Move SpanRunner outside SpanBuilderImpl #122

Merged
merged 3 commits into from
Feb 12, 2023

Conversation

iRevive
Copy link
Contributor

@iRevive iRevive commented Feb 8, 2023

While cleaning up the internal implementation, I spotted a few inconsistencies regarding start/end time selections.

Before (main branch):

start_timestamp end_timestamp
ops.use. builder has start time builder_start Clock[F].realTime
ops.use Clock[F].realTime Clock[F].realTime
ops.startUnmanaged. builder has start time builder_start j_span.end
ops.startUnmanaged j_span.start j_span.end

After (this branch):

start_timestamp end_timestamp
ops.use. builder has start time builder_start Clock[F].realTime
ops.use Clock[F].realTime Clock[F].realTime
ops.startUnmanaged. builder has start time builder_start Clock[F].realTime
ops.startUnmanaged Clock[F].realTime Clock[F].realTime

We can also introduce TimestampStrategy to allow choosing between Clock[F].realTime and j_span.start / j_span.end.
It feels like overkill, but it may be helpful in applications when otel4s and some Java libs use the same OpenTelementry SDK.

@iRevive iRevive added the tracing Improvements to tracing module label Feb 8, 2023
@iRevive iRevive requested a review from a team February 8, 2023 12:44
@@ -89,7 +90,7 @@ private[java] class SpanBackendImpl[F[_]: Sync](
}

private[otel4s] def end: F[Unit] =
Sync[F].delay(jSpan.end())
Sync[F].realTime.flatMap(now => end(now))
Copy link
Contributor Author

@iRevive iRevive Feb 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, only startUnmanaged is affected. For resource-like API, we were injecting the realtime under the hood. E.g.
https://github.com/typelevel/otel4s/pull/122/files#diff-988bfe14df2f23c008240b2752bde4a711b0c4fa716b62f5416f1de82582bc55L330-L333

Copy link
Member

@rossabaker rossabaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

I'd rather avoid TimestampStrategy until we have a compelling real-world case, but good to keep in mind ... and figure out before 1.0.

*
* @see
* See [[use]] for more details regarding lifecycle strategy
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thank you for adding these, too!

Comment on lines +185 to +203
mimaBinaryIssueFilters ++= Seq(
ProblemFilters.exclude[MissingClassProblem](
"org.typelevel.otel4s.java.trace.SpanBuilderImpl$Runner"
),
ProblemFilters.exclude[MissingClassProblem](
"org.typelevel.otel4s.java.trace.SpanBuilderImpl$Runner$"
),
ProblemFilters.exclude[MissingClassProblem](
"org.typelevel.otel4s.java.trace.SpanBuilderImpl$TimestampSelect"
),
ProblemFilters.exclude[MissingClassProblem](
"org.typelevel.otel4s.java.trace.SpanBuilderImpl$TimestampSelect$"
),
ProblemFilters.exclude[MissingClassProblem](
"org.typelevel.otel4s.java.trace.SpanBuilderImpl$TimestampSelect$Delegate$"
),
ProblemFilters.exclude[MissingClassProblem](
"org.typelevel.otel4s.java.trace.SpanBuilderImpl$TimestampSelect$Explicit$"
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of this code would be inlined by the macros, right? This just bit Circe on Scala 3...

I have a feeling our next release will be 0.2, but as long as we're not changing the public API, this is a noble effort.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, these classes shouldn't appear in the inline positions

@rossabaker
Copy link
Member

Is this our first PR in the MiMa world? I'm unsure what the Scala 3 build is cranky about there.

@iRevive
Copy link
Contributor Author

iRevive commented Feb 10, 2023

Yes, as far as I am aware, it's the first PR after the 0.1.0 release

@armanbilge
Copy link
Member

I believe you are running into this issue, because you are publishing "aggregate" modules which don't contain classfiles.

@rossabaker
Copy link
Member

We could unblock this by emptying the mimaPreviousArtifacts, as long as we remember to roll it back before either:

  1. anything gets added to that aggregate
  2. the above gets released

@armanbilge
Copy link
Member

  1. bumping the base version to 0.2 /shrug

@rossabaker
Copy link
Member

Yeah, the next release will contain new features, and nobody is using this in prod yet ... at least hopefully not for libraries! 0.2 is fine with me, too.

@iRevive
Copy link
Contributor Author

iRevive commented Feb 11, 2023

I should bump the base version to 0.2 in this PR, right?

@rossabaker
Copy link
Member

That only postpones the problem until after 0.2 is released, but I'm hopeful the problem will be gone by other means then, and it's a reasonable thing to do on its own. 👍

@iRevive iRevive merged commit 7bd1f95 into typelevel:main Feb 12, 2023
@iRevive iRevive deleted the span-runner-refactor branch February 12, 2023 08:53
chr12c pushed a commit to chr12c/otel4s that referenced this pull request Jun 26, 2023
Move `SpanRunner` outside  `SpanBuilderImpl`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tracing Improvements to tracing module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants