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

Daily release/10 28 24 afternoon #19108

Merged
merged 18 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title: Scala instrumentation
title: "Scala instrumentation"
tags:
- Agents
- Java agent
- Custom instrumentation
metaDescription: Supplemental directions for instrumenting the New Relic Java agent with Scala applications.
metaDescription: "Supplemental directions for instrumenting the New Relic Java agent with Scala applications."
redirects:
- /docs/agents/java-agent/frameworks/scala-installation-java
- /docs/java/scala-general-help
Expand Down Expand Up @@ -223,6 +223,48 @@ implicit val ec: ExecutionContext = ???
x.foreach(println) // prints 3 on completion of Future
```

### Futures

New Relic handles Scala futures when they're submitted to the executor, which might lead to a different outcome than you expect. The examples in this section clarifies how this works, so you know what to expect.

This example is calling a transaction block, which takes a future as its parameter and chains it to a second future:

```scala
def chainFutures(f: Future[Unit]) = txn {
f.flatMap( _ => Future{ Thread.sleep(2000) })
}

val f = Future { Thread.sleep(5000) } // future is submitted here
chainFutures(f)
```

From this example, you might expect `chainFutures` to produce a transaction lasting 7 seconds. Instead, the New Relic UI shows the transaction finishing immediately.

The future `f` in the example is submitted by the `Future.apply()` method when it's constructed, before the transaction exists. Because `f` is submitted outside the transaction, any threadhops made during its execution aren't linked together. The downstream future, `Future{ Thread.sleep(2000) }`, is also untracked, because it's submitted in a callback after the transaction context is already gone.

There are a few things you can do to get your transaction to capture the timing of both futures.

* Although you might not be able to change when `f` is submitted, you can time it using the `asyncTrace` method. This times `f` from the moment the transaction is started (but will not track threadhops made by `f`).
* You can use a token to link the callback to the transaction in order to preserve the transaction context during threadhops.
* You can add another `asyncTrace` to time the second future.

With this example, the New Relic UI shows a transaction lasting about 7 seconds, with two segments named “first future” and “second future”:


```scala
def chainFutures(f: Future[Unit]) = txn {
val t = NewRelic.getAgent.getTransaction.getToken
asyncTrace("future one" )(f) //asyncTrace times the first future
.flatMap(_ => {
t.linkAndExpire() //token links across potential threadhops
asyncTrace("future two"){ Future { Thread.sleep(2000) } } //asyncTrace times the second future
})
}
val f = Future { Thread.sleep(5000) }
chainFutures(f)
```


## Instrument Scala with the Java agent API [#using-the-java-api]

Instrument Scala to use the New Relic API class or [annotations](/docs/agents/java-agent/java-agent-api/java-agent-api-instrument-using-annotation).
Expand Down
19 changes: 19 additions & 0 deletions src/content/whats-new/2024/10/whats-new-10-21-in-app-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: 'Global in-app help helps you connect the dots'
summary: 'Now you can get contextual help and access to our support team without leaving your current workflow .'
getStartedLink: https://one.newrelic.com/
releaseDate: '2024-10-21'
---

New Relic has released an enhanced global in-app help system that seamlessly integrates contextual assistance and direct access to our support team, no matter where you are in the UI. This update consolidates all support features into one convenient location, ensuring you have the resources and expert guidance you need at your fingertips like:

* **Contextual in-app help:** Quickly access relevant assistance directly within the application, for efficient problem-solving without leaving your current workflow.
* **In-app support case and forum search:** Access a wealth of information and community insights and leverage shared knowledge to find solutions faster.
* **Access your support cases:** Easily track and manage support queries, receive timely updates and directly communicate with our support team without leaving the UI.
* **Direct link to our docs site:** Benefit from comprehensive and expertly curated documentation that provides detailed guidance, helping you maximize the potential of New Relic to achieve optimal results.
* **Useful keyboard shortcuts:** Enhance your productivity with time-saving shortcuts that streamline your tasks.
* **What's New posts:** Stay informed with the latest updates and features, ensuring you are always in the know about our latest tools and insights to drive innovation and growth in your projects.

![In-app help](/images/whats-new-in-app-help.webp "A screenshot of our in-app help on the APM summary page")

Just click the **?** and get immediate access to the global in-app help.
Loading
Loading