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

Support using Scala propagators with Java backend #365

Merged
merged 4 commits into from
Dec 20, 2023

Conversation

NthPortal
Copy link
Contributor

Add conversions from Scala to Java propagators so that the Scala instances can be passed to builders of Java OpenTelemetry instances

* `TextMapPropagator`s, and `ContextPropagators`, available through
* [[org.typelevel.otel4s.java.context.propagation.PropagatorConverters]].
*/
trait AsJavaExtensions {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we put implicit classes right into the PropagatorConverters object , we can define them as value classes:

implicit class TextMapGetterHasAsJava[A](private val getter: TextMapGetter[A]) extends AnyVal

In some cases, it could be more optimized in runtime.

But I don't have a strong opinion on this, to be honest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But I don't have a strong opinion on this, to be honest.

neither do I. I just structured it the same way scala.jdk.CollectionConverters is structured. I have no attachment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I say we leave it as is and change it later if needed

@NthPortal NthPortal force-pushed the scala-propagator-support/PR branch from 1d9d185 to 6fd1320 Compare November 28, 2023 19:17
@NthPortal
Copy link
Contributor Author

the docs for the conversions are copied/adapted from the stdlib. what's the correct way to cite that?

@iRevive
Copy link
Contributor

iRevive commented Dec 4, 2023

the docs for the conversions are copied/adapted from the stdlib. what's the correct way to cite that?

I don't know, to be honest. Perhaps a note would be enough.

@NthPortal
Copy link
Contributor Author

the docs for the conversions are copied/adapted from the stdlib. what's the correct way to cite that?

@SethTisue do you know the answer to this? sorry to drag you in here 😬

@SethTisue
Copy link
Member

I think what you've done — including a credit — is sufficient under the Apache license.

@NthPortal
Copy link
Contributor Author

thank you Seth!

Copy link
Contributor

@iRevive iRevive left a comment

Choose a reason for hiding this comment

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

LGMT. @armanbilge would you like to take a look?

@armanbilge
Copy link
Member

Thanks, sorry, don't have bandwidth to review this one. Thanks for all your work, please go ahead :)

@iRevive
Copy link
Contributor

iRevive commented Dec 20, 2023

@NthPortal seems we are ready to merge. Let me know if there is something else you would like to do within the PR.

@NthPortal
Copy link
Contributor Author

I'll autosquash and then once the build succeeds, it's done 👍

Add `PassThroughPropagator` that works with any context
implementation.
Change `TextMapPropagator` to always return the same instance when
passed a `Seq` with exactly one element, even when that element is
a `TextMapPropagator.Noop` instance.
Redesign converters between Java and Scala
`TextMap{Getter,Propagator}`s to follow the pattern from the Scala
standard library, supporting converting in either direction between
the types.

Remove unused conversion for `TextMapSetter`.
@NthPortal NthPortal force-pushed the scala-propagator-support/PR branch from 58e58be to c1565ad Compare December 20, 2023 14:52
@NthPortal NthPortal merged commit db4381d into typelevel:main Dec 20, 2023
10 checks passed
@NthPortal NthPortal deleted the scala-propagator-support/PR branch December 20, 2023 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants