Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mdatagen] allow adding resource_attribute warnings #27257

Merged

Conversation

povilasv
Copy link
Contributor

@povilasv povilasv commented Sep 28, 2023

Description:

allow adding resource_attribute warnings

Link to tracking Issue: #19174
Testing:

  • Generated unit tests
  • Tested manually with some changes to k8sclusterreceiver:
  k8s.kubelet.version:
    description: The version of Kubelet running on the node.
    type: string
    enabled: false
    warnings:
      if_configured: This resource_attribute is deprecated and will be removed soon.

  opencensus.resourcetype:
    description: The OpenCensus resource type.
    type: string
    enabled: true
    warnings:
      if_enabled: This resource_attribute is deprecated and will be removed soon.

Gives the following output:

{"level":"warn","ts":1695985300.0413303,"caller":"metadata/generated_metrics.go:2201","msg":"[WARNING] `k8s.kubelet.version` should not be configured: This resource_attribute is deprecated and will be removed soon.","kind":"receiver","name":"k8s_cluster","data_type":"metrics"}     
{"level":"warn","ts":1695985300.041354,"caller":"metadata/generated_metrics.go:2207","msg":"[WARNING] `opencensus.resourcetype` should not be enabled: This resource_attribute is deprecated and will be removed soon.","kind":"receiver","name":"k8s_cluster","data_type":"metrics"}

Documentation:

@github-actions github-actions bot added the cmd/mdatagen mdatagen command label Sep 28, 2023
@povilasv povilasv force-pushed the main-mdatagen-resource-warnings branch from 7edff94 to a315d6b Compare September 28, 2023 12:46
@povilasv
Copy link
Contributor Author

povilasv commented Oct 5, 2023

👋 FYI this PR changes generated ResourceAttributeConfig for a lot of receivers and processors.
It adds an internal field enabledSetByUser, so we can detect when user manually enabled resource attribute (vs enabled by default).

Example of change:


	enabledSetByUser bool
}

func (rac *ResourceAttributeConfig) Unmarshal(parser *confmap.Conf) error {
	if parser == nil {
		return nil
	}
	err := parser.Unmarshal(rac, confmap.WithErrorUnused())
	if err != nil {
		return err
	}
	rac.enabledSetByUser = parser.IsSet("enabled")
	return nil
}

I had to update some receiver tests so that it ignores this internal field

@povilasv povilasv force-pushed the main-mdatagen-resource-warnings branch 3 times, most recently from 670e248 to 8e368ea Compare October 5, 2023 12:16
@dmitryax dmitryax merged commit 91643ba into open-telemetry:main Oct 10, 2023
85 checks passed
@dmitryax
Copy link
Member

Thanks @povilasv!

@github-actions github-actions bot added this to the next release milestone Oct 10, 2023
@povilasv povilasv deleted the main-mdatagen-resource-warnings branch October 10, 2023 08:16
jmsnll pushed a commit to jmsnll/opentelemetry-collector-contrib that referenced this pull request Nov 12, 2023
…7257)

**Description:**  allow adding resource_attribute warnings

**Link to tracking Issue:**
open-telemetry#19174

**Testing:**
- Generated unit tests
- Tested manually with some changes to k8sclusterreceiver:

```
  k8s.kubelet.version:
    description: The version of Kubelet running on the node.
    type: string
    enabled: false
    warnings:
      if_configured: This resource_attribute is deprecated and will be removed soon.

  opencensus.resourcetype:
    description: The OpenCensus resource type.
    type: string
    enabled: true
    warnings:
      if_enabled: This resource_attribute is deprecated and will be removed soon.
```

Gives the following output:
```
{"level":"warn","ts":1695985300.0413303,"caller":"metadata/generated_metrics.go:2201","msg":"[WARNING] `k8s.kubelet.version` should not be configured: This resource_attribute is deprecated and will be removed soon.","kind":"receiver","name":"k8s_cluster","data_type":"metrics"}     
{"level":"warn","ts":1695985300.041354,"caller":"metadata/generated_metrics.go:2207","msg":"[WARNING] `opencensus.resourcetype` should not be enabled: This resource_attribute is deprecated and will be removed soon.","kind":"receiver","name":"k8s_cluster","data_type":"metrics"}
 ```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants