diff --git a/.chloggen/mongodbreceiver-duplicate-attribute-24972.yaml b/.chloggen/mongodbreceiver-duplicate-attribute-24972.yaml new file mode 100755 index 000000000000..3da1b89d8f2e --- /dev/null +++ b/.chloggen/mongodbreceiver-duplicate-attribute-24972.yaml @@ -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: mongodbreceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "add `receiver.mongodb.removeDatabaseAttr` Alpha feature gate to remove duplicate database name attribute" + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [24972] + +# (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] diff --git a/receiver/mongodbreceiver/README.md b/receiver/mongodbreceiver/README.md index b8cf83199cb1..542aac9163dd 100644 --- a/receiver/mongodbreceiver/README.md +++ b/receiver/mongodbreceiver/README.md @@ -76,3 +76,15 @@ The following metric are available with versions: - `mongodb.index.access.count` >= 4.0 Details about the metrics produced by this receiver can be found in [metadata.yaml](./metadata.yaml) + +## Feature gate configurations +See the [Collector feature gates](https://github.com/open-telemetry/opentelemetry-collector/blob/main/featuregate/README.md#collector-feature-gates) for an overview of feature gates in the collector. + +**ALPHA**: `receiver.mongodb.removeDatabaseAttr` + +The feature gate `receiver.mongodb.removeDatabaseAttr` once enabled will remove database name attribute, +because both resource and datapoint attributes are called database. + +This feature gate will eventually be enabled by default, and eventually the old implementation will be removed. It aims +to give users time to migrate to the new implementation. The target release for this featuregate to be enabled by default +is 0.94.0. diff --git a/receiver/mongodbreceiver/documentation.md b/receiver/mongodbreceiver/documentation.md index 8dec702e7645..57a89bd1da2e 100644 --- a/receiver/mongodbreceiver/documentation.md +++ b/receiver/mongodbreceiver/documentation.md @@ -34,12 +34,6 @@ The number of collections. | ---- | ----------- | ---------- | ----------------------- | --------- | | {collections} | Sum | Int | Cumulative | false | -#### Attributes - -| Name | Description | Values | -| ---- | ----------- | ------ | -| database | The name of a database. | Any Str | - ### mongodb.connection.count The number of connections. @@ -52,7 +46,6 @@ The number of connections. | Name | Description | Values | | ---- | ----------- | ------ | -| database | The name of a database. | Any Str | | type | The status of the connection. | Str: ``active``, ``available``, ``current`` | ### mongodb.cursor.count @@ -79,12 +72,6 @@ The size of the collection. Data compression does not affect this value. | ---- | ----------- | ---------- | ----------------------- | --------- | | By | Sum | Int | Cumulative | false | -#### Attributes - -| Name | Description | Values | -| ---- | ----------- | ------ | -| database | The name of a database. | Any Str | - ### mongodb.database.count The number of existing databases. @@ -105,7 +92,6 @@ The number of document operations executed. | Name | Description | Values | | ---- | ----------- | ------ | -| database | The name of a database. | Any Str | | operation | The MongoDB operation being counted. | Str: ``insert``, ``query``, ``update``, ``delete``, ``getmore``, ``command`` | ### mongodb.extent.count @@ -116,12 +102,6 @@ The number of extents. | ---- | ----------- | ---------- | ----------------------- | --------- | | {extents} | Sum | Int | Cumulative | false | -#### Attributes - -| Name | Description | Values | -| ---- | ----------- | ------ | -| database | The name of a database. | Any Str | - ### mongodb.global_lock.time The time the global lock has been held. @@ -142,7 +122,6 @@ The number of times an index has been accessed. | Name | Description | Values | | ---- | ----------- | ------ | -| database | The name of a database. | Any Str | | collection | The name of a collection. | Any Str | ### mongodb.index.count @@ -153,12 +132,6 @@ The number of indexes. | ---- | ----------- | ---------- | ----------------------- | --------- | | {indexes} | Sum | Int | Cumulative | false | -#### Attributes - -| Name | Description | Values | -| ---- | ----------- | ------ | -| database | The name of a database. | Any Str | - ### mongodb.index.size Sum of the space allocated to all indexes in the database, including free index space. @@ -167,12 +140,6 @@ Sum of the space allocated to all indexes in the database, including free index | ---- | ----------- | ---------- | ----------------------- | --------- | | By | Sum | Int | Cumulative | false | -#### Attributes - -| Name | Description | Values | -| ---- | ----------- | ------ | -| database | The name of a database. | Any Str | - ### mongodb.memory.usage The amount of memory used. @@ -185,7 +152,6 @@ The amount of memory used. | Name | Description | Values | | ---- | ----------- | ------ | -| database | The name of a database. | Any Str | | type | The type of memory used. | Str: ``resident``, ``virtual`` | ### mongodb.network.io.receive @@ -220,12 +186,6 @@ The number of objects. | ---- | ----------- | ---------- | ----------------------- | --------- | | {objects} | Sum | Int | Cumulative | false | -#### Attributes - -| Name | Description | Values | -| ---- | ----------- | ------ | -| database | The name of a database. | Any Str | - ### mongodb.operation.count The number of operations executed. @@ -272,12 +232,6 @@ If collection data is compressed it reflects the compressed size. | ---- | ----------- | ---------- | ----------------------- | --------- | | By | Sum | Int | Cumulative | true | -#### Attributes - -| Name | Description | Values | -| ---- | ----------- | ------ | -| database | The name of a database. | Any Str | - ## Optional Metrics The following metrics are not emitted by default. Each of them can be enabled by applying the following configuration: @@ -310,7 +264,6 @@ Number of times the lock was acquired in the specified mode. | Name | Description | Values | | ---- | ----------- | ------ | -| database | The name of a database. | Any Str | | lock_type | The Resource over which the Lock controls access | Str: ``parallel_batch_write_mode``, ``replication_state_transition``, ``global``, ``database``, ``collection``, ``mutex``, ``metadata``, ``oplog`` | | lock_mode | The mode of Lock which denotes the degree of access | Str: ``shared``, ``exclusive``, ``intent_shared``, ``intent_exclusive`` | @@ -326,7 +279,6 @@ Cumulative wait time for the lock acquisitions. | Name | Description | Values | | ---- | ----------- | ------ | -| database | The name of a database. | Any Str | | lock_type | The Resource over which the Lock controls access | Str: ``parallel_batch_write_mode``, ``replication_state_transition``, ``global``, ``database``, ``collection``, ``mutex``, ``metadata``, ``oplog`` | | lock_mode | The mode of Lock which denotes the degree of access | Str: ``shared``, ``exclusive``, ``intent_shared``, ``intent_exclusive`` | @@ -342,7 +294,6 @@ Number of times the lock acquisitions encountered waits because the locks were h | Name | Description | Values | | ---- | ----------- | ------ | -| database | The name of a database. | Any Str | | lock_type | The Resource over which the Lock controls access | Str: ``parallel_batch_write_mode``, ``replication_state_transition``, ``global``, ``database``, ``collection``, ``mutex``, ``metadata``, ``oplog`` | | lock_mode | The mode of Lock which denotes the degree of access | Str: ``shared``, ``exclusive``, ``intent_shared``, ``intent_exclusive`` | @@ -358,7 +309,6 @@ Number of times the lock acquisitions encountered deadlocks. | Name | Description | Values | | ---- | ----------- | ------ | -| database | The name of a database. | Any Str | | lock_type | The Resource over which the Lock controls access | Str: ``parallel_batch_write_mode``, ``replication_state_transition``, ``global``, ``database``, ``collection``, ``mutex``, ``metadata``, ``oplog`` | | lock_mode | The mode of Lock which denotes the degree of access | Str: ``shared``, ``exclusive``, ``intent_shared``, ``intent_exclusive`` | diff --git a/receiver/mongodbreceiver/go.mod b/receiver/mongodbreceiver/go.mod index 60c26a0fa411..36812d5b9c29 100644 --- a/receiver/mongodbreceiver/go.mod +++ b/receiver/mongodbreceiver/go.mod @@ -17,6 +17,7 @@ require ( go.opentelemetry.io/collector/config/configtls v0.89.0 go.opentelemetry.io/collector/confmap v0.89.0 go.opentelemetry.io/collector/consumer v0.89.0 + go.opentelemetry.io/collector/featuregate v1.0.0-rcv0018 go.opentelemetry.io/collector/pdata v1.0.0-rcv0018 go.opentelemetry.io/collector/receiver v0.89.0 go.uber.org/multierr v1.11.0 @@ -82,7 +83,6 @@ require ( go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/collector v0.89.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.89.0 // indirect - go.opentelemetry.io/collector/featuregate v1.0.0-rcv0018 // indirect go.opentelemetry.io/otel v1.21.0 // indirect go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/trace v1.21.0 // indirect diff --git a/receiver/mongodbreceiver/integration_test.go b/receiver/mongodbreceiver/integration_test.go index d23013cd64f3..51abdd4fb90d 100644 --- a/receiver/mongodbreceiver/integration_test.go +++ b/receiver/mongodbreceiver/integration_test.go @@ -12,10 +12,12 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config/confignet" + "go.opentelemetry.io/collector/featuregate" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/scraperinttest" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/pmetrictest" @@ -24,6 +26,10 @@ import ( const mongoPort = "27017" func TestIntegration(t *testing.T) { + // Simulate enable removeDatabaseAttrFeatureGate + err := featuregate.GlobalRegistry().Set(removeDatabaseAttrID, true) + require.NoError(t, err) + t.Run("4.0", integrationTest("4_0", []string{"/setup.sh"}, func(*Config) {})) t.Run("5.0", integrationTest("5_0", []string{"/setup.sh"}, func(*Config) {})) t.Run("4.4lpu", integrationTest("4_4lpu", []string{"/lpu.sh"}, func(cfg *Config) { diff --git a/receiver/mongodbreceiver/internal/metadata/generated_metrics.go b/receiver/mongodbreceiver/internal/metadata/generated_metrics.go index f4f4df1ca183..9e9bb67ec6ca 100644 --- a/receiver/mongodbreceiver/internal/metadata/generated_metrics.go +++ b/receiver/mongodbreceiver/internal/metadata/generated_metrics.go @@ -316,10 +316,9 @@ func (m *metricMongodbCollectionCount) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) - m.data.Sum().DataPoints().EnsureCapacity(m.capacity) } -func (m *metricMongodbCollectionCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string) { +func (m *metricMongodbCollectionCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } @@ -327,7 +326,6 @@ func (m *metricMongodbCollectionCount) recordDataPoint(start pcommon.Timestamp, dp.SetStartTimestamp(start) dp.SetTimestamp(ts) dp.SetIntValue(val) - dp.Attributes().PutStr("database", databaseAttributeValue) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -372,7 +370,7 @@ func (m *metricMongodbConnectionCount) init() { m.data.Sum().DataPoints().EnsureCapacity(m.capacity) } -func (m *metricMongodbConnectionCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string, connectionTypeAttributeValue string) { +func (m *metricMongodbConnectionCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, connectionTypeAttributeValue string) { if !m.config.Enabled { return } @@ -380,7 +378,6 @@ func (m *metricMongodbConnectionCount) recordDataPoint(start pcommon.Timestamp, dp.SetStartTimestamp(start) dp.SetTimestamp(ts) dp.SetIntValue(val) - dp.Attributes().PutStr("database", databaseAttributeValue) dp.Attributes().PutStr("type", connectionTypeAttributeValue) } @@ -525,10 +522,9 @@ func (m *metricMongodbDataSize) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) - m.data.Sum().DataPoints().EnsureCapacity(m.capacity) } -func (m *metricMongodbDataSize) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string) { +func (m *metricMongodbDataSize) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } @@ -536,7 +532,6 @@ func (m *metricMongodbDataSize) recordDataPoint(start pcommon.Timestamp, ts pcom dp.SetStartTimestamp(start) dp.SetTimestamp(ts) dp.SetIntValue(val) - dp.Attributes().PutStr("database", databaseAttributeValue) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -632,7 +627,7 @@ func (m *metricMongodbDocumentOperationCount) init() { m.data.Sum().DataPoints().EnsureCapacity(m.capacity) } -func (m *metricMongodbDocumentOperationCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string, operationAttributeValue string) { +func (m *metricMongodbDocumentOperationCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, operationAttributeValue string) { if !m.config.Enabled { return } @@ -640,7 +635,6 @@ func (m *metricMongodbDocumentOperationCount) recordDataPoint(start pcommon.Time dp.SetStartTimestamp(start) dp.SetTimestamp(ts) dp.SetIntValue(val) - dp.Attributes().PutStr("database", databaseAttributeValue) dp.Attributes().PutStr("operation", operationAttributeValue) } @@ -683,10 +677,9 @@ func (m *metricMongodbExtentCount) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) - m.data.Sum().DataPoints().EnsureCapacity(m.capacity) } -func (m *metricMongodbExtentCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string) { +func (m *metricMongodbExtentCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } @@ -694,7 +687,6 @@ func (m *metricMongodbExtentCount) recordDataPoint(start pcommon.Timestamp, ts p dp.SetStartTimestamp(start) dp.SetTimestamp(ts) dp.SetIntValue(val) - dp.Attributes().PutStr("database", databaseAttributeValue) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -839,7 +831,7 @@ func (m *metricMongodbIndexAccessCount) init() { m.data.Sum().DataPoints().EnsureCapacity(m.capacity) } -func (m *metricMongodbIndexAccessCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string, collectionAttributeValue string) { +func (m *metricMongodbIndexAccessCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, collectionAttributeValue string) { if !m.config.Enabled { return } @@ -847,7 +839,6 @@ func (m *metricMongodbIndexAccessCount) recordDataPoint(start pcommon.Timestamp, dp.SetStartTimestamp(start) dp.SetTimestamp(ts) dp.SetIntValue(val) - dp.Attributes().PutStr("database", databaseAttributeValue) dp.Attributes().PutStr("collection", collectionAttributeValue) } @@ -890,10 +881,9 @@ func (m *metricMongodbIndexCount) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) - m.data.Sum().DataPoints().EnsureCapacity(m.capacity) } -func (m *metricMongodbIndexCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string) { +func (m *metricMongodbIndexCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } @@ -901,7 +891,6 @@ func (m *metricMongodbIndexCount) recordDataPoint(start pcommon.Timestamp, ts pc dp.SetStartTimestamp(start) dp.SetTimestamp(ts) dp.SetIntValue(val) - dp.Attributes().PutStr("database", databaseAttributeValue) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -943,10 +932,9 @@ func (m *metricMongodbIndexSize) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) - m.data.Sum().DataPoints().EnsureCapacity(m.capacity) } -func (m *metricMongodbIndexSize) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string) { +func (m *metricMongodbIndexSize) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } @@ -954,7 +942,6 @@ func (m *metricMongodbIndexSize) recordDataPoint(start pcommon.Timestamp, ts pco dp.SetStartTimestamp(start) dp.SetTimestamp(ts) dp.SetIntValue(val) - dp.Attributes().PutStr("database", databaseAttributeValue) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -999,7 +986,7 @@ func (m *metricMongodbLockAcquireCount) init() { m.data.Sum().DataPoints().EnsureCapacity(m.capacity) } -func (m *metricMongodbLockAcquireCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string, lockTypeAttributeValue string, lockModeAttributeValue string) { +func (m *metricMongodbLockAcquireCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, lockTypeAttributeValue string, lockModeAttributeValue string) { if !m.config.Enabled { return } @@ -1007,7 +994,6 @@ func (m *metricMongodbLockAcquireCount) recordDataPoint(start pcommon.Timestamp, dp.SetStartTimestamp(start) dp.SetTimestamp(ts) dp.SetIntValue(val) - dp.Attributes().PutStr("database", databaseAttributeValue) dp.Attributes().PutStr("lock_type", lockTypeAttributeValue) dp.Attributes().PutStr("lock_mode", lockModeAttributeValue) } @@ -1054,7 +1040,7 @@ func (m *metricMongodbLockAcquireTime) init() { m.data.Sum().DataPoints().EnsureCapacity(m.capacity) } -func (m *metricMongodbLockAcquireTime) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string, lockTypeAttributeValue string, lockModeAttributeValue string) { +func (m *metricMongodbLockAcquireTime) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, lockTypeAttributeValue string, lockModeAttributeValue string) { if !m.config.Enabled { return } @@ -1062,7 +1048,6 @@ func (m *metricMongodbLockAcquireTime) recordDataPoint(start pcommon.Timestamp, dp.SetStartTimestamp(start) dp.SetTimestamp(ts) dp.SetIntValue(val) - dp.Attributes().PutStr("database", databaseAttributeValue) dp.Attributes().PutStr("lock_type", lockTypeAttributeValue) dp.Attributes().PutStr("lock_mode", lockModeAttributeValue) } @@ -1109,7 +1094,7 @@ func (m *metricMongodbLockAcquireWaitCount) init() { m.data.Sum().DataPoints().EnsureCapacity(m.capacity) } -func (m *metricMongodbLockAcquireWaitCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string, lockTypeAttributeValue string, lockModeAttributeValue string) { +func (m *metricMongodbLockAcquireWaitCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, lockTypeAttributeValue string, lockModeAttributeValue string) { if !m.config.Enabled { return } @@ -1117,7 +1102,6 @@ func (m *metricMongodbLockAcquireWaitCount) recordDataPoint(start pcommon.Timest dp.SetStartTimestamp(start) dp.SetTimestamp(ts) dp.SetIntValue(val) - dp.Attributes().PutStr("database", databaseAttributeValue) dp.Attributes().PutStr("lock_type", lockTypeAttributeValue) dp.Attributes().PutStr("lock_mode", lockModeAttributeValue) } @@ -1164,7 +1148,7 @@ func (m *metricMongodbLockDeadlockCount) init() { m.data.Sum().DataPoints().EnsureCapacity(m.capacity) } -func (m *metricMongodbLockDeadlockCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string, lockTypeAttributeValue string, lockModeAttributeValue string) { +func (m *metricMongodbLockDeadlockCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, lockTypeAttributeValue string, lockModeAttributeValue string) { if !m.config.Enabled { return } @@ -1172,7 +1156,6 @@ func (m *metricMongodbLockDeadlockCount) recordDataPoint(start pcommon.Timestamp dp.SetStartTimestamp(start) dp.SetTimestamp(ts) dp.SetIntValue(val) - dp.Attributes().PutStr("database", databaseAttributeValue) dp.Attributes().PutStr("lock_type", lockTypeAttributeValue) dp.Attributes().PutStr("lock_mode", lockModeAttributeValue) } @@ -1219,7 +1202,7 @@ func (m *metricMongodbMemoryUsage) init() { m.data.Sum().DataPoints().EnsureCapacity(m.capacity) } -func (m *metricMongodbMemoryUsage) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string, memoryTypeAttributeValue string) { +func (m *metricMongodbMemoryUsage) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, memoryTypeAttributeValue string) { if !m.config.Enabled { return } @@ -1227,7 +1210,6 @@ func (m *metricMongodbMemoryUsage) recordDataPoint(start pcommon.Timestamp, ts p dp.SetStartTimestamp(start) dp.SetTimestamp(ts) dp.SetIntValue(val) - dp.Attributes().PutStr("database", databaseAttributeValue) dp.Attributes().PutStr("type", memoryTypeAttributeValue) } @@ -1423,10 +1405,9 @@ func (m *metricMongodbObjectCount) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) - m.data.Sum().DataPoints().EnsureCapacity(m.capacity) } -func (m *metricMongodbObjectCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string) { +func (m *metricMongodbObjectCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } @@ -1434,7 +1415,6 @@ func (m *metricMongodbObjectCount) recordDataPoint(start pcommon.Timestamp, ts p dp.SetStartTimestamp(start) dp.SetTimestamp(ts) dp.SetIntValue(val) - dp.Attributes().PutStr("database", databaseAttributeValue) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1737,10 +1717,9 @@ func (m *metricMongodbStorageSize) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(true) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) - m.data.Sum().DataPoints().EnsureCapacity(m.capacity) } -func (m *metricMongodbStorageSize) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string) { +func (m *metricMongodbStorageSize) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } @@ -1748,7 +1727,6 @@ func (m *metricMongodbStorageSize) recordDataPoint(start pcommon.Timestamp, ts p dp.SetStartTimestamp(start) dp.SetTimestamp(ts) dp.SetIntValue(val) - dp.Attributes().PutStr("database", databaseAttributeValue) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2030,13 +2008,13 @@ func (mb *MetricsBuilder) RecordMongodbCacheOperationsDataPoint(ts pcommon.Times } // RecordMongodbCollectionCountDataPoint adds a data point to mongodb.collection.count metric. -func (mb *MetricsBuilder) RecordMongodbCollectionCountDataPoint(ts pcommon.Timestamp, val int64, databaseAttributeValue string) { - mb.metricMongodbCollectionCount.recordDataPoint(mb.startTime, ts, val, databaseAttributeValue) +func (mb *MetricsBuilder) RecordMongodbCollectionCountDataPoint(ts pcommon.Timestamp, val int64) { + mb.metricMongodbCollectionCount.recordDataPoint(mb.startTime, ts, val) } // RecordMongodbConnectionCountDataPoint adds a data point to mongodb.connection.count metric. -func (mb *MetricsBuilder) RecordMongodbConnectionCountDataPoint(ts pcommon.Timestamp, val int64, databaseAttributeValue string, connectionTypeAttributeValue AttributeConnectionType) { - mb.metricMongodbConnectionCount.recordDataPoint(mb.startTime, ts, val, databaseAttributeValue, connectionTypeAttributeValue.String()) +func (mb *MetricsBuilder) RecordMongodbConnectionCountDataPoint(ts pcommon.Timestamp, val int64, connectionTypeAttributeValue AttributeConnectionType) { + mb.metricMongodbConnectionCount.recordDataPoint(mb.startTime, ts, val, connectionTypeAttributeValue.String()) } // RecordMongodbCursorCountDataPoint adds a data point to mongodb.cursor.count metric. @@ -2050,8 +2028,8 @@ func (mb *MetricsBuilder) RecordMongodbCursorTimeoutCountDataPoint(ts pcommon.Ti } // RecordMongodbDataSizeDataPoint adds a data point to mongodb.data.size metric. -func (mb *MetricsBuilder) RecordMongodbDataSizeDataPoint(ts pcommon.Timestamp, val int64, databaseAttributeValue string) { - mb.metricMongodbDataSize.recordDataPoint(mb.startTime, ts, val, databaseAttributeValue) +func (mb *MetricsBuilder) RecordMongodbDataSizeDataPoint(ts pcommon.Timestamp, val int64) { + mb.metricMongodbDataSize.recordDataPoint(mb.startTime, ts, val) } // RecordMongodbDatabaseCountDataPoint adds a data point to mongodb.database.count metric. @@ -2060,13 +2038,13 @@ func (mb *MetricsBuilder) RecordMongodbDatabaseCountDataPoint(ts pcommon.Timesta } // RecordMongodbDocumentOperationCountDataPoint adds a data point to mongodb.document.operation.count metric. -func (mb *MetricsBuilder) RecordMongodbDocumentOperationCountDataPoint(ts pcommon.Timestamp, val int64, databaseAttributeValue string, operationAttributeValue AttributeOperation) { - mb.metricMongodbDocumentOperationCount.recordDataPoint(mb.startTime, ts, val, databaseAttributeValue, operationAttributeValue.String()) +func (mb *MetricsBuilder) RecordMongodbDocumentOperationCountDataPoint(ts pcommon.Timestamp, val int64, operationAttributeValue AttributeOperation) { + mb.metricMongodbDocumentOperationCount.recordDataPoint(mb.startTime, ts, val, operationAttributeValue.String()) } // RecordMongodbExtentCountDataPoint adds a data point to mongodb.extent.count metric. -func (mb *MetricsBuilder) RecordMongodbExtentCountDataPoint(ts pcommon.Timestamp, val int64, databaseAttributeValue string) { - mb.metricMongodbExtentCount.recordDataPoint(mb.startTime, ts, val, databaseAttributeValue) +func (mb *MetricsBuilder) RecordMongodbExtentCountDataPoint(ts pcommon.Timestamp, val int64) { + mb.metricMongodbExtentCount.recordDataPoint(mb.startTime, ts, val) } // RecordMongodbGlobalLockTimeDataPoint adds a data point to mongodb.global_lock.time metric. @@ -2080,43 +2058,43 @@ func (mb *MetricsBuilder) RecordMongodbHealthDataPoint(ts pcommon.Timestamp, val } // RecordMongodbIndexAccessCountDataPoint adds a data point to mongodb.index.access.count metric. -func (mb *MetricsBuilder) RecordMongodbIndexAccessCountDataPoint(ts pcommon.Timestamp, val int64, databaseAttributeValue string, collectionAttributeValue string) { - mb.metricMongodbIndexAccessCount.recordDataPoint(mb.startTime, ts, val, databaseAttributeValue, collectionAttributeValue) +func (mb *MetricsBuilder) RecordMongodbIndexAccessCountDataPoint(ts pcommon.Timestamp, val int64, collectionAttributeValue string) { + mb.metricMongodbIndexAccessCount.recordDataPoint(mb.startTime, ts, val, collectionAttributeValue) } // RecordMongodbIndexCountDataPoint adds a data point to mongodb.index.count metric. -func (mb *MetricsBuilder) RecordMongodbIndexCountDataPoint(ts pcommon.Timestamp, val int64, databaseAttributeValue string) { - mb.metricMongodbIndexCount.recordDataPoint(mb.startTime, ts, val, databaseAttributeValue) +func (mb *MetricsBuilder) RecordMongodbIndexCountDataPoint(ts pcommon.Timestamp, val int64) { + mb.metricMongodbIndexCount.recordDataPoint(mb.startTime, ts, val) } // RecordMongodbIndexSizeDataPoint adds a data point to mongodb.index.size metric. -func (mb *MetricsBuilder) RecordMongodbIndexSizeDataPoint(ts pcommon.Timestamp, val int64, databaseAttributeValue string) { - mb.metricMongodbIndexSize.recordDataPoint(mb.startTime, ts, val, databaseAttributeValue) +func (mb *MetricsBuilder) RecordMongodbIndexSizeDataPoint(ts pcommon.Timestamp, val int64) { + mb.metricMongodbIndexSize.recordDataPoint(mb.startTime, ts, val) } // RecordMongodbLockAcquireCountDataPoint adds a data point to mongodb.lock.acquire.count metric. -func (mb *MetricsBuilder) RecordMongodbLockAcquireCountDataPoint(ts pcommon.Timestamp, val int64, databaseAttributeValue string, lockTypeAttributeValue AttributeLockType, lockModeAttributeValue AttributeLockMode) { - mb.metricMongodbLockAcquireCount.recordDataPoint(mb.startTime, ts, val, databaseAttributeValue, lockTypeAttributeValue.String(), lockModeAttributeValue.String()) +func (mb *MetricsBuilder) RecordMongodbLockAcquireCountDataPoint(ts pcommon.Timestamp, val int64, lockTypeAttributeValue AttributeLockType, lockModeAttributeValue AttributeLockMode) { + mb.metricMongodbLockAcquireCount.recordDataPoint(mb.startTime, ts, val, lockTypeAttributeValue.String(), lockModeAttributeValue.String()) } // RecordMongodbLockAcquireTimeDataPoint adds a data point to mongodb.lock.acquire.time metric. -func (mb *MetricsBuilder) RecordMongodbLockAcquireTimeDataPoint(ts pcommon.Timestamp, val int64, databaseAttributeValue string, lockTypeAttributeValue AttributeLockType, lockModeAttributeValue AttributeLockMode) { - mb.metricMongodbLockAcquireTime.recordDataPoint(mb.startTime, ts, val, databaseAttributeValue, lockTypeAttributeValue.String(), lockModeAttributeValue.String()) +func (mb *MetricsBuilder) RecordMongodbLockAcquireTimeDataPoint(ts pcommon.Timestamp, val int64, lockTypeAttributeValue AttributeLockType, lockModeAttributeValue AttributeLockMode) { + mb.metricMongodbLockAcquireTime.recordDataPoint(mb.startTime, ts, val, lockTypeAttributeValue.String(), lockModeAttributeValue.String()) } // RecordMongodbLockAcquireWaitCountDataPoint adds a data point to mongodb.lock.acquire.wait_count metric. -func (mb *MetricsBuilder) RecordMongodbLockAcquireWaitCountDataPoint(ts pcommon.Timestamp, val int64, databaseAttributeValue string, lockTypeAttributeValue AttributeLockType, lockModeAttributeValue AttributeLockMode) { - mb.metricMongodbLockAcquireWaitCount.recordDataPoint(mb.startTime, ts, val, databaseAttributeValue, lockTypeAttributeValue.String(), lockModeAttributeValue.String()) +func (mb *MetricsBuilder) RecordMongodbLockAcquireWaitCountDataPoint(ts pcommon.Timestamp, val int64, lockTypeAttributeValue AttributeLockType, lockModeAttributeValue AttributeLockMode) { + mb.metricMongodbLockAcquireWaitCount.recordDataPoint(mb.startTime, ts, val, lockTypeAttributeValue.String(), lockModeAttributeValue.String()) } // RecordMongodbLockDeadlockCountDataPoint adds a data point to mongodb.lock.deadlock.count metric. -func (mb *MetricsBuilder) RecordMongodbLockDeadlockCountDataPoint(ts pcommon.Timestamp, val int64, databaseAttributeValue string, lockTypeAttributeValue AttributeLockType, lockModeAttributeValue AttributeLockMode) { - mb.metricMongodbLockDeadlockCount.recordDataPoint(mb.startTime, ts, val, databaseAttributeValue, lockTypeAttributeValue.String(), lockModeAttributeValue.String()) +func (mb *MetricsBuilder) RecordMongodbLockDeadlockCountDataPoint(ts pcommon.Timestamp, val int64, lockTypeAttributeValue AttributeLockType, lockModeAttributeValue AttributeLockMode) { + mb.metricMongodbLockDeadlockCount.recordDataPoint(mb.startTime, ts, val, lockTypeAttributeValue.String(), lockModeAttributeValue.String()) } // RecordMongodbMemoryUsageDataPoint adds a data point to mongodb.memory.usage metric. -func (mb *MetricsBuilder) RecordMongodbMemoryUsageDataPoint(ts pcommon.Timestamp, val int64, databaseAttributeValue string, memoryTypeAttributeValue AttributeMemoryType) { - mb.metricMongodbMemoryUsage.recordDataPoint(mb.startTime, ts, val, databaseAttributeValue, memoryTypeAttributeValue.String()) +func (mb *MetricsBuilder) RecordMongodbMemoryUsageDataPoint(ts pcommon.Timestamp, val int64, memoryTypeAttributeValue AttributeMemoryType) { + mb.metricMongodbMemoryUsage.recordDataPoint(mb.startTime, ts, val, memoryTypeAttributeValue.String()) } // RecordMongodbNetworkIoReceiveDataPoint adds a data point to mongodb.network.io.receive metric. @@ -2135,8 +2113,8 @@ func (mb *MetricsBuilder) RecordMongodbNetworkRequestCountDataPoint(ts pcommon.T } // RecordMongodbObjectCountDataPoint adds a data point to mongodb.object.count metric. -func (mb *MetricsBuilder) RecordMongodbObjectCountDataPoint(ts pcommon.Timestamp, val int64, databaseAttributeValue string) { - mb.metricMongodbObjectCount.recordDataPoint(mb.startTime, ts, val, databaseAttributeValue) +func (mb *MetricsBuilder) RecordMongodbObjectCountDataPoint(ts pcommon.Timestamp, val int64) { + mb.metricMongodbObjectCount.recordDataPoint(mb.startTime, ts, val) } // RecordMongodbOperationCountDataPoint adds a data point to mongodb.operation.count metric. @@ -2165,8 +2143,8 @@ func (mb *MetricsBuilder) RecordMongodbSessionCountDataPoint(ts pcommon.Timestam } // RecordMongodbStorageSizeDataPoint adds a data point to mongodb.storage.size metric. -func (mb *MetricsBuilder) RecordMongodbStorageSizeDataPoint(ts pcommon.Timestamp, val int64, databaseAttributeValue string) { - mb.metricMongodbStorageSize.recordDataPoint(mb.startTime, ts, val, databaseAttributeValue) +func (mb *MetricsBuilder) RecordMongodbStorageSizeDataPoint(ts pcommon.Timestamp, val int64) { + mb.metricMongodbStorageSize.recordDataPoint(mb.startTime, ts, val) } // RecordMongodbUptimeDataPoint adds a data point to mongodb.uptime metric. diff --git a/receiver/mongodbreceiver/internal/metadata/generated_metrics_test.go b/receiver/mongodbreceiver/internal/metadata/generated_metrics_test.go index 967df16e4b33..29632f4b83df 100644 --- a/receiver/mongodbreceiver/internal/metadata/generated_metrics_test.go +++ b/receiver/mongodbreceiver/internal/metadata/generated_metrics_test.go @@ -61,11 +61,11 @@ func TestMetricsBuilder(t *testing.T) { defaultMetricsCount++ allMetricsCount++ - mb.RecordMongodbCollectionCountDataPoint(ts, 1, "database-val") + mb.RecordMongodbCollectionCountDataPoint(ts, 1) defaultMetricsCount++ allMetricsCount++ - mb.RecordMongodbConnectionCountDataPoint(ts, 1, "database-val", AttributeConnectionTypeActive) + mb.RecordMongodbConnectionCountDataPoint(ts, 1, AttributeConnectionTypeActive) defaultMetricsCount++ allMetricsCount++ @@ -77,7 +77,7 @@ func TestMetricsBuilder(t *testing.T) { defaultMetricsCount++ allMetricsCount++ - mb.RecordMongodbDataSizeDataPoint(ts, 1, "database-val") + mb.RecordMongodbDataSizeDataPoint(ts, 1) defaultMetricsCount++ allMetricsCount++ @@ -85,11 +85,11 @@ func TestMetricsBuilder(t *testing.T) { defaultMetricsCount++ allMetricsCount++ - mb.RecordMongodbDocumentOperationCountDataPoint(ts, 1, "database-val", AttributeOperationInsert) + mb.RecordMongodbDocumentOperationCountDataPoint(ts, 1, AttributeOperationInsert) defaultMetricsCount++ allMetricsCount++ - mb.RecordMongodbExtentCountDataPoint(ts, 1, "database-val") + mb.RecordMongodbExtentCountDataPoint(ts, 1) defaultMetricsCount++ allMetricsCount++ @@ -100,31 +100,31 @@ func TestMetricsBuilder(t *testing.T) { defaultMetricsCount++ allMetricsCount++ - mb.RecordMongodbIndexAccessCountDataPoint(ts, 1, "database-val", "collection-val") + mb.RecordMongodbIndexAccessCountDataPoint(ts, 1, "collection-val") defaultMetricsCount++ allMetricsCount++ - mb.RecordMongodbIndexCountDataPoint(ts, 1, "database-val") + mb.RecordMongodbIndexCountDataPoint(ts, 1) defaultMetricsCount++ allMetricsCount++ - mb.RecordMongodbIndexSizeDataPoint(ts, 1, "database-val") + mb.RecordMongodbIndexSizeDataPoint(ts, 1) allMetricsCount++ - mb.RecordMongodbLockAcquireCountDataPoint(ts, 1, "database-val", AttributeLockTypeParallelBatchWriteMode, AttributeLockModeShared) + mb.RecordMongodbLockAcquireCountDataPoint(ts, 1, AttributeLockTypeParallelBatchWriteMode, AttributeLockModeShared) allMetricsCount++ - mb.RecordMongodbLockAcquireTimeDataPoint(ts, 1, "database-val", AttributeLockTypeParallelBatchWriteMode, AttributeLockModeShared) + mb.RecordMongodbLockAcquireTimeDataPoint(ts, 1, AttributeLockTypeParallelBatchWriteMode, AttributeLockModeShared) allMetricsCount++ - mb.RecordMongodbLockAcquireWaitCountDataPoint(ts, 1, "database-val", AttributeLockTypeParallelBatchWriteMode, AttributeLockModeShared) + mb.RecordMongodbLockAcquireWaitCountDataPoint(ts, 1, AttributeLockTypeParallelBatchWriteMode, AttributeLockModeShared) allMetricsCount++ - mb.RecordMongodbLockDeadlockCountDataPoint(ts, 1, "database-val", AttributeLockTypeParallelBatchWriteMode, AttributeLockModeShared) + mb.RecordMongodbLockDeadlockCountDataPoint(ts, 1, AttributeLockTypeParallelBatchWriteMode, AttributeLockModeShared) defaultMetricsCount++ allMetricsCount++ - mb.RecordMongodbMemoryUsageDataPoint(ts, 1, "database-val", AttributeMemoryTypeResident) + mb.RecordMongodbMemoryUsageDataPoint(ts, 1, AttributeMemoryTypeResident) defaultMetricsCount++ allMetricsCount++ @@ -140,7 +140,7 @@ func TestMetricsBuilder(t *testing.T) { defaultMetricsCount++ allMetricsCount++ - mb.RecordMongodbObjectCountDataPoint(ts, 1, "database-val") + mb.RecordMongodbObjectCountDataPoint(ts, 1) defaultMetricsCount++ allMetricsCount++ @@ -162,7 +162,7 @@ func TestMetricsBuilder(t *testing.T) { defaultMetricsCount++ allMetricsCount++ - mb.RecordMongodbStorageSizeDataPoint(ts, 1, "database-val") + mb.RecordMongodbStorageSizeDataPoint(ts, 1) allMetricsCount++ mb.RecordMongodbUptimeDataPoint(ts, 1) @@ -222,9 +222,6 @@ func TestMetricsBuilder(t *testing.T) { assert.Equal(t, ts, dp.Timestamp()) assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("database") - assert.True(t, ok) - assert.EqualValues(t, "database-val", attrVal.Str()) case "mongodb.connection.count": assert.False(t, validatedMetrics["mongodb.connection.count"], "Found a duplicate in the metrics slice: mongodb.connection.count") validatedMetrics["mongodb.connection.count"] = true @@ -239,10 +236,7 @@ func TestMetricsBuilder(t *testing.T) { assert.Equal(t, ts, dp.Timestamp()) assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("database") - assert.True(t, ok) - assert.EqualValues(t, "database-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("type") + attrVal, ok := dp.Attributes().Get("type") assert.True(t, ok) assert.EqualValues(t, "active", attrVal.Str()) case "mongodb.cursor.count": @@ -287,9 +281,6 @@ func TestMetricsBuilder(t *testing.T) { assert.Equal(t, ts, dp.Timestamp()) assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("database") - assert.True(t, ok) - assert.EqualValues(t, "database-val", attrVal.Str()) case "mongodb.database.count": assert.False(t, validatedMetrics["mongodb.database.count"], "Found a duplicate in the metrics slice: mongodb.database.count") validatedMetrics["mongodb.database.count"] = true @@ -318,10 +309,7 @@ func TestMetricsBuilder(t *testing.T) { assert.Equal(t, ts, dp.Timestamp()) assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("database") - assert.True(t, ok) - assert.EqualValues(t, "database-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("operation") + attrVal, ok := dp.Attributes().Get("operation") assert.True(t, ok) assert.EqualValues(t, "insert", attrVal.Str()) case "mongodb.extent.count": @@ -338,9 +326,6 @@ func TestMetricsBuilder(t *testing.T) { assert.Equal(t, ts, dp.Timestamp()) assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("database") - assert.True(t, ok) - assert.EqualValues(t, "database-val", attrVal.Str()) case "mongodb.global_lock.time": assert.False(t, validatedMetrics["mongodb.global_lock.time"], "Found a duplicate in the metrics slice: mongodb.global_lock.time") validatedMetrics["mongodb.global_lock.time"] = true @@ -381,10 +366,7 @@ func TestMetricsBuilder(t *testing.T) { assert.Equal(t, ts, dp.Timestamp()) assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("database") - assert.True(t, ok) - assert.EqualValues(t, "database-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("collection") + attrVal, ok := dp.Attributes().Get("collection") assert.True(t, ok) assert.EqualValues(t, "collection-val", attrVal.Str()) case "mongodb.index.count": @@ -401,9 +383,6 @@ func TestMetricsBuilder(t *testing.T) { assert.Equal(t, ts, dp.Timestamp()) assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("database") - assert.True(t, ok) - assert.EqualValues(t, "database-val", attrVal.Str()) case "mongodb.index.size": assert.False(t, validatedMetrics["mongodb.index.size"], "Found a duplicate in the metrics slice: mongodb.index.size") validatedMetrics["mongodb.index.size"] = true @@ -418,9 +397,6 @@ func TestMetricsBuilder(t *testing.T) { assert.Equal(t, ts, dp.Timestamp()) assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("database") - assert.True(t, ok) - assert.EqualValues(t, "database-val", attrVal.Str()) case "mongodb.lock.acquire.count": assert.False(t, validatedMetrics["mongodb.lock.acquire.count"], "Found a duplicate in the metrics slice: mongodb.lock.acquire.count") validatedMetrics["mongodb.lock.acquire.count"] = true @@ -435,10 +411,7 @@ func TestMetricsBuilder(t *testing.T) { assert.Equal(t, ts, dp.Timestamp()) assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("database") - assert.True(t, ok) - assert.EqualValues(t, "database-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("lock_type") + attrVal, ok := dp.Attributes().Get("lock_type") assert.True(t, ok) assert.EqualValues(t, "parallel_batch_write_mode", attrVal.Str()) attrVal, ok = dp.Attributes().Get("lock_mode") @@ -458,10 +431,7 @@ func TestMetricsBuilder(t *testing.T) { assert.Equal(t, ts, dp.Timestamp()) assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("database") - assert.True(t, ok) - assert.EqualValues(t, "database-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("lock_type") + attrVal, ok := dp.Attributes().Get("lock_type") assert.True(t, ok) assert.EqualValues(t, "parallel_batch_write_mode", attrVal.Str()) attrVal, ok = dp.Attributes().Get("lock_mode") @@ -481,10 +451,7 @@ func TestMetricsBuilder(t *testing.T) { assert.Equal(t, ts, dp.Timestamp()) assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("database") - assert.True(t, ok) - assert.EqualValues(t, "database-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("lock_type") + attrVal, ok := dp.Attributes().Get("lock_type") assert.True(t, ok) assert.EqualValues(t, "parallel_batch_write_mode", attrVal.Str()) attrVal, ok = dp.Attributes().Get("lock_mode") @@ -504,10 +471,7 @@ func TestMetricsBuilder(t *testing.T) { assert.Equal(t, ts, dp.Timestamp()) assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("database") - assert.True(t, ok) - assert.EqualValues(t, "database-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("lock_type") + attrVal, ok := dp.Attributes().Get("lock_type") assert.True(t, ok) assert.EqualValues(t, "parallel_batch_write_mode", attrVal.Str()) attrVal, ok = dp.Attributes().Get("lock_mode") @@ -527,10 +491,7 @@ func TestMetricsBuilder(t *testing.T) { assert.Equal(t, ts, dp.Timestamp()) assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("database") - assert.True(t, ok) - assert.EqualValues(t, "database-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("type") + attrVal, ok := dp.Attributes().Get("type") assert.True(t, ok) assert.EqualValues(t, "resident", attrVal.Str()) case "mongodb.network.io.receive": @@ -589,9 +550,6 @@ func TestMetricsBuilder(t *testing.T) { assert.Equal(t, ts, dp.Timestamp()) assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("database") - assert.True(t, ok) - assert.EqualValues(t, "database-val", attrVal.Str()) case "mongodb.operation.count": assert.False(t, validatedMetrics["mongodb.operation.count"], "Found a duplicate in the metrics slice: mongodb.operation.count") validatedMetrics["mongodb.operation.count"] = true @@ -686,9 +644,6 @@ func TestMetricsBuilder(t *testing.T) { assert.Equal(t, ts, dp.Timestamp()) assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("database") - assert.True(t, ok) - assert.EqualValues(t, "database-val", attrVal.Str()) case "mongodb.uptime": assert.False(t, validatedMetrics["mongodb.uptime"], "Found a duplicate in the metrics slice: mongodb.uptime") validatedMetrics["mongodb.uptime"] = true diff --git a/receiver/mongodbreceiver/internal/metadata/metrics_database_attr_version.go b/receiver/mongodbreceiver/internal/metadata/metrics_database_attr_version.go new file mode 100644 index 000000000000..038c051919e6 --- /dev/null +++ b/receiver/mongodbreceiver/internal/metadata/metrics_database_attr_version.go @@ -0,0 +1,260 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package metadata // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mongodbreceiver/internal/metadata" + +import ( + "go.opentelemetry.io/collector/pdata/pcommon" +) + +func (m *metricMongodbCollectionCount) recordDataPointDatabaseAttr(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) + dp.Attributes().PutStr("database", databaseAttributeValue) +} + +func (m *metricMongodbConnectionCount) recordDataPointDatabaseAttr(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string, connectionTypeAttributeValue string) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) + dp.Attributes().PutStr("database", databaseAttributeValue) + dp.Attributes().PutStr("type", connectionTypeAttributeValue) +} + +func (m *metricMongodbDataSize) recordDataPointDatabaseAttr(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) + dp.Attributes().PutStr("database", databaseAttributeValue) +} + +func (m *metricMongodbDocumentOperationCount) recordDataPointDatabaseAttr(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string, operationAttributeValue string) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) + dp.Attributes().PutStr("database", databaseAttributeValue) + dp.Attributes().PutStr("operation", operationAttributeValue) +} + +func (m *metricMongodbExtentCount) recordDataPointDatabaseAttr(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) + dp.Attributes().PutStr("database", databaseAttributeValue) +} + +func (m *metricMongodbIndexAccessCount) recordDataPointDatabaseAttr(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string, collectionAttributeValue string) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) + dp.Attributes().PutStr("database", databaseAttributeValue) + dp.Attributes().PutStr("collection", collectionAttributeValue) +} + +func (m *metricMongodbIndexCount) recordDataPointDatabaseAttr(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) + dp.Attributes().PutStr("database", databaseAttributeValue) +} + +func (m *metricMongodbIndexSize) recordDataPointDatabaseAttr(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) + dp.Attributes().PutStr("database", databaseAttributeValue) +} + +func (m *metricMongodbLockAcquireCount) recordDataPointDatabaseAttr(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string, lockTypeAttributeValue string, lockModeAttributeValue string) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) + dp.Attributes().PutStr("database", databaseAttributeValue) + dp.Attributes().PutStr("lock_type", lockTypeAttributeValue) + dp.Attributes().PutStr("lock_mode", lockModeAttributeValue) +} + +func (m *metricMongodbLockAcquireTime) recordDataPointDatabaseAttr(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string, lockTypeAttributeValue string, lockModeAttributeValue string) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) + dp.Attributes().PutStr("database", databaseAttributeValue) + dp.Attributes().PutStr("lock_type", lockTypeAttributeValue) + dp.Attributes().PutStr("lock_mode", lockModeAttributeValue) +} + +func (m *metricMongodbLockAcquireWaitCount) recordDataPointDatabaseAttr(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string, lockTypeAttributeValue string, lockModeAttributeValue string) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) + dp.Attributes().PutStr("database", databaseAttributeValue) + dp.Attributes().PutStr("lock_type", lockTypeAttributeValue) + dp.Attributes().PutStr("lock_mode", lockModeAttributeValue) +} + +func (m *metricMongodbLockDeadlockCount) recordDataPointDatabaseAttr(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string, lockTypeAttributeValue string, lockModeAttributeValue string) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) + dp.Attributes().PutStr("database", databaseAttributeValue) + dp.Attributes().PutStr("lock_type", lockTypeAttributeValue) + dp.Attributes().PutStr("lock_mode", lockModeAttributeValue) +} + +func (m *metricMongodbMemoryUsage) recordDataPointDatabaseAttr(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string, memoryTypeAttributeValue string) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) + dp.Attributes().PutStr("database", databaseAttributeValue) + dp.Attributes().PutStr("type", memoryTypeAttributeValue) +} + +func (m *metricMongodbObjectCount) recordDataPointDatabaseAttr(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) + dp.Attributes().PutStr("database", databaseAttributeValue) +} + +func (m *metricMongodbStorageSize) recordDataPointDatabaseAttr(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, databaseAttributeValue string) { + if !m.config.Enabled { + return + } + dp := m.data.Sum().DataPoints().AppendEmpty() + dp.SetStartTimestamp(start) + dp.SetTimestamp(ts) + dp.SetIntValue(val) + dp.Attributes().PutStr("database", databaseAttributeValue) +} + +// RecordMongodbCollectionCountDataPointDatabaseAttr adds a data point to mongodb.collection.count metric. +func (mb *MetricsBuilder) RecordMongodbCollectionCountDataPointDatabaseAttr(ts pcommon.Timestamp, val int64, databaseAttributeValue string) { + mb.metricMongodbCollectionCount.recordDataPointDatabaseAttr(mb.startTime, ts, val, databaseAttributeValue) +} + +// RecordMongodbDataSizeDataPointDatabaseAttr adds a data point to mongodb.data.size metric. +func (mb *MetricsBuilder) RecordMongodbDataSizeDataPointDatabaseAttr(ts pcommon.Timestamp, val int64, databaseAttributeValue string) { + mb.metricMongodbDataSize.recordDataPointDatabaseAttr(mb.startTime, ts, val, databaseAttributeValue) +} + +// RecordMongodbDocumentOperationCountDataPointDatabaseAttr adds a data point to mongodb.document.operation.count metric. +func (mb *MetricsBuilder) RecordMongodbDocumentOperationCountDataPointDatabaseAttr(ts pcommon.Timestamp, val int64, databaseAttributeValue string, operationAttributeValue AttributeOperation) { + mb.metricMongodbDocumentOperationCount.recordDataPointDatabaseAttr(mb.startTime, ts, val, databaseAttributeValue, operationAttributeValue.String()) +} + +// RecordMongodbConnectionCountDataPointDatabaseAttr adds a data point to mongodb.connection.count metric. +func (mb *MetricsBuilder) RecordMongodbConnectionCountDataPointDatabaseAttr(ts pcommon.Timestamp, val int64, databaseAttributeValue string, connectionTypeAttributeValue AttributeConnectionType) { + mb.metricMongodbConnectionCount.recordDataPointDatabaseAttr(mb.startTime, ts, val, databaseAttributeValue, connectionTypeAttributeValue.String()) +} + +// RecordMongodbExtentCountDataPointDatabaseAttr adds a data point to mongodb.extent.count metric. +func (mb *MetricsBuilder) RecordMongodbExtentCountDataPointDatabaseAttr(ts pcommon.Timestamp, val int64, databaseAttributeValue string) { + mb.metricMongodbExtentCount.recordDataPointDatabaseAttr(mb.startTime, ts, val, databaseAttributeValue) +} + +// RecordMongodbIndexAccessCountDataPointDatabaseAttr adds a data point to mongodb.index.access.count metric. +func (mb *MetricsBuilder) RecordMongodbIndexAccessCountDataPointDatabaseAttr(ts pcommon.Timestamp, val int64, databaseAttributeValue string, collectionAttributeValue string) { + mb.metricMongodbIndexAccessCount.recordDataPointDatabaseAttr(mb.startTime, ts, val, databaseAttributeValue, collectionAttributeValue) +} + +// RecordMongodbIndexCountDataPointDatabaseAttr adds a data point to mongodb.index.count metric. +func (mb *MetricsBuilder) RecordMongodbIndexCountDataPointDatabaseAttr(ts pcommon.Timestamp, val int64, databaseAttributeValue string) { + mb.metricMongodbIndexCount.recordDataPointDatabaseAttr(mb.startTime, ts, val, databaseAttributeValue) +} + +// RecordMongodbIndexSizeDataPointDatabaseAttr adds a data point to mongodb.index.size metric. +func (mb *MetricsBuilder) RecordMongodbIndexSizeDataPointDatabaseAttr(ts pcommon.Timestamp, val int64, databaseAttributeValue string) { + mb.metricMongodbIndexSize.recordDataPointDatabaseAttr(mb.startTime, ts, val, databaseAttributeValue) +} + +// RecordMongodbLockAcquireCountDataPointDatabaseAttr adds a data point to mongodb.lock.acquire.count metric. +func (mb *MetricsBuilder) RecordMongodbLockAcquireCountDataPointDatabaseAttr(ts pcommon.Timestamp, val int64, databaseAttributeValue string, lockTypeAttributeValue AttributeLockType, lockModeAttributeValue AttributeLockMode) { + mb.metricMongodbLockAcquireCount.recordDataPointDatabaseAttr(mb.startTime, ts, val, databaseAttributeValue, lockTypeAttributeValue.String(), lockModeAttributeValue.String()) +} + +// RecordMongodbLockAcquireTimeDataPointDatabaseAttr adds a data point to mongodb.lock.acquire.time metric. +func (mb *MetricsBuilder) RecordMongodbLockAcquireTimeDataPointDatabaseAttr(ts pcommon.Timestamp, val int64, databaseAttributeValue string, lockTypeAttributeValue AttributeLockType, lockModeAttributeValue AttributeLockMode) { + mb.metricMongodbLockAcquireTime.recordDataPointDatabaseAttr(mb.startTime, ts, val, databaseAttributeValue, lockTypeAttributeValue.String(), lockModeAttributeValue.String()) +} + +// RecordMongodbLockAcquireWaitCountDataPointDatabaseAttr adds a data point to mongodb.lock.acquire.wait_count metric. +func (mb *MetricsBuilder) RecordMongodbLockAcquireWaitCountDataPointDatabaseAttr(ts pcommon.Timestamp, val int64, databaseAttributeValue string, lockTypeAttributeValue AttributeLockType, lockModeAttributeValue AttributeLockMode) { + mb.metricMongodbLockAcquireWaitCount.recordDataPointDatabaseAttr(mb.startTime, ts, val, databaseAttributeValue, lockTypeAttributeValue.String(), lockModeAttributeValue.String()) +} + +// RecordMongodbLockDeadlockCountDataPointDatabaseAttr adds a data point to mongodb.lock.deadlock.count metric. +func (mb *MetricsBuilder) RecordMongodbLockDeadlockCountDataPointDatabaseAttr(ts pcommon.Timestamp, val int64, databaseAttributeValue string, lockTypeAttributeValue AttributeLockType, lockModeAttributeValue AttributeLockMode) { + mb.metricMongodbLockDeadlockCount.recordDataPointDatabaseAttr(mb.startTime, ts, val, databaseAttributeValue, lockTypeAttributeValue.String(), lockModeAttributeValue.String()) +} + +// RecordMongodbMemoryUsageDataPointDatabaseAttr adds a data point to mongodb.memory.usage metric. +func (mb *MetricsBuilder) RecordMongodbMemoryUsageDataPointDatabaseAttr(ts pcommon.Timestamp, val int64, databaseAttributeValue string, memoryTypeAttributeValue AttributeMemoryType) { + mb.metricMongodbMemoryUsage.recordDataPointDatabaseAttr(mb.startTime, ts, val, databaseAttributeValue, memoryTypeAttributeValue.String()) +} + +// RecordMongodbObjectCountDataPointDatabaseAttr adds a data point to mongodb.object.count metric. +func (mb *MetricsBuilder) RecordMongodbObjectCountDataPointDatabaseAttr(ts pcommon.Timestamp, val int64, databaseAttributeValue string) { + mb.metricMongodbObjectCount.recordDataPointDatabaseAttr(mb.startTime, ts, val, databaseAttributeValue) +} + +// RecordMongodbStorageSizeDataPointDatabaseAttr adds a data point to mongodb.storage.size metric. +func (mb *MetricsBuilder) RecordMongodbStorageSizeDataPointDatabaseAttr(ts pcommon.Timestamp, val int64, databaseAttributeValue string) { + mb.metricMongodbStorageSize.recordDataPointDatabaseAttr(mb.startTime, ts, val, databaseAttributeValue) +} diff --git a/receiver/mongodbreceiver/metadata.yaml b/receiver/mongodbreceiver/metadata.yaml index 7b3185ce0899..f620467fff7d 100644 --- a/receiver/mongodbreceiver/metadata.yaml +++ b/receiver/mongodbreceiver/metadata.yaml @@ -15,9 +15,6 @@ resource_attributes: type: string attributes: - database: - description: The name of a database. - type: string collection: description: The name of a collection. type: string @@ -99,7 +96,7 @@ metrics: aggregation_temporality: cumulative value_type: int monotonic: false - attributes: [database] + attributes: [] mongodb.data.size: description: The size of the collection. Data compression does not affect this value. unit: By @@ -108,7 +105,7 @@ metrics: aggregation_temporality: cumulative value_type: int monotonic: false - attributes: [database] + attributes: [] mongodb.connection.count: description: The number of connections. unit: "{connections}" @@ -117,7 +114,7 @@ metrics: value_type: int aggregation_temporality: cumulative monotonic: false - attributes: [database, connection_type] + attributes: [connection_type] mongodb.extent.count: description: The number of extents. unit: "{extents}" @@ -126,7 +123,7 @@ metrics: aggregation_temporality: cumulative value_type: int monotonic: false - attributes: [database] + attributes: [] mongodb.global_lock.time: description: The time the global lock has been held. unit: ms @@ -144,7 +141,7 @@ metrics: aggregation_temporality: cumulative value_type: int monotonic: false - attributes: [database] + attributes: [] mongodb.index.size: description: Sum of the space allocated to all indexes in the database, including free index space. unit: By @@ -153,7 +150,7 @@ metrics: aggregation_temporality: cumulative value_type: int monotonic: false - attributes: [database] + attributes: [] mongodb.memory.usage: description: The amount of memory used. unit: By @@ -162,7 +159,7 @@ metrics: aggregation_temporality: cumulative value_type: int monotonic: false - attributes: [database, memory_type] + attributes: [memory_type] mongodb.object.count: description: The number of objects. unit: "{objects}" @@ -171,7 +168,7 @@ metrics: aggregation_temporality: cumulative value_type: int monotonic: false - attributes: [database] + attributes: [] mongodb.operation.latency.time: description: The latency of operations. unit: us @@ -206,7 +203,7 @@ metrics: aggregation_temporality: cumulative value_type: int monotonic: true - attributes: [database] + attributes: [] mongodb.database.count: description: The number of existing databases. unit: "{databases}" @@ -224,7 +221,7 @@ metrics: value_type: int aggregation_temporality: cumulative monotonic: false - attributes: [database, collection] + attributes: [collection] mongodb.document.operation.count: description: The number of document operations executed. unit: "{documents}" @@ -233,7 +230,7 @@ metrics: value_type: int aggregation_temporality: cumulative monotonic: false - attributes: [database, operation] + attributes: [operation] mongodb.network.io.receive: description: The number of bytes received. unit: By @@ -305,7 +302,7 @@ metrics: value_type: int aggregation_temporality: cumulative monotonic: true - attributes: [database, lock_type, lock_mode] + attributes: [lock_type, lock_mode] mongodb.lock.acquire.wait_count: description: Number of times the lock acquisitions encountered waits because the locks were held in a conflicting mode. unit: "{count}" @@ -314,7 +311,7 @@ metrics: value_type: int aggregation_temporality: cumulative monotonic: true - attributes: [database, lock_type, lock_mode] + attributes: [lock_type, lock_mode] mongodb.lock.acquire.time: description: Cumulative wait time for the lock acquisitions. unit: "microseconds" @@ -323,7 +320,7 @@ metrics: value_type: int aggregation_temporality: cumulative monotonic: true - attributes: [database, lock_type, lock_mode] + attributes: [lock_type, lock_mode] mongodb.lock.deadlock.count: description: Number of times the lock acquisitions encountered deadlocks. unit: "{count}" @@ -332,7 +329,7 @@ metrics: value_type: int aggregation_temporality: cumulative monotonic: true - attributes: [database, lock_type, lock_mode] + attributes: [lock_type, lock_mode] mongodb.health: enabled: false description: The health status of the server. diff --git a/receiver/mongodbreceiver/metrics.go b/receiver/mongodbreceiver/metrics.go index 9d0b36578537..807a0a27b9ff 100644 --- a/receiver/mongodbreceiver/metrics.go +++ b/receiver/mongodbreceiver/metrics.go @@ -65,7 +65,11 @@ func (s *mongodbScraper) recordCollections(now pcommon.Timestamp, doc bson.M, db errs.AddPartial(1, fmt.Errorf(collectMetricWithAttributes, metricName, dbName, err)) return } - s.mb.RecordMongodbCollectionCountDataPoint(now, val, dbName) + if s.removeDatabaseAttr { + s.mb.RecordMongodbCollectionCountDataPoint(now, val) + } else { + s.mb.RecordMongodbCollectionCountDataPointDatabaseAttr(now, val, dbName) + } } func (s *mongodbScraper) recordDataSize(now pcommon.Timestamp, doc bson.M, dbName string, errs *scrapererror.ScrapeErrors) { @@ -76,7 +80,11 @@ func (s *mongodbScraper) recordDataSize(now pcommon.Timestamp, doc bson.M, dbNam errs.AddPartial(1, fmt.Errorf(collectMetricWithAttributes, metricName, dbName, err)) return } - s.mb.RecordMongodbDataSizeDataPoint(now, val, dbName) + if s.removeDatabaseAttr { + s.mb.RecordMongodbDataSizeDataPoint(now, val) + } else { + s.mb.RecordMongodbDataSizeDataPointDatabaseAttr(now, val, dbName) + } } func (s *mongodbScraper) recordStorageSize(now pcommon.Timestamp, doc bson.M, dbName string, errs *scrapererror.ScrapeErrors) { @@ -87,7 +95,11 @@ func (s *mongodbScraper) recordStorageSize(now pcommon.Timestamp, doc bson.M, db errs.AddPartial(1, fmt.Errorf(collectMetricWithAttributes, metricName, dbName, err)) return } - s.mb.RecordMongodbStorageSizeDataPoint(now, val, dbName) + if s.removeDatabaseAttr { + s.mb.RecordMongodbStorageSizeDataPoint(now, val) + } else { + s.mb.RecordMongodbStorageSizeDataPointDatabaseAttr(now, val, dbName) + } } func (s *mongodbScraper) recordObjectCount(now pcommon.Timestamp, doc bson.M, dbName string, errs *scrapererror.ScrapeErrors) { @@ -98,7 +110,11 @@ func (s *mongodbScraper) recordObjectCount(now pcommon.Timestamp, doc bson.M, db errs.AddPartial(1, fmt.Errorf(collectMetricWithAttributes, metricName, dbName, err)) return } - s.mb.RecordMongodbObjectCountDataPoint(now, val, dbName) + if s.removeDatabaseAttr { + s.mb.RecordMongodbObjectCountDataPoint(now, val) + } else { + s.mb.RecordMongodbObjectCountDataPointDatabaseAttr(now, val, dbName) + } } func (s *mongodbScraper) recordIndexCount(now pcommon.Timestamp, doc bson.M, dbName string, errs *scrapererror.ScrapeErrors) { @@ -109,7 +125,11 @@ func (s *mongodbScraper) recordIndexCount(now pcommon.Timestamp, doc bson.M, dbN errs.AddPartial(1, fmt.Errorf(collectMetricWithAttributes, metricName, dbName, err)) return } - s.mb.RecordMongodbIndexCountDataPoint(now, val, dbName) + if s.removeDatabaseAttr { + s.mb.RecordMongodbIndexCountDataPoint(now, val) + } else { + s.mb.RecordMongodbIndexCountDataPointDatabaseAttr(now, val, dbName) + } } func (s *mongodbScraper) recordIndexSize(now pcommon.Timestamp, doc bson.M, dbName string, errs *scrapererror.ScrapeErrors) { @@ -120,7 +140,11 @@ func (s *mongodbScraper) recordIndexSize(now pcommon.Timestamp, doc bson.M, dbNa errs.AddPartial(1, fmt.Errorf(collectMetricWithAttributes, metricName, dbName, err)) return } - s.mb.RecordMongodbIndexSizeDataPoint(now, val, dbName) + if s.removeDatabaseAttr { + s.mb.RecordMongodbIndexSizeDataPoint(now, val) + } else { + s.mb.RecordMongodbIndexSizeDataPointDatabaseAttr(now, val, dbName) + } } func (s *mongodbScraper) recordExtentCount(now pcommon.Timestamp, doc bson.M, dbName string, errs *scrapererror.ScrapeErrors) { @@ -135,7 +159,11 @@ func (s *mongodbScraper) recordExtentCount(now pcommon.Timestamp, doc bson.M, db errs.AddPartial(1, fmt.Errorf(collectMetricWithAttributes, metricName, dbName, err)) return } - s.mb.RecordMongodbExtentCountDataPoint(now, val, dbName) + if s.removeDatabaseAttr { + s.mb.RecordMongodbExtentCountDataPoint(now, val) + } else { + s.mb.RecordMongodbExtentCountDataPointDatabaseAttr(now, val, dbName) + } } } @@ -150,7 +178,11 @@ func (s *mongodbScraper) recordConnections(now pcommon.Timestamp, doc bson.M, db errs.AddPartial(1, fmt.Errorf(collectMetricWithAttributes, metricName, metricAttributes, err)) continue } - s.mb.RecordMongodbConnectionCountDataPoint(now, val, dbName, ct) + if s.removeDatabaseAttr { + s.mb.RecordMongodbConnectionCountDataPoint(now, val, ct) + } else { + s.mb.RecordMongodbConnectionCountDataPointDatabaseAttr(now, val, dbName, ct) + } } } @@ -166,7 +198,11 @@ func (s *mongodbScraper) recordMemoryUsage(now pcommon.Timestamp, doc bson.M, db } // convert from mebibytes to bytes memUsageBytes := val * int64(1048576) - s.mb.RecordMongodbMemoryUsageDataPoint(now, memUsageBytes, dbName, mt) + if s.removeDatabaseAttr { + s.mb.RecordMongodbMemoryUsageDataPoint(now, memUsageBytes, mt) + } else { + s.mb.RecordMongodbMemoryUsageDataPointDatabaseAttr(now, memUsageBytes, dbName, mt) + } } } @@ -180,7 +216,11 @@ func (s *mongodbScraper) recordDocumentOperations(now pcommon.Timestamp, doc bso errs.AddPartial(1, fmt.Errorf(collectMetricWithAttributes, metricName, metricAttributes, err)) continue } - s.mb.RecordMongodbDocumentOperationCountDataPoint(now, val, dbName, metadataKey) + if s.removeDatabaseAttr { + s.mb.RecordMongodbDocumentOperationCountDataPoint(now, val, metadataKey) + } else { + s.mb.RecordMongodbDocumentOperationCountDataPointDatabaseAttr(now, val, dbName, metadataKey) + } } } @@ -376,7 +416,11 @@ func (s *mongodbScraper) recordLockAcquireCounts(now pcommon.Timestamp, doc bson errs.AddPartial(1, fmt.Errorf(collectMetricWithAttributes, metricName, metricAttributes, err)) continue } - s.mb.RecordMongodbLockAcquireCountDataPoint(now, val, dBName, lockTypeAttribute, lockModeAttribute) + if s.removeDatabaseAttr { + s.mb.RecordMongodbLockAcquireCountDataPoint(now, val, lockTypeAttribute, lockModeAttribute) + } else { + s.mb.RecordMongodbLockAcquireCountDataPointDatabaseAttr(now, val, dBName, lockTypeAttribute, lockModeAttribute) + } } } } @@ -406,7 +450,11 @@ func (s *mongodbScraper) recordLockAcquireWaitCounts(now pcommon.Timestamp, doc errs.AddPartial(1, fmt.Errorf(collectMetricWithAttributes, metricName, metricAttributes, err)) continue } - s.mb.RecordMongodbLockAcquireWaitCountDataPoint(now, val, dBName, lockTypeAttribute, lockModeAttribute) + if s.removeDatabaseAttr { + s.mb.RecordMongodbLockAcquireWaitCountDataPoint(now, val, lockTypeAttribute, lockModeAttribute) + } else { + s.mb.RecordMongodbLockAcquireWaitCountDataPointDatabaseAttr(now, val, dBName, lockTypeAttribute, lockModeAttribute) + } } } } @@ -436,7 +484,11 @@ func (s *mongodbScraper) recordLockTimeAcquiringMicros(now pcommon.Timestamp, do errs.AddPartial(1, fmt.Errorf(collectMetricWithAttributes, metricName, metricAttributes, err)) continue } - s.mb.RecordMongodbLockAcquireTimeDataPoint(now, val, dBName, lockTypeAttribute, lockModeAttribute) + if s.removeDatabaseAttr { + s.mb.RecordMongodbLockAcquireTimeDataPoint(now, val, lockTypeAttribute, lockModeAttribute) + } else { + s.mb.RecordMongodbLockAcquireTimeDataPointDatabaseAttr(now, val, dBName, lockTypeAttribute, lockModeAttribute) + } } } } @@ -466,7 +518,11 @@ func (s *mongodbScraper) recordLockDeadlockCount(now pcommon.Timestamp, doc bson errs.AddPartial(1, fmt.Errorf(collectMetricWithAttributes, metricName, metricAttributes, err)) continue } - s.mb.RecordMongodbLockDeadlockCountDataPoint(now, val, dBName, lockTypeAttribute, lockModeAttribute) + if s.removeDatabaseAttr { + s.mb.RecordMongodbLockDeadlockCountDataPoint(now, val, lockTypeAttribute, lockModeAttribute) + } else { + s.mb.RecordMongodbLockDeadlockCountDataPointDatabaseAttr(now, val, dBName, lockTypeAttribute, lockModeAttribute) + } } } } @@ -490,7 +546,11 @@ func (s *mongodbScraper) recordIndexAccess(now pcommon.Timestamp, documents []bs } indexAccessTotal += indexAccessValue } - s.mb.RecordMongodbIndexAccessCountDataPoint(now, indexAccessTotal, dbName, collectionName) + if s.removeDatabaseAttr { + s.mb.RecordMongodbIndexAccessCountDataPoint(now, indexAccessTotal, collectionName) + } else { + s.mb.RecordMongodbIndexAccessCountDataPointDatabaseAttr(now, indexAccessTotal, dbName, collectionName) + } } // Top Stats diff --git a/receiver/mongodbreceiver/scraper.go b/receiver/mongodbreceiver/scraper.go index 53de8667d0a7..8ad682c16acf 100644 --- a/receiver/mongodbreceiver/scraper.go +++ b/receiver/mongodbreceiver/scraper.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/go-version" "go.mongodb.org/mongo-driver/bson" "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/featuregate" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/pmetric" "go.opentelemetry.io/collector/receiver" @@ -21,7 +22,21 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mongodbreceiver/internal/metadata" ) -var unknownVersion = func() *version.Version { return version.Must(version.NewVersion("0.0")) } +const ( + readmeURL = "https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/mongodbreceiver/README.md" + removeDatabaseAttrID = "receiver.mongodb.removeDatabaseAttr" +) + +var ( + unknownVersion = func() *version.Version { return version.Must(version.NewVersion("0.0")) } + + removeDatabaseAttrFeatureGate = featuregate.GlobalRegistry().MustRegister( + removeDatabaseAttrID, + featuregate.StageAlpha, + featuregate.WithRegisterDescription("Remove duplicate database name attribute"), + featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/24972"), + featuregate.WithRegisterFromVersion("v0.90.0")) +) type mongodbScraper struct { logger *zap.Logger @@ -29,15 +44,27 @@ type mongodbScraper struct { client client mongoVersion *version.Version mb *metadata.MetricsBuilder + + // removeDatabaseAttr if enabled, will remove database attribute on database metrics + removeDatabaseAttr bool } func newMongodbScraper(settings receiver.CreateSettings, config *Config) *mongodbScraper { - return &mongodbScraper{ - logger: settings.Logger, - config: config, - mb: metadata.NewMetricsBuilder(config.MetricsBuilderConfig, settings), - mongoVersion: unknownVersion(), + ms := &mongodbScraper{ + logger: settings.Logger, + config: config, + mb: metadata.NewMetricsBuilder(config.MetricsBuilderConfig, settings), + mongoVersion: unknownVersion(), + removeDatabaseAttr: removeDatabaseAttrFeatureGate.IsEnabled(), + } + + if !ms.removeDatabaseAttr { + settings.Logger.Warn( + fmt.Sprintf("Feature gate %s is not enabled. Please see the README for more information: %s", removeDatabaseAttrID, readmeURL), + ) } + + return ms } func (s *mongodbScraper) start(ctx context.Context, _ component.Host) error { @@ -152,7 +179,14 @@ func (s *mongodbScraper) collectIndexStats(ctx context.Context, now pcommon.Time return } s.recordIndexStats(now, indexStats, databaseName, collectionName, errs) - s.mb.EmitForResource() + + if s.removeDatabaseAttr { + rb := s.mb.NewResourceBuilder() + rb.SetDatabase(databaseName) + s.mb.EmitForResource(metadata.WithResource(rb.Emit())) + } else { + s.mb.EmitForResource() + } } func (s *mongodbScraper) recordDBStats(now pcommon.Timestamp, doc bson.M, dbName string, errs *scrapererror.ScrapeErrors) { diff --git a/receiver/mongodbreceiver/scraper_test.go b/receiver/mongodbreceiver/scraper_test.go index a95b776037bf..bcfa156fd2f6 100644 --- a/receiver/mongodbreceiver/scraper_test.go +++ b/receiver/mongodbreceiver/scraper_test.go @@ -289,6 +289,9 @@ func TestScraperScrape(t *testing.T) { scraper := newMongodbScraper(receivertest.NewNopCreateSettings(), scraperCfg) + // Set removeDatabaseAttr as true to simulate enable removeDatabaseAttrFeatureGate + scraper.removeDatabaseAttr = true + mc := tc.setupMockClient(t) if mc != nil { scraper.client = mc diff --git a/receiver/mongodbreceiver/testdata/integration/expected.4_0.yaml b/receiver/mongodbreceiver/testdata/integration/expected.4_0.yaml index 535bcc93ab1d..aa0f3d2a42a1 100644 --- a/receiver/mongodbreceiver/testdata/integration/expected.4_0.yaml +++ b/receiver/mongodbreceiver/testdata/integration/expected.4_0.yaml @@ -218,10 +218,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: admin startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: '{collections}' @@ -232,9 +228,6 @@ resourceMetrics: dataPoints: - asInt: "1" attributes: - - key: database - value: - stringValue: admin - key: type value: stringValue: active @@ -242,9 +235,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "838857" attributes: - - key: database - value: - stringValue: admin - key: type value: stringValue: available @@ -252,9 +242,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "3" attributes: - - key: database - value: - stringValue: admin - key: type value: stringValue: current @@ -267,10 +254,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "59" - attributes: - - key: database - value: - stringValue: admin startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: By @@ -281,9 +264,6 @@ resourceMetrics: dataPoints: - asInt: "0" attributes: - - key: database - value: - stringValue: admin - key: operation value: stringValue: insert @@ -291,9 +271,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "0" attributes: - - key: database - value: - stringValue: admin - key: operation value: stringValue: update @@ -301,9 +278,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "0" attributes: - - key: database - value: - stringValue: admin - key: operation value: stringValue: delete @@ -316,10 +290,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "0" - attributes: - - key: database - value: - stringValue: admin startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: '{extents}' @@ -329,10 +299,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: admin startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: '{indexes}' @@ -342,10 +308,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "4096" - attributes: - - key: database - value: - stringValue: admin startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: By @@ -356,9 +318,6 @@ resourceMetrics: dataPoints: - asInt: "1141899264" attributes: - - key: database - value: - stringValue: admin - key: type value: stringValue: virtual @@ -366,9 +325,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "82837504" attributes: - - key: database - value: - stringValue: admin - key: type value: stringValue: resident @@ -381,10 +337,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: admin startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: '{objects}' @@ -394,10 +346,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "4096" - attributes: - - key: database - value: - stringValue: admin startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" isMonotonic: true @@ -406,7 +354,10 @@ resourceMetrics: name: otelcol/mongodbreceiver version: latest - resource: - attributes: [] + attributes: + - key: database + value: + stringValue: admin scopeMetrics: - metrics: - description: The number of times an index has been accessed. @@ -416,9 +367,6 @@ resourceMetrics: dataPoints: - asInt: "0" attributes: - - key: database - value: - stringValue: admin - key: collection value: stringValue: system.version @@ -441,10 +389,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: config startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: '{collections}' @@ -455,9 +399,6 @@ resourceMetrics: dataPoints: - asInt: "1" attributes: - - key: database - value: - stringValue: config - key: type value: stringValue: active @@ -465,9 +406,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "838857" attributes: - - key: database - value: - stringValue: config - key: type value: stringValue: available @@ -475,9 +413,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "3" attributes: - - key: database - value: - stringValue: config - key: type value: stringValue: current @@ -490,10 +425,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "0" - attributes: - - key: database - value: - stringValue: config startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: By @@ -504,9 +435,6 @@ resourceMetrics: dataPoints: - asInt: "0" attributes: - - key: database - value: - stringValue: config - key: operation value: stringValue: insert @@ -514,9 +442,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "0" attributes: - - key: database - value: - stringValue: config - key: operation value: stringValue: update @@ -524,9 +449,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "0" attributes: - - key: database - value: - stringValue: config - key: operation value: stringValue: delete @@ -539,10 +461,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "0" - attributes: - - key: database - value: - stringValue: config startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: '{extents}' @@ -552,10 +470,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "2" - attributes: - - key: database - value: - stringValue: config startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: '{indexes}' @@ -565,10 +479,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "8192" - attributes: - - key: database - value: - stringValue: config startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: By @@ -579,9 +489,6 @@ resourceMetrics: dataPoints: - asInt: "82837504" attributes: - - key: database - value: - stringValue: config - key: type value: stringValue: resident @@ -589,9 +496,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "1141899264" attributes: - - key: database - value: - stringValue: config - key: type value: stringValue: virtual @@ -604,10 +508,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "0" - attributes: - - key: database - value: - stringValue: config startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: '{objects}' @@ -617,10 +517,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "4096" - attributes: - - key: database - value: - stringValue: config startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" isMonotonic: true @@ -629,7 +525,10 @@ resourceMetrics: name: otelcol/mongodbreceiver version: latest - resource: - attributes: [] + attributes: + - key: database + value: + stringValue: config scopeMetrics: - metrics: - description: The number of times an index has been accessed. @@ -639,9 +538,6 @@ resourceMetrics: dataPoints: - asInt: "0" attributes: - - key: database - value: - stringValue: config - key: collection value: stringValue: system.sessions @@ -664,10 +560,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: local startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: '{collections}' @@ -678,9 +570,6 @@ resourceMetrics: dataPoints: - asInt: "838857" attributes: - - key: database - value: - stringValue: local - key: type value: stringValue: available @@ -688,9 +577,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "3" attributes: - - key: database - value: - stringValue: local - key: type value: stringValue: current @@ -698,9 +584,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "1" attributes: - - key: database - value: - stringValue: local - key: type value: stringValue: active @@ -713,10 +596,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1445" - attributes: - - key: database - value: - stringValue: local startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: By @@ -727,9 +606,6 @@ resourceMetrics: dataPoints: - asInt: "0" attributes: - - key: database - value: - stringValue: local - key: operation value: stringValue: update @@ -737,9 +613,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "0" attributes: - - key: database - value: - stringValue: local - key: operation value: stringValue: delete @@ -747,9 +620,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "0" attributes: - - key: database - value: - stringValue: local - key: operation value: stringValue: insert @@ -762,10 +632,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "0" - attributes: - - key: database - value: - stringValue: local startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: '{extents}' @@ -775,10 +641,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: local startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: '{indexes}' @@ -788,10 +650,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "4096" - attributes: - - key: database - value: - stringValue: local startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: By @@ -802,9 +660,6 @@ resourceMetrics: dataPoints: - asInt: "82837504" attributes: - - key: database - value: - stringValue: local - key: type value: stringValue: resident @@ -812,9 +667,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "1141899264" attributes: - - key: database - value: - stringValue: local - key: type value: stringValue: virtual @@ -827,10 +679,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: local startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: '{objects}' @@ -840,10 +688,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "4096" - attributes: - - key: database - value: - stringValue: local startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" isMonotonic: true @@ -864,10 +708,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: testdb startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: '{collections}' @@ -878,9 +718,6 @@ resourceMetrics: dataPoints: - asInt: "1" attributes: - - key: database - value: - stringValue: testdb - key: type value: stringValue: active @@ -888,9 +725,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "838857" attributes: - - key: database - value: - stringValue: testdb - key: type value: stringValue: available @@ -898,9 +732,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "3" attributes: - - key: database - value: - stringValue: testdb - key: type value: stringValue: current @@ -913,10 +744,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "0" - attributes: - - key: database - value: - stringValue: testdb startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: By @@ -927,9 +754,6 @@ resourceMetrics: dataPoints: - asInt: "0" attributes: - - key: database - value: - stringValue: testdb - key: operation value: stringValue: insert @@ -937,9 +761,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "0" attributes: - - key: database - value: - stringValue: testdb - key: operation value: stringValue: update @@ -947,9 +768,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "0" attributes: - - key: database - value: - stringValue: testdb - key: operation value: stringValue: delete @@ -962,10 +780,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "0" - attributes: - - key: database - value: - stringValue: testdb startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: '{extents}' @@ -975,10 +789,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: testdb startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: '{indexes}' @@ -988,10 +798,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "4096" - attributes: - - key: database - value: - stringValue: testdb startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: By @@ -1002,9 +808,6 @@ resourceMetrics: dataPoints: - asInt: "82837504" attributes: - - key: database - value: - stringValue: testdb - key: type value: stringValue: resident @@ -1012,9 +815,6 @@ resourceMetrics: timeUnixNano: "1682363210513475000" - asInt: "1141899264" attributes: - - key: database - value: - stringValue: testdb - key: type value: stringValue: virtual @@ -1027,10 +827,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "0" - attributes: - - key: database - value: - stringValue: testdb startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" unit: '{objects}' @@ -1040,10 +836,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "4096" - attributes: - - key: database - value: - stringValue: testdb startTimeUnixNano: "1682363190502544000" timeUnixNano: "1682363210513475000" isMonotonic: true @@ -1052,7 +844,10 @@ resourceMetrics: name: otelcol/mongodbreceiver version: latest - resource: - attributes: [] + attributes: + - key: database + value: + stringValue: testdb scopeMetrics: - metrics: - description: The number of times an index has been accessed. @@ -1062,9 +857,6 @@ resourceMetrics: dataPoints: - asInt: "0" attributes: - - key: database - value: - stringValue: testdb - key: collection value: stringValue: orders diff --git a/receiver/mongodbreceiver/testdata/integration/expected.4_4lpu.yaml b/receiver/mongodbreceiver/testdata/integration/expected.4_4lpu.yaml index dace89bf9e9f..b6c3274c4698 100644 --- a/receiver/mongodbreceiver/testdata/integration/expected.4_4lpu.yaml +++ b/receiver/mongodbreceiver/testdata/integration/expected.4_4lpu.yaml @@ -218,10 +218,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "2" - attributes: - - key: database - value: - stringValue: admin startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: '{collections}' @@ -232,9 +228,6 @@ resourceMetrics: dataPoints: - asInt: "2" attributes: - - key: database - value: - stringValue: admin - key: type value: stringValue: active @@ -242,9 +235,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "838857" attributes: - - key: database - value: - stringValue: admin - key: type value: stringValue: available @@ -252,9 +242,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "3" attributes: - - key: database - value: - stringValue: admin - key: type value: stringValue: current @@ -267,10 +254,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1160" - attributes: - - key: database - value: - stringValue: admin startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: By @@ -281,9 +264,6 @@ resourceMetrics: dataPoints: - asInt: "1" attributes: - - key: database - value: - stringValue: admin - key: operation value: stringValue: insert @@ -291,9 +271,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "1" attributes: - - key: database - value: - stringValue: admin - key: operation value: stringValue: update @@ -301,9 +278,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "0" attributes: - - key: database - value: - stringValue: admin - key: operation value: stringValue: delete @@ -316,10 +290,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "3" - attributes: - - key: database - value: - stringValue: admin startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: '{indexes}' @@ -329,10 +299,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "61440" - attributes: - - key: database - value: - stringValue: admin startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: By @@ -343,9 +309,6 @@ resourceMetrics: dataPoints: - asInt: "105906176" attributes: - - key: database - value: - stringValue: admin - key: type value: stringValue: resident @@ -353,9 +316,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "1563426816" attributes: - - key: database - value: - stringValue: admin - key: type value: stringValue: virtual @@ -368,10 +328,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "4" - attributes: - - key: database - value: - stringValue: admin startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: '{objects}' @@ -381,10 +337,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "40960" - attributes: - - key: database - value: - stringValue: admin startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" isMonotonic: true @@ -405,10 +357,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: config startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: '{collections}' @@ -419,9 +367,6 @@ resourceMetrics: dataPoints: - asInt: "2" attributes: - - key: database - value: - stringValue: config - key: type value: stringValue: active @@ -429,9 +374,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "838857" attributes: - - key: database - value: - stringValue: config - key: type value: stringValue: available @@ -439,9 +381,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "3" attributes: - - key: database - value: - stringValue: config - key: type value: stringValue: current @@ -454,10 +393,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "0" - attributes: - - key: database - value: - stringValue: config startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: By @@ -468,9 +403,6 @@ resourceMetrics: dataPoints: - asInt: "1" attributes: - - key: database - value: - stringValue: config - key: operation value: stringValue: insert @@ -478,9 +410,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "1" attributes: - - key: database - value: - stringValue: config - key: operation value: stringValue: update @@ -488,9 +417,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "0" attributes: - - key: database - value: - stringValue: config - key: operation value: stringValue: delete @@ -503,10 +429,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "2" - attributes: - - key: database - value: - stringValue: config startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: '{indexes}' @@ -516,10 +438,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "8192" - attributes: - - key: database - value: - stringValue: config startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: By @@ -530,9 +448,6 @@ resourceMetrics: dataPoints: - asInt: "105906176" attributes: - - key: database - value: - stringValue: config - key: type value: stringValue: resident @@ -540,9 +455,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "1563426816" attributes: - - key: database - value: - stringValue: config - key: type value: stringValue: virtual @@ -555,10 +467,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "0" - attributes: - - key: database - value: - stringValue: config startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: '{objects}' @@ -568,10 +476,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "4096" - attributes: - - key: database - value: - stringValue: config startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" isMonotonic: true @@ -592,10 +496,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: local startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: '{collections}' @@ -606,9 +506,6 @@ resourceMetrics: dataPoints: - asInt: "2" attributes: - - key: database - value: - stringValue: local - key: type value: stringValue: active @@ -616,9 +513,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "838857" attributes: - - key: database - value: - stringValue: local - key: type value: stringValue: available @@ -626,9 +520,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "3" attributes: - - key: database - value: - stringValue: local - key: type value: stringValue: current @@ -641,10 +532,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "4191" - attributes: - - key: database - value: - stringValue: local startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: By @@ -655,9 +542,6 @@ resourceMetrics: dataPoints: - asInt: "1" attributes: - - key: database - value: - stringValue: local - key: operation value: stringValue: update @@ -665,9 +549,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "0" attributes: - - key: database - value: - stringValue: local - key: operation value: stringValue: delete @@ -675,9 +556,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "1" attributes: - - key: database - value: - stringValue: local - key: operation value: stringValue: insert @@ -690,10 +568,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: local startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: '{indexes}' @@ -703,10 +577,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "20480" - attributes: - - key: database - value: - stringValue: local startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: By @@ -717,9 +587,6 @@ resourceMetrics: dataPoints: - asInt: "105906176" attributes: - - key: database - value: - stringValue: local - key: type value: stringValue: resident @@ -727,9 +594,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "1563426816" attributes: - - key: database - value: - stringValue: local - key: type value: stringValue: virtual @@ -742,10 +606,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "2" - attributes: - - key: database - value: - stringValue: local startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: '{objects}' @@ -755,10 +615,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "20480" - attributes: - - key: database - value: - stringValue: local startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" isMonotonic: true @@ -779,10 +635,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: testdb startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: '{collections}' @@ -793,9 +645,6 @@ resourceMetrics: dataPoints: - asInt: "2" attributes: - - key: database - value: - stringValue: testdb - key: type value: stringValue: active @@ -803,9 +652,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "838857" attributes: - - key: database - value: - stringValue: testdb - key: type value: stringValue: available @@ -813,9 +659,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "3" attributes: - - key: database - value: - stringValue: testdb - key: type value: stringValue: current @@ -828,10 +671,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "0" - attributes: - - key: database - value: - stringValue: testdb startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: By @@ -842,9 +681,6 @@ resourceMetrics: dataPoints: - asInt: "1" attributes: - - key: database - value: - stringValue: testdb - key: operation value: stringValue: insert @@ -852,9 +688,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "1" attributes: - - key: database - value: - stringValue: testdb - key: operation value: stringValue: update @@ -862,9 +695,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "0" attributes: - - key: database - value: - stringValue: testdb - key: operation value: stringValue: delete @@ -877,10 +707,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: testdb startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: '{indexes}' @@ -890,10 +716,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "4096" - attributes: - - key: database - value: - stringValue: testdb startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: By @@ -904,9 +726,6 @@ resourceMetrics: dataPoints: - asInt: "1563426816" attributes: - - key: database - value: - stringValue: testdb - key: type value: stringValue: virtual @@ -914,9 +733,6 @@ resourceMetrics: timeUnixNano: "1682363222253814000" - asInt: "105906176" attributes: - - key: database - value: - stringValue: testdb - key: type value: stringValue: resident @@ -929,10 +745,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "0" - attributes: - - key: database - value: - stringValue: testdb startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" unit: '{objects}' @@ -942,10 +754,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "4096" - attributes: - - key: database - value: - stringValue: testdb startTimeUnixNano: "1682363202250964000" timeUnixNano: "1682363222253814000" isMonotonic: true @@ -954,7 +762,10 @@ resourceMetrics: name: otelcol/mongodbreceiver version: latest - resource: - attributes: [] + attributes: + - key: database + value: + stringValue: testdb scopeMetrics: - metrics: - description: The number of times an index has been accessed. @@ -964,9 +775,6 @@ resourceMetrics: dataPoints: - asInt: "0" attributes: - - key: database - value: - stringValue: testdb - key: collection value: stringValue: orders diff --git a/receiver/mongodbreceiver/testdata/integration/expected.5_0.yaml b/receiver/mongodbreceiver/testdata/integration/expected.5_0.yaml index 0850d5f9d6a6..5d1841f9c625 100644 --- a/receiver/mongodbreceiver/testdata/integration/expected.5_0.yaml +++ b/receiver/mongodbreceiver/testdata/integration/expected.5_0.yaml @@ -218,10 +218,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: admin startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: '{collections}' @@ -232,9 +228,6 @@ resourceMetrics: dataPoints: - asInt: "2" attributes: - - key: database - value: - stringValue: admin - key: type value: stringValue: active @@ -242,9 +235,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "838857" attributes: - - key: database - value: - stringValue: admin - key: type value: stringValue: available @@ -252,9 +242,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "3" attributes: - - key: database - value: - stringValue: admin - key: type value: stringValue: current @@ -267,10 +254,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "59" - attributes: - - key: database - value: - stringValue: admin startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: By @@ -281,9 +264,6 @@ resourceMetrics: dataPoints: - asInt: "0" attributes: - - key: database - value: - stringValue: admin - key: operation value: stringValue: insert @@ -291,9 +271,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "0" attributes: - - key: database - value: - stringValue: admin - key: operation value: stringValue: update @@ -301,9 +278,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "0" attributes: - - key: database - value: - stringValue: admin - key: operation value: stringValue: delete @@ -316,10 +290,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: admin startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: '{indexes}' @@ -329,10 +299,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "4096" - attributes: - - key: database - value: - stringValue: admin startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: By @@ -343,9 +309,6 @@ resourceMetrics: dataPoints: - asInt: "1585446912" attributes: - - key: database - value: - stringValue: admin - key: type value: stringValue: virtual @@ -353,9 +316,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "117440512" attributes: - - key: database - value: - stringValue: admin - key: type value: stringValue: resident @@ -368,10 +328,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: admin startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: '{objects}' @@ -381,10 +337,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "4096" - attributes: - - key: database - value: - stringValue: admin startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" isMonotonic: true @@ -393,7 +345,10 @@ resourceMetrics: name: otelcol/mongodbreceiver version: latest - resource: - attributes: [] + attributes: + - key: database + value: + stringValue: admin scopeMetrics: - metrics: - description: The number of times an index has been accessed. @@ -403,9 +358,6 @@ resourceMetrics: dataPoints: - asInt: "0" attributes: - - key: database - value: - stringValue: admin - key: collection value: stringValue: system.version @@ -428,10 +380,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: config startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: '{collections}' @@ -442,9 +390,6 @@ resourceMetrics: dataPoints: - asInt: "2" attributes: - - key: database - value: - stringValue: config - key: type value: stringValue: active @@ -452,9 +397,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "838857" attributes: - - key: database - value: - stringValue: config - key: type value: stringValue: available @@ -462,9 +404,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "3" attributes: - - key: database - value: - stringValue: config - key: type value: stringValue: current @@ -477,10 +416,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "0" - attributes: - - key: database - value: - stringValue: config startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: By @@ -491,9 +426,6 @@ resourceMetrics: dataPoints: - asInt: "0" attributes: - - key: database - value: - stringValue: config - key: operation value: stringValue: insert @@ -501,9 +433,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "0" attributes: - - key: database - value: - stringValue: config - key: operation value: stringValue: update @@ -511,9 +440,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "0" attributes: - - key: database - value: - stringValue: config - key: operation value: stringValue: delete @@ -526,10 +452,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "2" - attributes: - - key: database - value: - stringValue: config startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: '{indexes}' @@ -539,10 +461,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "8192" - attributes: - - key: database - value: - stringValue: config startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: By @@ -553,9 +471,6 @@ resourceMetrics: dataPoints: - asInt: "117440512" attributes: - - key: database - value: - stringValue: config - key: type value: stringValue: resident @@ -563,9 +478,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "1585446912" attributes: - - key: database - value: - stringValue: config - key: type value: stringValue: virtual @@ -578,10 +490,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "0" - attributes: - - key: database - value: - stringValue: config startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: '{objects}' @@ -591,10 +499,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "4096" - attributes: - - key: database - value: - stringValue: config startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" isMonotonic: true @@ -603,7 +507,10 @@ resourceMetrics: name: otelcol/mongodbreceiver version: latest - resource: - attributes: [] + attributes: + - key: database + value: + stringValue: config scopeMetrics: - metrics: - description: The number of times an index has been accessed. @@ -613,9 +520,6 @@ resourceMetrics: dataPoints: - asInt: "0" attributes: - - key: database - value: - stringValue: config - key: collection value: stringValue: system.sessions @@ -638,10 +542,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: local startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: '{collections}' @@ -652,9 +552,6 @@ resourceMetrics: dataPoints: - asInt: "2" attributes: - - key: database - value: - stringValue: local - key: type value: stringValue: active @@ -662,9 +559,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "838857" attributes: - - key: database - value: - stringValue: local - key: type value: stringValue: available @@ -672,9 +566,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "3" attributes: - - key: database - value: - stringValue: local - key: type value: stringValue: current @@ -687,10 +578,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "2097" - attributes: - - key: database - value: - stringValue: local startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: By @@ -701,9 +588,6 @@ resourceMetrics: dataPoints: - asInt: "0" attributes: - - key: database - value: - stringValue: local - key: operation value: stringValue: insert @@ -711,9 +595,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "0" attributes: - - key: database - value: - stringValue: local - key: operation value: stringValue: update @@ -721,9 +602,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "0" attributes: - - key: database - value: - stringValue: local - key: operation value: stringValue: delete @@ -736,10 +614,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: local startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: '{indexes}' @@ -749,10 +623,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "4096" - attributes: - - key: database - value: - stringValue: local startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: By @@ -763,9 +633,6 @@ resourceMetrics: dataPoints: - asInt: "117440512" attributes: - - key: database - value: - stringValue: local - key: type value: stringValue: resident @@ -773,9 +640,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "1585446912" attributes: - - key: database - value: - stringValue: local - key: type value: stringValue: virtual @@ -788,10 +652,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: local startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: '{objects}' @@ -801,10 +661,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "4096" - attributes: - - key: database - value: - stringValue: local startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" isMonotonic: true @@ -825,10 +681,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: testdb startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: '{collections}' @@ -839,9 +691,6 @@ resourceMetrics: dataPoints: - asInt: "2" attributes: - - key: database - value: - stringValue: testdb - key: type value: stringValue: active @@ -849,9 +698,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "838857" attributes: - - key: database - value: - stringValue: testdb - key: type value: stringValue: available @@ -859,9 +705,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "3" attributes: - - key: database - value: - stringValue: testdb - key: type value: stringValue: current @@ -874,10 +717,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "0" - attributes: - - key: database - value: - stringValue: testdb startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: By @@ -888,9 +727,6 @@ resourceMetrics: dataPoints: - asInt: "0" attributes: - - key: database - value: - stringValue: testdb - key: operation value: stringValue: insert @@ -898,9 +734,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "0" attributes: - - key: database - value: - stringValue: testdb - key: operation value: stringValue: update @@ -908,9 +741,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "0" attributes: - - key: database - value: - stringValue: testdb - key: operation value: stringValue: delete @@ -923,10 +753,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: testdb startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: '{indexes}' @@ -936,10 +762,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "4096" - attributes: - - key: database - value: - stringValue: testdb startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: By @@ -950,9 +772,6 @@ resourceMetrics: dataPoints: - asInt: "117440512" attributes: - - key: database - value: - stringValue: testdb - key: type value: stringValue: resident @@ -960,9 +779,6 @@ resourceMetrics: timeUnixNano: "1682363210542990000" - asInt: "1585446912" attributes: - - key: database - value: - stringValue: testdb - key: type value: stringValue: virtual @@ -975,10 +791,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "0" - attributes: - - key: database - value: - stringValue: testdb startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" unit: '{objects}' @@ -988,10 +800,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "4096" - attributes: - - key: database - value: - stringValue: testdb startTimeUnixNano: "1682363190539043000" timeUnixNano: "1682363210542990000" isMonotonic: true @@ -1000,7 +808,10 @@ resourceMetrics: name: otelcol/mongodbreceiver version: latest - resource: - attributes: [] + attributes: + - key: database + value: + stringValue: testdb scopeMetrics: - metrics: - description: The number of times an index has been accessed. @@ -1010,9 +821,6 @@ resourceMetrics: dataPoints: - asInt: "0" attributes: - - key: database - value: - stringValue: testdb - key: collection value: stringValue: orders diff --git a/receiver/mongodbreceiver/testdata/scraper/expected.yaml b/receiver/mongodbreceiver/testdata/scraper/expected.yaml index 891f5a1c6a73..0d60072a858a 100644 --- a/receiver/mongodbreceiver/testdata/scraper/expected.yaml +++ b/receiver/mongodbreceiver/testdata/scraper/expected.yaml @@ -296,50 +296,6 @@ resourceMetrics: scope: name: otelcol/mongodbreceiver version: latest - - resource: {} - scopeMetrics: - - metrics: - - description: The number of times an index has been accessed. - name: mongodb.index.access.count - sum: - aggregationTemporality: 2 - dataPoints: - - asInt: "0" - attributes: - - key: collection - value: - stringValue: products - - key: database - value: - stringValue: fakedatabase - startTimeUnixNano: "1000000" - timeUnixNano: "2000000" - unit: '{accesses}' - scope: - name: otelcol/mongodbreceiver - version: latest - - resource: {} - scopeMetrics: - - metrics: - - description: The number of times an index has been accessed. - name: mongodb.index.access.count - sum: - aggregationTemporality: 2 - dataPoints: - - asInt: "2" - attributes: - - key: collection - value: - stringValue: orders - - key: database - value: - stringValue: fakedatabase - startTimeUnixNano: "1000000" - timeUnixNano: "2000000" - unit: '{accesses}' - scope: - name: otelcol/mongodbreceiver - version: latest - resource: attributes: - key: database @@ -353,10 +309,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: fakedatabase startTimeUnixNano: "1000000" timeUnixNano: "2000000" unit: '{collections}' @@ -367,9 +319,6 @@ resourceMetrics: dataPoints: - asInt: "1" attributes: - - key: database - value: - stringValue: fakedatabase - key: type value: stringValue: active @@ -377,9 +326,6 @@ resourceMetrics: timeUnixNano: "2000000" - asInt: "838857" attributes: - - key: database - value: - stringValue: fakedatabase - key: type value: stringValue: available @@ -387,9 +333,6 @@ resourceMetrics: timeUnixNano: "2000000" - asInt: "3" attributes: - - key: database - value: - stringValue: fakedatabase - key: type value: stringValue: current @@ -402,10 +345,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "3141" - attributes: - - key: database - value: - stringValue: fakedatabase startTimeUnixNano: "1000000" timeUnixNano: "2000000" unit: By @@ -416,9 +355,6 @@ resourceMetrics: dataPoints: - asInt: "0" attributes: - - key: database - value: - stringValue: fakedatabase - key: operation value: stringValue: delete @@ -426,9 +362,6 @@ resourceMetrics: timeUnixNano: "2000000" - asInt: "1" attributes: - - key: database - value: - stringValue: fakedatabase - key: operation value: stringValue: insert @@ -436,9 +369,6 @@ resourceMetrics: timeUnixNano: "2000000" - asInt: "1" attributes: - - key: database - value: - stringValue: fakedatabase - key: operation value: stringValue: update @@ -451,10 +381,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "0" - attributes: - - key: database - value: - stringValue: fakedatabase startTimeUnixNano: "1000000" timeUnixNano: "2000000" unit: '{extents}' @@ -464,10 +390,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "1" - attributes: - - key: database - value: - stringValue: fakedatabase startTimeUnixNano: "1000000" timeUnixNano: "2000000" unit: '{indexes}' @@ -477,10 +399,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "16384" - attributes: - - key: database - value: - stringValue: fakedatabase startTimeUnixNano: "1000000" timeUnixNano: "2000000" unit: By @@ -491,9 +409,6 @@ resourceMetrics: dataPoints: - asInt: "82837504" attributes: - - key: database - value: - stringValue: fakedatabase - key: type value: stringValue: resident @@ -501,9 +416,6 @@ resourceMetrics: timeUnixNano: "2000000" - asInt: "1141899264" attributes: - - key: database - value: - stringValue: fakedatabase - key: type value: stringValue: virtual @@ -516,10 +428,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "2" - attributes: - - key: database - value: - stringValue: fakedatabase startTimeUnixNano: "1000000" timeUnixNano: "2000000" unit: '{objects}' @@ -529,10 +437,6 @@ resourceMetrics: aggregationTemporality: 2 dataPoints: - asInt: "16384" - attributes: - - key: database - value: - stringValue: fakedatabase startTimeUnixNano: "1000000" timeUnixNano: "2000000" isMonotonic: true @@ -540,3 +444,49 @@ resourceMetrics: scope: name: otelcol/mongodbreceiver version: latest + - resource: + attributes: + - key: database + value: + stringValue: fakedatabase + scopeMetrics: + - metrics: + - description: The number of times an index has been accessed. + name: mongodb.index.access.count + sum: + aggregationTemporality: 2 + dataPoints: + - asInt: "0" + attributes: + - key: collection + value: + stringValue: products + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + unit: '{accesses}' + scope: + name: otelcol/mongodbreceiver + version: latest + - resource: + attributes: + - key: database + value: + stringValue: fakedatabase + scopeMetrics: + - metrics: + - description: The number of times an index has been accessed. + name: mongodb.index.access.count + sum: + aggregationTemporality: 2 + dataPoints: + - asInt: "2" + attributes: + - key: collection + value: + stringValue: orders + startTimeUnixNano: "1000000" + timeUnixNano: "2000000" + unit: '{accesses}' + scope: + name: otelcol/mongodbreceiver + version: latest \ No newline at end of file