Skip to content

Commit

Permalink
Revert "Added Max Samples per Custom Events Setting"
Browse files Browse the repository at this point in the history
This reverts commit 0385173.
  • Loading branch information
mirackara committed Jun 27, 2022
1 parent e59734c commit fd44db5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 37 deletions.
3 changes: 0 additions & 3 deletions internal/harvest.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,8 @@ type HarvestConfigurer interface {
MaxSpanEvents() int
// MaxCustomEvents returns the maximum number of Custom Events that should be reported per period
MaxCustomEvents() int
// MaxSamplesStored returns the maximum number of Custom Event Samples stored in a Custom Event
MaxSamplesStored() int
// MaxErrorEvents returns the maximum number of Error Events that should be reported per period
MaxErrorEvents() int

MaxTxnEventer
}

Expand Down
8 changes: 4 additions & 4 deletions v3/internal/connect_reply.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,19 @@ func (r *ConnectReply) ConfigurablePeriod() time.Duration {
func uintPtr(x uint) *uint { return &x }

// DefaultEventHarvestConfig provides faster event harvest defaults.
func DefaultEventHarvestConfig(maxTxnEvents int, maxCustomEvents int) EventHarvestConfig {
func DefaultEventHarvestConfig(maxTxnEvents int) EventHarvestConfig {
cfg := EventHarvestConfig{}
cfg.ReportPeriodMs = DefaultConfigurableEventHarvestMs
cfg.Limits.TxnEvents = uintPtr(uint(maxTxnEvents))
cfg.Limits.CustomEvents = uintPtr(uint(maxCustomEvents))
cfg.Limits.CustomEvents = uintPtr(uint(MaxCustomEvents))
cfg.Limits.ErrorEvents = uintPtr(uint(MaxErrorEvents))
return cfg
}

// DefaultEventHarvestConfigWithDT is an extended version of DefaultEventHarvestConfig,
// with the addition that it takes into account distributed tracer span event harvest limits.
func DefaultEventHarvestConfigWithDT(maxTxnEvents int, dtEnabled bool, spanEventLimit int, maxCustomEvents int) EventHarvestConfig {
cfg := DefaultEventHarvestConfig(maxTxnEvents,maxCustomEvents)
func DefaultEventHarvestConfigWithDT(maxTxnEvents int, dtEnabled bool, spanEventLimit int) EventHarvestConfig {
cfg := DefaultEventHarvestConfig(maxTxnEvents)
if dtEnabled {
cfg.Limits.SpanEvents = uintPtr(uint(spanEventLimit))
}
Expand Down
8 changes: 4 additions & 4 deletions v3/newrelic/app_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/json"
"strings"
"time"

"github.com/newrelic/go-agent/v3/internal"
)

Expand Down Expand Up @@ -190,7 +191,9 @@ func (run *appRun) ptrErrorEvents() *uint { return run.Reply.EventData.Limits.E
func (run *appRun) ptrSpanEvents() *uint { return run.Reply.EventData.Limits.SpanEvents }

func (run *appRun) MaxTxnEvents() int { return run.limit(run.Config.maxTxnEvents(), run.ptrTxnEvents) }

func (run *appRun) MaxCustomEvents() int {
return run.limit(internal.MaxCustomEvents, run.ptrCustomEvents)
}
func (run *appRun) MaxErrorEvents() int {
return run.limit(internal.MaxErrorEvents, run.ptrErrorEvents)
}
Expand All @@ -201,9 +204,6 @@ func (run *appRun) MaxErrorEvents() int {
func (run *appRun) MaxSpanEvents() int {
return run.limit(run.Config.DistributedTracer.ReservoirLimit, run.ptrSpanEvents)
}
func (run *appRun) MaxCustomEvents() int {
return run.limit(run.Config.maxCustomEvents(), run.ptrCustomEvents)
}

func (run *appRun) limit(dflt int, field func() *uint) int {
if field() != nil {
Expand Down
16 changes: 2 additions & 14 deletions v3/newrelic/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ type Config struct {
// custom analytics events. High security mode overrides this
// setting.
Enabled bool
// MaxSamplesStored sets the desired maximum custom events stored
MaxSamplesStored int
}

// TransactionEvents controls the behavior of transaction analytics
// events.
TransactionEvents struct {
Expand Down Expand Up @@ -383,7 +382,6 @@ func defaultConfig() Config {
c.Enabled = true
c.Labels = make(map[string]string)
c.CustomInsightsEvents.Enabled = true
c.CustomInsightsEvents.MaxSamplesStored = internal.MaxCustomEvents
c.TransactionEvents.Enabled = true
c.TransactionEvents.Attributes.Enabled = true
c.TransactionEvents.MaxSamplesStored = internal.MaxTxnEvents
Expand Down Expand Up @@ -505,16 +503,6 @@ func (c Config) validateTraceObserverConfig() (*observerURL, error) {
}, nil
}

// maxCustomEvents returns the configured maximum number of Custom Events if it has been configured
// and is less than the default maximum; otherwise it returns the default max.
func (c Config) maxCustomEvents() int {
configured := c.CustomInsightsEvents.MaxSamplesStored
if configured < 0 || configured > internal.MaxCustomEvents {
return internal.MaxTxnEvents
}
return configured
}

// maxTxnEvents returns the configured maximum number of Transaction Events if it has been configured
// and is less than the default maximum; otherwise it returns the default max.
func (c Config) maxTxnEvents() int {
Expand Down Expand Up @@ -679,7 +667,7 @@ func configConnectJSONInternal(c Config, pid int, util *utilization.Data, e envi
Util: util,
SecurityPolicies: securityPolicies,
Metadata: metadata,
EventData: internal.DefaultEventHarvestConfigWithDT(c.maxTxnEvents(), c.DistributedTracer.Enabled, c.DistributedTracer.ReservoirLimit, c.maxCustomEvents()),
EventData: internal.DefaultEventHarvestConfigWithDT(c.maxTxnEvents(), c.DistributedTracer.Enabled, c.DistributedTracer.ReservoirLimit),
}})
}

Expand Down
8 changes: 0 additions & 8 deletions v3/newrelic/config_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ func ConfigDistributedTracerEnabled(enabled bool) ConfigOption {
return func(cfg *Config) { cfg.DistributedTracer.Enabled = enabled }
}

// ConfigCustomInsightsEventsMaxSamplesLimit alters the sample size allowing control
// of how many custom events are stored in an agent for a given harvest cycle.
// Alters the CustomInsightsEvents.MaxSamplesStored setting.
func ConfigCustomInsightsEventsMaxSamplesStored(limit int) ConfigOption {
return func(cfg *Config) { cfg.CustomInsightsEvents.MaxSamplesStored = limit}
}


// ConfigDistributedTracerReservoirLimit alters the sample reservoir size (maximum
// number of span events to be collected) for distributed tracing instead of
// using the built-in default.
Expand Down
5 changes: 1 addition & 4 deletions v3/newrelic/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ func TestCopyConfigReferenceFieldsPresent(t *testing.T) {
"Enabled":true
},
"CrossApplicationTracer":{"Enabled":false},
"CustomInsightsEvents":{
"Enabled":true,
"MaxSamplesStored":1000
},
"CustomInsightsEvents":{"Enabled":true},
"DatastoreTracer":{
"DatabaseNameReporting":{"Enabled":true},
"InstanceReporting":{"Enabled":true},
Expand Down

0 comments on commit fd44db5

Please sign in to comment.