Skip to content

feat: add datamanagement and pruningrules packages#1407

Draft
pranav-new-relic wants to merge 7 commits into
mainfrom
wip/datamanagement
Draft

feat: add datamanagement and pruningrules packages#1407
pranav-new-relic wants to merge 7 commits into
mainfrom
wip/datamanagement

Conversation

@pranav-new-relic
Copy link
Copy Markdown
Member

@pranav-new-relic pranav-new-relic commented May 11, 2026

Summary

Adds two new packages to support metric cardinality management in New Relic:

pkg/datamanagement — exposes the NerdGraph dataManagement API for managing account-level cardinality limit overrides:

  • DataManagementCreateAccountLimit mutation — upserts a limit override, supporting both an account-wide default (empty Qualifier) and a per-metric override (Qualifier = metric name)
  • GetLimits query — returns all current limits for an account; used to read back the cardinality default after apply

pkg/pruningrules — a purpose-built client for metric attribute pruning rules, using the nrqlDropRules NerdGraph API scoped exclusively to DROP_ATTRIBUTES_FROM_METRIC_AGGREGATES. This replaces direct use of the general-purpose nrqldroprules package for metric pruning, which is EOL June 30 2026:

  • NRQLDropRulesCreate / NRQLDropRulesDelete mutations
  • GetList query + GetPruningRuleByID helper
  • NRQLDropRulesActionTypes restricted to DROP_ATTRIBUTES_FROM_METRIC_AGGREGATES only — DROP_ATTRIBUTES and DROP_DATA are intentionally excluded to prevent misuse

Both packages are wired into the top-level NewRelic struct in newrelic/newrelic.go.

Context

These packages are the client-go foundation for two Terraform resources being added in terraform-provider-newrelic#3091:

  • newrelic_account_cardinality_limit — uses datamanagement
  • newrelic_metric_pruning_rule — uses pruningrules

Testing

Integration tests cover create/list/get-by-ID/delete happy paths, invalid input failure cases, and not-found handling. Tests have been verified against a live account via the Terraform provider CI.

@pranav-new-relic pranav-new-relic changed the title wip(datamanagement): add datamanagement package scaffolding feat(datamanagement): add datamanagement package May 11, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 11, 2026

Codecov Report

❌ Patch coverage is 2.40964% with 81 lines in your changes missing coverage. Please review.
✅ Project coverage is 32.32%. Comparing base (ec1123e) to head (124c60b).

Files with missing lines Patch % Lines
pkg/pruningrules/pruningrules_api.go 0.00% 37 Missing ⚠️
pkg/datamanagement/datamanagement_api.go 0.00% 26 Missing ⚠️
pkg/pruningrules/pruningrules_api_.go 0.00% 8 Missing ⚠️
pkg/datamanagement/datamanagement.go 0.00% 6 Missing ⚠️
pkg/pruningrules/pruningrules.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1407      +/-   ##
==========================================
- Coverage   32.70%   32.32%   -0.38%     
==========================================
  Files         141      146       +5     
  Lines        6691     6774      +83     
==========================================
+ Hits         2188     2190       +2     
- Misses       4292     4373      +81     
  Partials      211      211              
Flag Coverage Δ
unit 32.32% <2.40%> (-0.38%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

pranav-new-relic added a commit to newrelic/terraform-provider-newrelic that referenced this pull request May 19, 2026
…d data source

Adds two new top-level identifiers for managing dimensional metric
cardinality limit overrides in a New Relic account:

newrelic_account_cardinality_limit (resource)
  - mode = "DEFAULT": sets the account-wide per-metric cardinality
    default (applies to all metrics not individually overridden)
  - mode = "PER_METRIC": overrides the limit for a single named metric
    (metric_name required)
  - CustomizeDiff enforces mode/metric_name compatibility at plan time
  - Create/Update both call the upsert mutation (idempotent)
  - Delete is a state-only removal; the NerdGraph API has no delete
    operation for cardinality overrides
  - Resource ID format: <accountId>:<metricName> (trailing colon for DEFAULT)

newrelic_account_cardinality_limits (data source)
  - Reads all current account limits via dataManagement.limits and
    returns cardinality-related entries as a structured list

Depends on newrelic/newrelic-client-go#1407 (datamanagement package).
go.mod pinned to wip/datamanagement branch commit.
@pranav-new-relic pranav-new-relic changed the title feat(datamanagement): add datamanagement package feat: add datamanagement and pruningrules packages May 21, 2026
@github-actions
Copy link
Copy Markdown

❌ Invalid Conventional Commits Detected

The following commits do not follow the Conventional Commits format:

3dec7d6 - test(datamanagement,pruningrules): add integration tests for both packages

Please update these commit messages to follow the format:
<type>[optional scope]: <description>

Valid types: build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test

@pranav-new-relic pranav-new-relic force-pushed the wip/datamanagement branch 3 times, most recently from 315874c to 5af5cf7 Compare May 22, 2026 18:50
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 22, 2026

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 4 committers have signed the CLA.

✅ Philip-R-Beckwith
✅ pranav-new-relic
❌ gffuentes
❌ nr-developer-toolkit
You have signed the CLA already but the status is still pending? Let us recheck it.

Adds a new datamanagement package generated via tutone, exposing:
- DataManagementCreateAccountLimit mutation — upserts a per-account
  limit override (supports both account-wide default and per-metric
  qualifier overrides via the Qualifier field)
- GetLimits query — returns all current limits for an account,
  including the dimensional metric per-metric cardinality limit

This package is the client-go foundation for the
newrelic_account_cardinality_limit Terraform resource.
…ning

Adds a dedicated pruningrules package as the long-term replacement for
DROP_ATTRIBUTES_FROM_METRIC_AGGREGATES usage in nrqldroprules, which is
scheduled for EOL on June 30 2026. Only DROP_ATTRIBUTES_FROM_METRIC_AGGREGATES
is exposed; DROP_ATTRIBUTES and DROP_DATA are intentionally excluded since
this package is purpose-built for metric attribute pruning.

Also wires Pruningrules into the top-level NewRelic client struct.
…in newrelic.go

- Restore accidentally-commented-out SyntheticsAutomatedTest* struct_tags
  entries in .tutone.yml that were dropped in the pruningrules commit
- Fix import, struct field, and initializer ordering in newrelic.go:
  Dashboards before DataManagement, Pipelinecontrol before Pruningrules
- Move pruningrules import after plugins (alphabetical: pl < pr)
- Replace `for _, _ = range` with `for range` in nrqldroprules integration test
…ion test

The API returns INVALID_INPUT when the rule ID fails format validation
before the lookup, rather than RULE_NOT_FOUND. Accept either reason.
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