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

Improve docs for upgrading the Java Agent and adding Java Agent APIs #16710

Merged
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.

obenkenobi marked this conversation as resolved.
Show resolved Hide resolved
For example with gradle:
obenkenobi marked this conversation as resolved.
Show resolved Hide resolved

```groovy
implementation 'com.newrelic.agent.java:newrelic-api:8.10.0'
```

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.
obenkenobi marked this conversation as resolved.
Show resolved Hide resolved

## Transactions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,10 @@ 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), it is recommended to upgrade your API dependencies as well to the latest version. Your newer version of the agent will still support the APIs but you may be missing new features plus upgrading is relatively easy. If you are using a build tool like maven, upgrade the API versions to latest. For example if you are using the Java Agent API with gradle where `${agent.version}` is a placeholder for the upgraded agent version:
obenkenobi marked this conversation as resolved.
Show resolved Hide resolved
```groovy
ally-sassman marked this conversation as resolved.
Show resolved Hide resolved
implementation 'com.newrelic.agent.java:newrelic-api:8.10.0'
obenkenobi marked this conversation as resolved.
Show resolved Hide resolved
```
5. Restart your Java process.
ally-sassman marked this conversation as resolved.
Show resolved Hide resolved

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

## Update agent config differences [#diff]

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.

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`.
Loading