Skip to content

feat(newrelic): APM application id can be looked up by name#361

Open
3bbbeau wants to merge 4 commits intoargoproj:masterfrom
3bbbeau:feat/newrelic-appid-by-name
Open

feat(newrelic): APM application id can be looked up by name#361
3bbbeau wants to merge 4 commits intoargoproj:masterfrom
3bbbeau:feat/newrelic-appid-by-name

Conversation

@3bbbeau
Copy link
Copy Markdown

@3bbbeau 3bbbeau commented Mar 5, 2025

Summary

This is intended to be a quality of life feature to allow ArgoCD ApplicationSet resources to minimize boilerplate when dealing with NewRelic APM resources across multiple environments.

Currently

  • An application programmatically uses the NR SDK to report to NewRelic
  • NewRelic APM Application ID has to then be retrieved following the first run of an application from the NR Dashboard and added to an ArgoCD Application via the annotation, across multiple environments.
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  annotations:
    notifications.argoproj.io/subscribe.<trigger-name>.newrelic: 123456789

Desired

Using ArgoCD ApplicationSet resources, the annotation can be either provided via the application id as the above example, or instead by name, e.g. MyApp-{{ .values.env }}:

---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  annotations:
    notifications.argoproj.io/subscribe.<trigger-name>.newrelic: MyApp-Dev

Logic

If dest.Recipient can be parsed to an int, then the application id was directly provided and logic remains as before.

If dest.Recipient cannot be parsed to an integer, then it was passed by name (since all NewRelic APM IDs are defined as integers within the schema) and we call /v2/applications.json to query using filter[name]

If /v2/applications.json returns multiple application IDs then an error is returned, as we can't determine which application id to use to place the deployment marker.

@3bbbeau 3bbbeau force-pushed the feat/newrelic-appid-by-name branch 9 times, most recently from 063b8d4 to 2d77a47 Compare March 5, 2025 12:53
Comment thread pkg/services/newrelic.go Outdated
Comment thread pkg/services/newrelic.go Outdated
Comment thread pkg/services/newrelic.go Outdated
@pasha-codefresh
Copy link
Copy Markdown
Member

Hey @3bbbeau could you please address comments?

@3bbbeau 3bbbeau force-pushed the feat/newrelic-appid-by-name branch from 0613604 to cb85658 Compare January 26, 2026 13:17
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 26, 2026

Codecov Report

❌ Patch coverage is 65.90909% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.12%. Comparing base (da04400) to head (1582b2f).
⚠️ Report is 27 commits behind head on master.

Files with missing lines Patch % Lines
pkg/services/newrelic.go 65.90% 9 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #361      +/-   ##
==========================================
+ Coverage   55.41%   60.12%   +4.71%     
==========================================
  Files          46       48       +2     
  Lines        4125     3742     -383     
==========================================
- Hits         2286     2250      -36     
+ Misses       1511     1131     -380     
- Partials      328      361      +33     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This is intended to be a quality of life addition to allow
`ApplicationSet` resources to minimize boilerplate when dealing with
NewRelic APM resources across multiple environments.
- An application programmatically [uses the NR SDK to report to
  NewRelic](https://github.com/newrelic/go-agent/blob/master/v3/examples/server/main.go#L267-L274)
- NewRelic APM Application ID has to then be retrieved following the
  first run of an application from the NR Dashboard and added to an
  ArgoCD `Application` via the annotation, across multiple environments.
Using ArgoCD `ApplicationSet` resources, the annotation can be either
provided via app_id, or by name, e.g. `MyApp-{{ .values.env }}`
If `dest.Recipient` can be parsed to an int, then app_id is provided
and logic remains as before.
If `dest.Recipient` cannot be parsed to an integer, then it was passed
by name and we call `/v2/applications.json` to query using
`filter[name]`
If `/v2/applications.json` returns multiple application IDs then an
error is returned, as we can't determine which app_id to use to place
the deployment marker.

Signed-off-by: 3bbbeau <0x3bb@3bb.io>
Signed-off-by: 3bbbeau <0x3bb@3bb.io>
Guard against potential injection from appName

Signed-off-by: 3bbbeau <0x3bb@3bb.io>
@3bbbeau 3bbbeau force-pushed the feat/newrelic-appid-by-name branch from cb85658 to eedfe1e Compare January 26, 2026 13:40
- error wrapping %w
- http.NoBody over nil
- unused parameter 'r'
- assert errors with require

Signed-off-by: 3bbbeau <0x3bb@3bb.io>
@3bbbeau 3bbbeau force-pushed the feat/newrelic-appid-by-name branch from eedfe1e to 1582b2f Compare January 26, 2026 13:40
@3bbbeau
Copy link
Copy Markdown
Author

3bbbeau commented Jan 26, 2026

@pasha-codefresh Hey, I've addressed all but #361 (comment) which I'm not sure I understand broader implementation details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants