Skip to content

Commit

Permalink
[receiver/mongodb] add receiver.mongodb.removeDatabaseAttr Alpha feat…
Browse files Browse the repository at this point in the history
…ure gate (#27621)

**Description:** 
Add `receiver.mongodb.removeDatabaseAttr` Alpha feature gate to remove
duplicate database name attribute.

**Link to tracking Issue:** 

#24972

**Testing:** 
make generate
make chlog-validate
go test for mongodbreceiver

Manually tested, built image and manually enabled and disabled this
feature gate.

This is the warning we publish:

> 2023-10-15 17:06:29 2023-10-15T09:06:29.358Z warn
[email protected]/scraper.go:62
Feature gate receiver.mongodb.removeDatabaseAttr is not enabled. Please
see the README for more information:
https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/mongodbreceiver/README.md
{"kind": "receiver", "name": "mongodb", "data_type": "metrics"}


**Documentation:**

---------

Signed-off-by: sakulali <[email protected]>
  • Loading branch information
sakulali authored Nov 27, 2023
1 parent de3b9c0 commit c27d056
Show file tree
Hide file tree
Showing 16 changed files with 582 additions and 942 deletions.
27 changes: 27 additions & 0 deletions .chloggen/mongodbreceiver-duplicate-attribute-24972.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: 'bug_fix'

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: 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]
12 changes: 12 additions & 0 deletions receiver/mongodbreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
50 changes: 0 additions & 50 deletions receiver/mongodbreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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`` |
Expand All @@ -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`` |
Expand All @@ -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`` |
Expand All @@ -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`` |
Expand Down
2 changes: 1 addition & 1 deletion receiver/mongodbreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions receiver/mongodbreceiver/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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) {
Expand Down
Loading

0 comments on commit c27d056

Please sign in to comment.