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

cats effect 3: pass transaction info by implicits #578

Merged
merged 1 commit into from
Dec 2, 2021
Merged

Conversation

richard-gibson
Copy link
Contributor

@richard-gibson richard-gibson commented Nov 29, 2021

Before contributing, please read our contributing guidelines and code of conduct.

Overview

This is a change to the newrelic scala cats 3 api. The change ensures transaction and current token information is passed by parameters rather than ThreadLocal variables. Parameters used are implicit, this helps to keep API changes to a minimum

Related Github Issue

Include a link to the related GitHub issue, if applicable
#406

Testing

The agent includes a suite of tests which should be used to
verify your changes don't break existing functionality. These tests will run with
Github Actions when a pull request is made. More details on running the tests locally can be found
here,

Checks

[N] Are your contributions backwards compatible with relevant frameworks and APIs?
A small breaking change was necessary for the Cats Effect 3 API.

    val txnBlock: IO[Int] = txn(
      for {
        one <- asyncTrace("one")(IO(1))
        two <- asyncTrace("two")(IO(one + 1))
        three <- asyncTrace("three")(IO(two + 1))
      } yield three
    )

now becomes

    val txnBlock: IO[Int] = txn(implicit txnInfo =>
      for {
        one <- asyncTrace("one")(IO(1))
        two <- asyncTrace("two")(IO(one + 1))
        three <- asyncTrace("three")(IO(two + 1))
      } yield three
    )

[ Y] Does your code contain any breaking changes? Please describe.
See above
[ N] Does your code introduce any new dependencies? Please describe.

import com.newrelic.api.agent.weaver.Weaver
import com.newrelic.api.agent.weaver.scala.{ScalaMatchType, ScalaWeave}

@ScalaWeave(`type` = ScalaMatchType.Object, `originalName` = "com.newrelic.cats3.api.TraceOps")
class TraceOps_Instrumentation {
def txn[S, F[_]:Sync](body: F[S]): F[S] = {
Util.wrapTrace(Weaver.callOriginal)
// def txnInfo: TxnInfo = Weaver.callOriginal()
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove comment

@twcrone twcrone merged commit 031ce9e into main Dec 2, 2021
@twcrone twcrone deleted the ce3-implicits branch December 2, 2021 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants