Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ac29886
Fix: Don't return error for metric translation in the prw exporter
rapphil Dec 11, 2023
883bd39
Merge branch 'main' into rapphil-prw-fix-metric-translation
rapphil Dec 12, 2023
f2a846b
Merge remote-tracking branch 'origin/main' into rapphil-prw-fix-metri…
rapphil Jan 11, 2024
baa04c6
Feat: Add telemetry for metric translation in the PRWE
rapphil Jan 12, 2024
691a7ec
Merge branch 'main' into rapphil-prw-fix-metric-translation
rapphil Jan 12, 2024
f897551
Merge branch 'main' into rapphil-prw-fix-metric-translation
rapphil Jan 12, 2024
b3a6ce6
Fix and simplify log line in case of failure to translated
rapphil Jan 12, 2024
a128f16
Simplify tests
rapphil Jan 12, 2024
84af853
Fix: fix based on code review
rapphil Jan 12, 2024
bffdd8c
Chore: Update metric name
rapphil Jan 12, 2024
faf0fdd
Fix: Fix go.mod
rapphil Jan 12, 2024
8bf5987
Merge remote-tracking branch 'origin/main' into rapphil-prw-fix-metri…
rapphil Jan 12, 2024
f60d68e
Chore: fix go.mod
rapphil Jan 12, 2024
5e953f5
Merge remote-tracking branch 'origin/main' into rapphil-prw-fix-metri…
rapphil Jan 30, 2024
0fad48b
Fix go.mod
rapphil Jan 30, 2024
bfdb63a
Merge branch 'main' into rapphil-prw-fix-metric-translation
rapphil Jan 30, 2024
c178c3b
Merge remote-tracking branch 'origin/main' into rapphil-prw-fix-metri…
rapphil Mar 1, 2024
2bc92ca
Fix merge conflicts
rapphil Mar 1, 2024
9e7ac06
Merge branch 'main' into rapphil-prw-fix-metric-translation
bryan-aguilar Mar 1, 2024
315996a
Merge branch 'main' into rapphil-prw-fix-metric-translation
bryan-aguilar Mar 13, 2024
e8ea846
make tidy
bryan-aguilar Mar 13, 2024
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
27 changes: 27 additions & 0 deletions .chloggen/prw_failure_translate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# 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: prometheusremotewriteexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Don't drop all metrics in a batch in case some of them cannot be translated from Otel to Prometheus.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [29729]

# (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:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
7 changes: 5 additions & 2 deletions exporter/prometheusremotewriteexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.uber.org/multierr"
"go.uber.org/zap"

prometheustranslator "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite"
Expand Down Expand Up @@ -134,15 +135,17 @@ func (prwe *prwExporter) PushMetrics(ctx context.Context, md pmetric.Metrics) er

tsMap, err := prometheusremotewrite.FromMetrics(md, prwe.exporterSettings)
if err != nil {
err = consumererror.NewPermanent(err)
prwe.settings.Logger.Warn("Failed to translate metrics: %s", zap.Error(err))
prwe.settings.Logger.Warn("Exporting remaining %s metrics.", zap.Int("converted", len(tsMap)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there known cases where OTEL -> Prometheus translation will fail? If so, this may be a noisy log line to emit at the warning level. Instead of logging at the warn level could we ensure that a metric is generated and emitted by the exporter that counts the amount of failed translations there are?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will not increase the amount of error messages given that in the present state the component is already producing an error message on failed translations: the error message due to permanent error logged by the exporter helper.

please refer to the following current error message for an example of failure:

2022-10-19T11:27:07.375+0800    error   exporterhelper/queued_retry.go:395      Exporting failed. The error is not retryable. Dropping data.    {"kind": "exporter", "data_type": "metrics", "name": "prometheusremotewrite", "error": "Permanent error: invalid temporality and type combination;

I'd rather put this new feature in a different PR.

}

var m []*prompb.MetricMetadata
if prwe.exporterSettings.SendMetadata {
m = prometheusremotewrite.OtelMetricsToMetadata(md, prwe.exporterSettings.AddMetricSuffixes)
}

// Call export even if a conversion error, since there may be points that were successfully converted.
return multierr.Combine(err, prwe.handleExport(ctx, tsMap, m))
return prwe.handleExport(ctx, tsMap, m)
}
}

Expand Down
17 changes: 12 additions & 5 deletions exporter/prometheusremotewriteexporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,11 @@ func Test_PushMetrics(t *testing.T) {

emptySummaryBatch := getMetricsFromMetricList(invalidMetrics[emptySummary])

// partial success (or partial failure) cases

partialSuccess1 := getMetricsFromMetricList(validMetrics1[validSum], validMetrics2[validSum],
validMetrics1[validIntGauge], validMetrics2[validIntGauge], invalidMetrics[emptyGauge])

// staleNaN cases
staleNaNHistogramBatch := getMetricsFromMetricList(staleNaNMetrics[staleNaNHistogram])
staleNaNEmptyHistogramBatch := getMetricsFromMetricList(staleNaNMetrics[staleNaNEmptyHistogram])
Expand Down Expand Up @@ -469,7 +474,6 @@ func Test_PushMetrics(t *testing.T) {
name: "invalid_type_case",
metrics: invalidTypeBatch,
httpResponseCode: http.StatusAccepted,
returnErr: true,
},
{
name: "intSum_case",
Expand Down Expand Up @@ -570,28 +574,31 @@ func Test_PushMetrics(t *testing.T) {
metrics: emptyDoubleGaugeBatch,
reqTestFunc: checkFunc,
httpResponseCode: http.StatusAccepted,
returnErr: true,
},
{
name: "emptyCumulativeSum_case",
metrics: emptyCumulativeSumBatch,
reqTestFunc: checkFunc,
httpResponseCode: http.StatusAccepted,
returnErr: true,
},
{
name: "emptyCumulativeHistogram_case",
metrics: emptyCumulativeHistogramBatch,
reqTestFunc: checkFunc,
httpResponseCode: http.StatusAccepted,
returnErr: true,
},
{
name: "emptySummary_case",
metrics: emptySummaryBatch,
reqTestFunc: checkFunc,
httpResponseCode: http.StatusAccepted,
returnErr: true,
},
{
name: "partialSuccess_case",
metrics: partialSuccess1,
reqTestFunc: checkFunc,
httpResponseCode: http.StatusAccepted,
expectedTimeSeries: 4,
},
{
name: "staleNaNIntGauge_case",
Expand Down