Skip to content

Commit

Permalink
feat(application_settings): amp application apm settings to sync with…
Browse files Browse the repository at this point in the history
… the latest released/available features/functionalities in apm settings ui

feat(application_settings) : Revamp application settings to sync with the latest features

feat(application_settings) : Revamp application settings to sync with the latest features

feat(application_settings) : Revamp application settings to sync with the latest features
  • Loading branch information
vinay-newrelic committed Feb 11, 2025
1 parent 6e5fd87 commit 7bd5f6d
Show file tree
Hide file tree
Showing 8 changed files with 1,184 additions and 27 deletions.
22 changes: 22 additions & 0 deletions .tutone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1676,3 +1676,25 @@ packages:
field_type_override: "*nrtime.EpochMilliseconds"
skip_type_create: true

- name: apm
path: pkg/apm
import_path: github.com/newrelic/newrelic-client-go/v2/pkg/apm
generators:
- typegen
- nerdgraphclient
mutations:
- name: agentApplicationSettingsUpdate
max_query_field_depth: 5
types:
- name: ID
field_type_override: string
skip_type_create: true
- name: DateTime
field_type_override: nrtime.DateTime
skip_type_create: true
- name: Seconds
field_type_override: nrtime.Seconds
skip_type_create: true
- name: EpochMilliseconds
field_type_override: "*nrtime.EpochMilliseconds"
skip_type_create: true
2 changes: 1 addition & 1 deletion pkg/agentapplications/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var AgentApplicationSettingsBrowserLoaderTypes = struct {
RUM: "RUM",
// Pro+SPA: This is the default installed agent when you enable browser monitoring. Gives you access to all of the Browser Pro features and to Single Page App (SPA) monitoring. Provides detailed page timing data and the most up-to-date New Relic features, including distributed tracing, for all types of applications.
SPA: "SPA",
// This value is specified for backwards-compatability.
// This value is specified for backwards-compatibility.
XHR: "XHR",
}

