Skip to content

Commit

Permalink
[receiver/prometheus] update scope name for consistency (open-telemet…
Browse files Browse the repository at this point in the history
…ry#34589)

Update the scope name for telemetry produced by the prometheusreceiver
from otelcol/prometheusreceiver to
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver

Part of
open-telemetry/opentelemetry-collector#9494

---------

Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
codeboten authored and f7o committed Sep 12, 2024
1 parent 4df432f commit 1469469
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
27 changes: 27 additions & 0 deletions .chloggen/codeboten_update-scope-prometheusreceiver.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: breaking

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Update the scope name for telemetry produced by the prometheusreceiver from `otelcol/prometheusreceiver` to `github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver"

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

# (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: []
5 changes: 2 additions & 3 deletions receiver/prometheusreceiver/internal/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ import (
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus"
mdata "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver/internal/metadata"
)

const receiverName = "otelcol/prometheusreceiver"

type transaction struct {
isNew bool
trimSuffixes bool
Expand Down Expand Up @@ -320,7 +319,7 @@ func (t *transaction) getMetrics(resource pcommon.Resource) (pmetric.Metrics, er
// If metrics don't include otel_scope_name or otel_scope_version
// labels, use the receiver name and version.
if scope == emptyScopeID {
ils.Scope().SetName(receiverName)
ils.Scope().SetName(mdata.ScopeName)
ils.Scope().SetVersion(t.buildInfo.Version)
} else {
// Otherwise, use the scope that was provided with the metrics.
Expand Down
2 changes: 1 addition & 1 deletion receiver/prometheusreceiver/internal/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func testReceiverVersionAndNameAreAttached(t *testing.T, enableNativeHistograms
require.Equal(t, expectedResource, gotResource)

gotScope := mds[0].ResourceMetrics().At(0).ScopeMetrics().At(0).Scope()
require.Equal(t, receiverName, gotScope.Name())
require.Equal(t, "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver", gotScope.Name())
require.Equal(t, component.NewDefaultBuildInfo().Version, gotScope.Version())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ func verifyMultipleScopes(t *testing.T, td *testData, rms []pmetric.ResourceMetr
require.Equal(t, sms.At(0).Scope().Name(), "fake.scope.name")
require.Equal(t, sms.At(0).Scope().Version(), "v0.1.0")
require.Equal(t, sms.At(0).Scope().Attributes().Len(), 0)
require.Equal(t, sms.At(1).Scope().Name(), "otelcol/prometheusreceiver")
require.Equal(t, sms.At(1).Scope().Name(), "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver")
require.Equal(t, sms.At(1).Scope().Attributes().Len(), 0)
require.Equal(t, sms.At(2).Scope().Name(), "scope.with.attributes")
require.Equal(t, sms.At(2).Scope().Version(), "v1.5.0")
Expand Down

0 comments on commit 1469469

Please sign in to comment.