Skip to content

Commit

Permalink
Merge pull request #16710 from obenkenobi/javaagent-upgrade-api-impro…
Browse files Browse the repository at this point in the history
…vements

Improve docs for upgrading the Java Agent and adding Java Agent APIs
  • Loading branch information
ally-sassman authored Apr 1, 2024
2 parents cfd7a96 + 7f38812 commit 6aa2081
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,15 @@ For all available New Relic APIs, see [Intro to APIs](/docs/apis/getting-started

## Use the API [#api]

To access the API class, add `newrelic-api.jar` to your application class path. The jar is in the New Relic Java agent's installation `zip` file. You can call the API when the Java agent is not running. The API methods are just stubs; the implementation is added when the Java agent loads the class.
To access the API, download it from maven central via a build tool.

Here's an example for gradle where you can replace `${agent.version}` with version of your agent:

```groovy
implementation 'com.newrelic.agent.java:newrelic-api:${agent.version}'
```

You can call the API even without the agent running, but the methods will be a no-op until the agent loads your application.

## Transactions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,13 @@ Then, to update to the latest Java agent version:
1. Back up the <DoNotTranslate>**entire**</DoNotTranslate> [Java agent root directory](/docs/agents/manage-apm-agents/troubleshooting/find-agent-root-directory#java-agent) to another location. Rename that directory to `NewRelic_Agent#.#.#`, where `#.#.#` is the agent version number.
2. [Download the agent.](/docs/release-notes/agent-release-notes/java-release-notes)
3. Unzip the new agent download file, then copy `newrelic-api.jar` and `newrelic.jar` into the original [Java agent root directory](/docs/agents/manage-apm-agents/troubleshooting/find-agent-root-directory#java-agent).
4. Compare your old `newrelic.yml` with the newly downloaded `newrelic.yml` from the zip, and [update the file if needed](#diff).
5. Restart your Java dispatcher.
4. (Optional) If you are using the any of the agent APIs like our [Java agent API](/docs/apm/agents/java-agent/api-guides/guide-using-java-agent-api/) or a [Scala API](/docs/apm/agents/java-agent/frameworks/scala-installation-java/#using-the-scala-api), we recommend you upgrade your API dependencies to the latest version. The newer agent version will still support the APIs, but you may be missing new features. If you're using a build tool like maven, upgrade the API versions to latest. For example, if you're using the Java Agent API with gradle, replace `${agent.version}` with the latest version:

If you experience issues after the Java agent update, restore from the backed-up New Relic agent directory.

## Update agent config differences [#diff]

```groovy
implementation 'com.newrelic.agent.java:newrelic-api:${agent.version}'
```

We add new settings to `newrelic.yml` as we release new versions of the agent. You can use `diff` or another diffing utility to see what's changed, and add the new config settings to your old file. Make sure not to overwrite any customizations you've made to the file, such as your license key, app name, or changes to default settings.
5. Restart your Java process.

For example, if you `diff` the default `newrelic.yml` files for Java agent versions 7.7.0 and 7.8.0, the results printed to the console will be:

```diff
➜ diff newrelic_7.7.0.yml newrelic_7.8.0.yml
98c98
< #forwarding:
---
> forwarding:
100,101c100,101
< # When true, application logs will be forwarded to New Relic. The default is false.
< #enabled: false
---
> # When true, application logs will be forwarded to New Relic. The default is true.
> enabled: true
```

In this example, these lines were added to the default `newrelic.yml` in Java agent version 7.8.0. If you are moving to 7.8.0 or higher, you should add these new lines to your original `newrelic.yml`.
If you experience issues after the Java agent update, restore from the backed-up New Relic agent directory.

0 comments on commit 6aa2081

Please sign in to comment.