Expand Down
204 changes: 204 additions & 0 deletions pkg/apm/apm_api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 39 additions & 10 deletions pkg/apm/applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type ApplicationsInterface interface {

// Application represents information about a New Relic application.
type Application struct {
GUID EntityGUID `json:"guid,omitempty"`
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Language string `json:"language,omitempty"`
Expand Down Expand Up @@ -49,10 +50,37 @@ type ApplicationEndUserSummary struct {

// ApplicationSettings represents some of the settings of a New Relic application.
type ApplicationSettings struct {
AppApdexThreshold float64 `json:"app_apdex_threshold,omitempty"`
EndUserApdexThreshold float64 `json:"end_user_apdex_threshold,omitempty"`
EnableRealUserMonitoring bool `json:"enable_real_user_monitoring"`
UseServerSideConfig bool `json:"use_server_side_config"`
Alias string `json:"alias,omitempty"`
ApmConfig Config `json:"apmConfig,omitempty"`
ThreadProfilerEnabled bool `json:"threadProfiler,omitempty"`
ErrorCollector ErrorCollector `json:"errorCollector,omitempty"`
TransactionTracing TransactionTracing `json:"transactionTracer,omitempty"`
TracerType string `json:"tracerType,omitempty"`
}

type Config struct {
ApdexTarget float64 `json:"apdexTarget,omitempty"`
UseServerSideConfig bool `json:"useServerSideConfig,omitempty"`
}

type ErrorCollector struct {
Enabled bool `json:"enabled,omitempty"`
ExpectedErrorCodes []string `json:"expectedErrorCodes,omitempty"`
ExpectedErrorClasses []string `json:"expectedErrorClasses,omitempty"`
IgnoredErrorCodes []string `json:"ignoredErrorCodes,omitempty"`
IgnoredErrorClasses []string `json:"ignoredErrorClasses,omitempty"`
}

type TransactionTracing struct {
Enabled bool `json:"enabled,omitempty"`
TransactionThresholdValue float64 `json:"transactionThresholdValue,omitempty"`
TransactionThresholdType string `json:"transactionThresholdType,omitempty"`
RecordSql string `json:"recordSql,omitempty"`
LogSql bool `json:"logSql,omitempty"`
StackTraceThresholdValue float64 `json:"stackTraceThreshold,omitempty"`
ExplainQueryPlanEnabled bool `json:"explainEnabled,omitempty"`
ExplainQueryPlanThresholdValue float64 `json:"explainThresholdValue,omitempty"`
ExplainQueryPlanThresholdType string `json:"explainThresholdType,omitempty"`
}

// ApplicationLinks represents all the links for a New Relic application.
Expand All @@ -66,17 +94,18 @@ type ApplicationLinks struct {
// ListApplicationsParams represents a set of filters to be
// used when querying New Relic applications.
type ListApplicationsParams struct {
Name string `url:"filter[name],omitempty"`
Host string `url:"filter[host],omitempty"`
IDs []int `url:"filter[ids],omitempty,comma"`
Language string `url:"filter[language],omitempty"`
Name string `url:"filter[name],omitempty"`
GUID EntityGUID `json:"filter[guid],omitempty"`
Host string `url:"filter[host],omitempty"`
IDs []int `url:"filter[ids],omitempty,comma"`
Language string `url:"filter[language],omitempty"`
}

// UpdateApplicationParams represents a set of parameters to be
// used when updating New Relic applications.
type UpdateApplicationParams struct {
Name string
Settings ApplicationSettings
Name string `json:"name,omitempty"`
Settings ApplicationSettings `json:"settings,omitempty"`
}

// ListApplications is used to retrieve New Relic applications.
Expand Down
59 changes: 50 additions & 9 deletions pkg/apm/applications_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,32 @@ var (
}

testApplicationSettings = ApplicationSettings{
AppApdexThreshold: 0.5,
EndUserApdexThreshold: 7,
EnableRealUserMonitoring: true,
UseServerSideConfig: false,
Alias: "tf_test_updated",
ApmConfig: Config{
ApdexTarget: 0,
UseServerSideConfig: false,
},
ThreadProfilerEnabled: false,
ErrorCollector: ErrorCollector{
Enabled: false,
ExpectedErrorCodes: nil,
ExpectedErrorClasses: nil,
IgnoredErrorCodes: nil,
IgnoredErrorClasses: nil,
},
TransactionTracing: TransactionTracing{
Enabled: false,
TransactionThresholdValue: 0,
TransactionThresholdType: "",
RecordSql: "",
LogSql: false,
StackTraceThresholdValue: 0,
ExplainQueryPlanEnabled: false,
ExplainQueryPlanThresholdValue: 0,
ExplainQueryPlanThresholdType: "",
},
TracerType: "NONE",
}

testApplicationLinks = ApplicationLinks{
ServerIDs: []int{},
HostIDs: []int{204260579},
Expand Down Expand Up @@ -99,10 +119,31 @@ var (
"apdex_score": 0.78
},
"settings": {
"app_apdex_threshold": 0.5,
"end_user_apdex_threshold": 7,
"enable_real_user_monitoring": true,
"use_server_side_config": false
"Alias": "tf_test_updated",
"ApmConfig": {
"ApdexTarget": 0,
"UseServerSideConfig": false
},
"ThreadProfilerEnabled": false,
"ErrorCollector": {
"Enabled": false,
"ExpectedErrorCodes": null,
"ExpectedErrorClasses": null,
"IgnoredErrorCodes": null,
"IgnoredErrorClasses": null
},
"TransactionTracing": {
"Enabled": false,
"TransactionThresholdValue": 0,
"TransactionThresholdType": "",
"RecordSql": "",
"LogSql": false,
"StackTraceThresholdValue": 0,
"ExplainQueryPlanEnabled": false,
"ExplainQueryPlanThresholdValue": 0,
"ExplainQueryPlanThresholdType": ""
},
"TracerType": "NONE"
},
"links": {
"application_instances": [
Expand Down
4 changes: 3 additions & 1 deletion pkg/apm/example_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ func Example_application() {
updateParams := UpdateApplicationParams{
Name: app.Name,
Settings: ApplicationSettings{
AppApdexThreshold: 0.6,
ApmConfig: Config{
ApdexTarget: 0.6,
},
},
}

Expand Down
Loading

0 comments on commit 7bd5f6d

Please sign in to comment.