Skip to content

Commit

Permalink
Update otelcol.receiver.prometheus with v0.87.0 opentelemetry collect…
Browse files Browse the repository at this point in the history
…or contrib version (#5799)

* copy pasted code from opentelemetry, no manual change

* Update docs/sources/flow/release-notes.md

---------

Co-authored-by: Paulin Todev <[email protected]>
Co-authored-by: Clayton Cornell <[email protected]>
  • Loading branch information
3 people authored Dec 14, 2023
1 parent 5355f60 commit 59af364
Show file tree
Hide file tree
Showing 25 changed files with 1,533 additions and 470 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ Main (unreleased)

### Breaking changes

- `otelcol.receiver.prometheus` will drop all `otel_scope_info` metrics when converting them to OTLP. (@wildum)
- If the `otel_scope_info` metric has labels `otel_scope_name` and `otel_scope_version`,
their values will be used to set OTLP Instrumentation Scope name and version respectively.
- Labels of `otel_scope_info` metrics other than `otel_scope_name` and `otel_scope_version`
are added as scope attributes with the matching name and version.

- The `target` block in `prometheus.exporter.blackbox` requires a mandatory `name`
argument instead of a block label. (@hainenber)

Expand All @@ -37,6 +43,9 @@ Main (unreleased)

- `pyroscope.ebpf` support python on arm64 platforms. (@korniltsev)

- `otelcol.receiver.prometheus` does not drop histograms without buckets anymore. (@wildum)

- Added exemplars support to `otelcol.receiver.prometheus`. (@wildum)
- `mimir.rules.kubernetes` may now retry its startup on failure. (@hainenber)

- Added links between compatible components in the documentation to make it
Expand Down
28 changes: 10 additions & 18 deletions component/otelcol/receiver/prometheus/internal/appendable.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// SPDX-License-Identifier: Apache-2.0

package internal // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver/internal"

Expand All @@ -21,17 +10,18 @@ import (

"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/storage"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/receiver"
"go.opentelemetry.io/collector/receiver/receiverhelper"
)

// appendable translates Prometheus scraping diffs into OpenTelemetry format.

type appendable struct {
sink consumer.Metrics
metricAdjuster MetricsAdjuster
useStartTimeMetric bool
trimSuffixes bool
startTimeMetricRegex *regexp.Regexp
externalLabels labels.Labels

Expand All @@ -46,17 +36,18 @@ func NewAppendable(
gcInterval time.Duration,
useStartTimeMetric bool,
startTimeMetricRegex *regexp.Regexp,
receiverID component.ID,
externalLabels labels.Labels) (storage.Appendable, error) {
useCreatedMetric bool,
externalLabels labels.Labels,
trimSuffixes bool) (storage.Appendable, error) {

var metricAdjuster MetricsAdjuster
if !useStartTimeMetric {
metricAdjuster = NewInitialPointAdjuster(set.Logger, gcInterval)
metricAdjuster = NewInitialPointAdjuster(set.Logger, gcInterval, useCreatedMetric)
} else {
metricAdjuster = NewStartTimeMetricAdjuster(set.Logger, startTimeMetricRegex)
}

obsrecv, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{ReceiverID: receiverID, Transport: transport, ReceiverCreateSettings: set})
obsrecv, err := receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{ReceiverID: set.ID, Transport: transport, ReceiverCreateSettings: set})
if err != nil {
return nil, err
}
Expand All @@ -69,9 +60,10 @@ func NewAppendable(
startTimeMetricRegex: startTimeMetricRegex,
externalLabels: externalLabels,
obsrecv: obsrecv,
trimSuffixes: trimSuffixes,
}, nil
}

func (o *appendable) Appender(ctx context.Context) storage.Appender {
return newTransaction(ctx, o.metricAdjuster, o.sink, o.externalLabels, o.settings, o.obsrecv)
return newTransaction(ctx, o.metricAdjuster, o.sink, o.externalLabels, o.settings, o.obsrecv, o.trimSuffixes)
}
2 changes: 1 addition & 1 deletion component/otelcol/receiver/prometheus/internal/doc.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package internal is a near copy of
// https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/v0.61.0/receiver/prometheusreceiver/internal
// https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/v0.87.0/receiver/prometheusreceiver/internal
// A copy was made because the upstream package is internal. If it is ever made
// public, our copy can be removed.
//
Expand Down
13 changes: 1 addition & 12 deletions component/otelcol/receiver/prometheus/internal/logger.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// SPDX-License-Identifier: Apache-2.0

package internal // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver/internal"

Expand Down
13 changes: 1 addition & 12 deletions component/otelcol/receiver/prometheus/internal/logger_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// SPDX-License-Identifier: Apache-2.0

package internal

Expand Down
13 changes: 1 addition & 12 deletions component/otelcol/receiver/prometheus/internal/metadata.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// SPDX-License-Identifier: Apache-2.0

package internal // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver/internal"

Expand Down
Loading

0 comments on commit 59af364

Please sign in to comment.