Skip to content

Commit

Permalink
Merge pull request #10 from musabbozkurt/new-relic-refactoring
Browse files Browse the repository at this point in the history
custom-extensions.xml is added
  • Loading branch information
musabbozkurt authored Aug 28, 2024
2 parents 55c03b8 + 4771ef0 commit 59eb06e
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ NEW_RELIC_LICENSE_KEY=eu01xxhu5ic8N0TmUkXQLgb0VWufpuyvapd0Qz63
NEW_RELIC_APP_NAME=inventory-management-service
NEW_RELIC_AGENT_JAR_PATH=opt/newrelic/newrelic.jar
NEW_RELIC_ENDPOINT=https://otlp.eu01.nr-data.net
NEW_RELIC_ENABLED=false
NEW_RELIC_AGENT_ENABLED=false
NEW_RELIC_INFRA_AGENT_REPLICAS=0

POSTGRES_PASSWORD=postgres
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ ARG PROJECT_DIR=/home/projects/${PROJECT_NAME}
COPY .. ${PROJECT_DIR}

# Download dependencies (this layer will be cached if pom.xml doesn't change)
RUN mvn -f ${PROJECT_DIR}/pom.xml dependency:go-offline

RUN mvn -f ${PROJECT_DIR}/pom.xml clean install -DskipTests
RUN --mount=type=cache,target=/root/.m2 mvn -f $PROJECT_DIR/pom.xml clean package -DskipTests

### Package stage ###

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* If there is a `New Relic` account, log in to [New Relic](https://login.newrelic.com/login)
1. Generate `api-key` and replace the `NEW_RELIC_LICENSE_KEY` value with yours in the [.env](.env) file
2. Replace the `NEW_RELIC_ENDPOINT` value with yours in the [.env](.env) file
3. In the [.env](.env) file, if `api-key` and `endpoint` are present with the correct
values, `NEW_RELIC_ENABLED` can be `true` and `NEW_RELIC_INFRA_AGENT_REPLICAS` can be greater than zero(0)
3. In the [.env](.env) file, if `api-key` and `endpoint` are present with the correct values,
`NEW_RELIC_AGENT_ENABLED` can be `true` and `NEW_RELIC_INFRA_AGENT_REPLICAS` can be greater than zero(0)

-----

Expand Down
25 changes: 25 additions & 0 deletions opt/newrelic/extensions/custom-extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- This is an example of a custom instrumentation extension XML file. -->

<extension xmlns="https://newrelic.com/docs/java/xsd/v1.0"
name="custom-extensions">
<instrumentation>

<!-- This point cut disables instrumentation of the method handle(HttpServletRequest request, @RequestBody(required = false) Map<String, String> body) for
all implementations of the class org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler. -->
<pointcut ignoreTransaction="true">
<className>
org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler
</className>
<!-- Disable instrumentation of the method Object handle(HttpServletRequest request, @RequestBody(required = false) Map<String, String> body) -->
<method>
<name>handle</name>
<parameters>
<type>javax.servlet.http.HttpServletRequest</type>
<type>java.util.Map</type>
</parameters>
</method>
</pointcut>
</instrumentation>
</extension>
2 changes: 1 addition & 1 deletion opt/newrelic/newrelic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ common: &default_settings
# Agent enabled
# Use this setting to disable the agent instead of removing it from the startup command.
# Default is true.
agent_enabled: true
agent_enabled: <%= ENV.fetch('NEW_RELIC_AGENT_ENABLED', false) %>

# Set the name of your application as you'd like it to show up in the New Relic UI.
# If enable_auto_app_naming is false, the agent reports all data to this application.
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ management:
export:
api-key: ${NEW_RELIC_LICENSE_KEY}
endpoint: ${NEW_RELIC_ENDPOINT}
enabled: ${NEW_RELIC_ENABLED}
enabled: ${NEW_RELIC_AGENT_ENABLED}
zipkin:
tracing:
endpoint: http://${ZIPKIN_HOST:localhost}:9411/api/v2/spans
Expand Down

0 comments on commit 59eb06e

Please sign in to comment.