Skip to content

Commit

Permalink
Merge branch 'release-v0.37' into backport-5704-to-release-v0.37
Browse files Browse the repository at this point in the history
  • Loading branch information
clayton-cornell authored Nov 8, 2023
2 parents f24542c + 89ded9f commit 25cecb3
Show file tree
Hide file tree
Showing 20 changed files with 600 additions and 44 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ This document contains a historical list of changes between releases. Only
changes that impact end-user behavior are listed; changes to documentation or
internal API changes are not present.

v0.37.4 (2023-11-06)
-----------------

### Enhancements

- Added an `add_metric_suffixes` option to `otelcol.exporter.prometheus` in flow mode,
which configures whether to add type and unit suffixes to metrics names. (@mar4uk)

### Bugfixes

- Fix a bug where reloading the configuration of a `loki.write` component lead
to a panic. (@tpaschalis)

v0.37.3 (2023-10-26)
-----------------

Expand All @@ -30,7 +43,7 @@ v0.37.3 (2023-10-26)
- `otelcol.receiver.kafka` has a new `header_extraction` block to extract headers from Kafka records.
- `otelcol.receiver.kafka` has a new `version` argument to change the version of
the SASL Protocol for SASL authentication.

v0.37.2 (2023-10-16)
-----------------

Expand Down
22 changes: 16 additions & 6 deletions component/common/loki/wal/watcher_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,23 @@ func NewWatcherMetrics(reg prometheus.Registerer) *WatcherMetrics {
}

if reg != nil {
reg.MustRegister(m.recordsRead)
reg.MustRegister(m.recordDecodeFails)
reg.MustRegister(m.droppedWriteNotifications)
reg.MustRegister(m.segmentRead)
reg.MustRegister(m.currentSegment)
reg.MustRegister(m.watchersRunning)
m.recordsRead = mustRegisterOrGet(reg, m.recordsRead).(*prometheus.CounterVec)
m.recordDecodeFails = mustRegisterOrGet(reg, m.recordDecodeFails).(*prometheus.CounterVec)
m.droppedWriteNotifications = mustRegisterOrGet(reg, m.droppedWriteNotifications).(*prometheus.CounterVec)
m.segmentRead = mustRegisterOrGet(reg, m.segmentRead).(*prometheus.CounterVec)
m.currentSegment = mustRegisterOrGet(reg, m.currentSegment).(*prometheus.GaugeVec)
m.watchersRunning = mustRegisterOrGet(reg, m.watchersRunning).(*prometheus.GaugeVec)
}

return m
}

func mustRegisterOrGet(reg prometheus.Registerer, c prometheus.Collector) prometheus.Collector {
if err := reg.Register(c); err != nil {
if are, ok := err.(prometheus.AlreadyRegisteredError); ok {
return are.ExistingCollector
}
panic(err)
}
return c
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ type Options struct {
// IncludeScopeLabels includes the otel_scope_name and otel_scope_version
// labels from the scope in the metrics.
IncludeScopeLabels bool
// AddMetricSuffixes controls whether suffixes are added to metric names. Defaults to true.
AddMetricSuffixes bool
}

var _ consumer.Metrics = (*Converter)(nil)
Expand Down Expand Up @@ -286,8 +288,7 @@ func (conv *Converter) consumeMetric(app storage.Appender, memResource *memorySe
}

func (conv *Converter) consumeGauge(app storage.Appender, memResource *memorySeries, memScope *memorySeries, m pmetric.Metric) {
// TODO: should we make the param addMetricSuffixes configurable? For now we set the default value (true) to keep the same behavior as before
metricName := prometheus.BuildCompliantName(m, "", true)
metricName := prometheus.BuildCompliantName(m, "", conv.opts.AddMetricSuffixes)

metricMD := conv.createOrUpdateMetadata(metricName, metadata.Metadata{
Type: textparse.MetricTypeGauge,
Expand Down Expand Up @@ -389,7 +390,7 @@ func getNumberDataPointValue(dp pmetric.NumberDataPoint) float64 {
}

func (conv *Converter) consumeSum(app storage.Appender, memResource *memorySeries, memScope *memorySeries, m pmetric.Metric) {
metricName := prometheus.BuildCompliantName(m, "", true)
metricName := prometheus.BuildCompliantName(m, "", conv.opts.AddMetricSuffixes)

// Excerpt from the spec:
//
Expand Down Expand Up @@ -447,7 +448,7 @@ func (conv *Converter) consumeSum(app storage.Appender, memResource *memorySerie
}

func (conv *Converter) consumeHistogram(app storage.Appender, memResource *memorySeries, memScope *memorySeries, m pmetric.Metric) {
metricName := prometheus.BuildCompliantName(m, "", true)
metricName := prometheus.BuildCompliantName(m, "", conv.opts.AddMetricSuffixes)

if m.Histogram().AggregationTemporality() != pmetric.AggregationTemporalityCumulative {
// Drop non-cumulative histograms for now, which is permitted by the spec.
Expand Down Expand Up @@ -606,7 +607,7 @@ func (conv *Converter) convertExemplar(otelExemplar pmetric.Exemplar, ts time.Ti
}

func (conv *Converter) consumeSummary(app storage.Appender, memResource *memorySeries, memScope *memorySeries, m pmetric.Metric) {
metricName := prometheus.BuildCompliantName(m, "", true)
metricName := prometheus.BuildCompliantName(m, "", conv.opts.AddMetricSuffixes)

metricMD := conv.createOrUpdateMetadata(metricName, metadata.Metadata{
Type: textparse.MetricTypeSummary,
Expand Down
Loading

0 comments on commit 25cecb3

Please sign in to comment.