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

Clean up some warnings and a typo in a public method #137

Merged
merged 3 commits into from Oct 5, 2020

Conversation

HaloFour
Copy link
Collaborator

@HaloFour HaloFour commented Oct 2, 2020

Clean up most of the Scala 2.12 warnings. Many of the Scala 2.13 warnings cannot currently be addressed with code that can cross-compile with Scala 2.12.

Replace use of deprecated Stack[Span] in SpanLocal with List[Span] treated as a stack.

Fix typo in name of MDCSupport.propagateMDC method.

@codecov-commenter
Copy link

codecov-commenter commented Oct 2, 2020

Codecov Report

Merging #137 into master will decrease coverage by 0.01%.
The diff coverage is 97.05%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #137      +/-   ##
==========================================
- Coverage   92.54%   92.52%   -0.02%     
==========================================
  Files          51       51              
  Lines         872      870       -2     
  Branches       56       51       -5     
==========================================
- Hits          807      805       -2     
  Misses         65       65              
Impacted Files Coverage Δ
.../scala/com/comcast/money/akka/MoneyExtension.scala 89.47% <ø> (ø)
.../com/comcast/money/akka/SpanContextWithStack.scala 90.90% <0.00%> (ø)
...main/scala/com/comcast/money/core/Formatters.scala 93.15% <ø> (ø)
...src/main/scala/com/comcast/money/core/Tracer.scala 100.00% <100.00%> (ø)
...urrent/TraceFriendlyExecutionContextExecutor.scala 86.66% <100.00%> (ø)
...e/concurrent/TraceFriendlyThreadPoolExecutor.scala 90.00% <100.00%> (ø)
...a/com/comcast/money/core/internal/MDCSupport.scala 100.00% <100.00%> (ø)
...la/com/comcast/money/core/internal/SpanLocal.scala 100.00% <100.00%> (ø)
.../com/comcast/money/core/logging/MethodTracer.scala 100.00% <100.00%> (ø)
...om/comcast/money/http/client/HttpTraceAspect.scala 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1c79be7...74c3cf2. Read the comment docs.

@HaloFour
Copy link
Collaborator Author

HaloFour commented Oct 2, 2020

The difference between empty parameter lists between SpanContext and SpanLocal generates a bunch of warnings, but I'm finding that making changes to either breaks existing code. I did make a few changes in less impacted areas but if that's controversial I can walk it back. If these changes are leading towards a potential 1.0 release then perhaps it's worth taking the breaking changes at this time to make the API consistent.

@HaloFour
Copy link
Collaborator Author

HaloFour commented Oct 3, 2020

Was reading up on idiomatic Scala and it sounds like empty parameter lists should be omitted when the method has no side effects. Given this my opinion would be that we should change the SpanContext trait to be as follows:

trait SpanContext {
  def push(span: Span): Unit
  def pop(): Option[Span]
  def current: Option[Span]
  def clear(): Unit
}

As pop and clear are expected to have the side effect of modifying the ambient span. The SpanLocal object already follows this convention.

@ptravers
Copy link
Collaborator

ptravers commented Oct 4, 2020

I would prefer to get the W3C Trace Header updates out before making a breaking release. Happy to do a breaking release after that. I'm a little concerned about making a 1.0 release without going through and doing a deep clean. There's a bunch of stuff that needs to be ripped out of the akka package and I imagine a lot of the other packages are so decrepit that they should really be rejuvenated before we go to 1.0. At some point we do need to have a discussion about what we want to do with Money. I personally feel like converting Money to being a shim for OpenTelemetry (OT) and asking our users to make the switch to OT would be the most responsible solution for the library going forward.

cc: @paulcleary what are your thoughts?

}
}

def propogateMDC(submittingThreadsContext: Option[Map[_, _]]): Unit = if (enabled) {
def propagateMDC(submittingThreadsContext: Option[Map[String, String]]): Unit = if (enabled) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this the only breaking change? Can we just instead deprecate the incorrect name and add a second method with the correct name?

I am actually more concerned about the type changes being made here and what effect that will have on integrated codebases. I also don't have any context as to why we need to wildcard the type here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't know if the changes to SpanContext are source-breaking or binary-breaking. They might count also.

Old versions of slf4j returned the raw Map type with the context map.

As for the name change, that's up for debate. IMO if this is a change on the road to 1.x it's better to accept the breaking changes now, but we can also temporarily include the deprecated version until we do release that version.

Copy link
Member

Choose a reason for hiding this comment

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

How is this breaking, just curious? The method is internal to the money runtime isn't it? I guess as long as anything that calls this method is also updated it is ok?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's technically a public class and used by other modules in the project to propagate MDC across thread boundaries. It's possible that an external client took a dependency on the class directly if they were tracing around some other asynchronous library not covered by one of Money's projects.

@@ -122,5 +122,5 @@ class SpanContextWithStack() extends SpanContext {
* empties the Stack of all spans
*/

override def clear: Unit = stack = List.empty[Span]
override def clear(): Unit = stack = List.empty[Span]
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@HaloFour
Copy link
Collaborator Author

HaloFour commented Oct 4, 2020

I'd also not want to rev Money to 1.0 until OpenTelemetry does, so that would be another reason to avoid (or mitigate) breaking changes.

@ptravers
Copy link
Collaborator

ptravers commented Oct 4, 2020

Yeah that's a great point! I think everyone in this thread knows already but I created an issue related to this #138

@HaloFour HaloFour merged commit 06171e5 into Comcast:master Oct 5, 2020
@HaloFour HaloFour deleted the clean-up-warnings branch October 5, 2020 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants