Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[exporter/signalfx] reduce log level of attempts to divide by zero #12970

Merged
merged 1 commit into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion exporter/signalfxexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,14 @@ func newSignalFxExporter(

headers := buildHeaders(config)

converter, err := translation.NewMetricsConverter(logger, options.metricTranslator, config.ExcludeMetrics, config.IncludeMetrics, config.NonAlphanumericDimensionChars)
sampledLogger := translation.CreateSampledLogger(logger)
converter, err := translation.NewMetricsConverter(
sampledLogger,
options.metricTranslator,
config.ExcludeMetrics,
config.IncludeMetrics,
config.NonAlphanumericDimensionChars,
)
if err != nil {
return nil, fmt.Errorf("failed to create metric converter: %w", err)
}
Expand Down
6 changes: 3 additions & 3 deletions exporter/signalfxexporter/internal/translation/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ type datapointValidator struct {
}

func newDatapointValidator(logger *zap.Logger, nonAlphanumericDimChars string) *datapointValidator {
return &datapointValidator{logger: createSampledLogger(logger), nonAlphanumericDimChars: nonAlphanumericDimChars}
return &datapointValidator{logger: CreateSampledLogger(logger), nonAlphanumericDimChars: nonAlphanumericDimChars}
}

// sanitizeDataPoints sanitizes datapoints prior to dispatching them to the backend.
Expand Down Expand Up @@ -269,8 +269,8 @@ func (dpv *datapointValidator) isValidDimensionValue(value, name string) bool {
return true
}

// Copied from https://github.com/open-telemetry/opentelemetry-collector/blob/v0.26.0/exporter/exporterhelper/queued_retry.go#L108
func createSampledLogger(logger *zap.Logger) *zap.Logger {
// CreateSampledLogger was copied from https://github.com/open-telemetry/opentelemetry-collector/blob/v0.26.0/exporter/exporterhelper/queued_retry.go#L108
func CreateSampledLogger(logger *zap.Logger) *zap.Logger {
if logger.Core().Enabled(zapcore.DebugLevel) {
// Debugging is enabled. Don't do any sampling.
return logger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,10 @@ func calculateNewMetric(
}

if tr.Operator == MetricOperatorDivision && *v2 == 0 {
logger.Warn(
// We can get here if, for example, in the denominator we get multiple
// datapoints that have the same counter value, which will yield a delta of
// zero.
logger.Debug(
"calculate_new_metric: attempt to divide by zero, skipping",
zap.String("tr.Operand2Metric", tr.Operand2Metric),
zap.String("tr.MetricName", tr.MetricName),
Expand Down
16 changes: 16 additions & 0 deletions unreleased/divide-by-zero.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: signalfxreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: log attempts to divide by zero at the debug level

# One or more tracking issues related to the change
issues: [12969]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: