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

[chore] Support connector in metrics.go.tmpl NewMetricsBuilder #12403

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Dainerx
Copy link
Contributor

@Dainerx Dainerx commented Feb 17, 2025

Description

I discovered this issue while trying to upgrade the opentelemetry collector from v0.111.0 to v0.119.0 that was released two weeks ago. To reproduce please take a look at the issue below.

Link to tracking issue

Fixes #12402

Testing

Run make generate on a processor or connector component

@Dainerx Dainerx requested review from dmitryax and a team as code owners February 17, 2025 10:29
@Dainerx Dainerx force-pushed the fix/cmd/mdatada-gen-metrics branch from c7f4818 to bb83847 Compare February 17, 2025 10:35
Copy link

codecov bot commented Feb 17, 2025

Codecov Report

Attention: Patch coverage is 90.62500% with 45 lines in your changes missing coverage. Please review.

Project coverage is 91.97%. Comparing base (0b6c04b) to head (c496a2f).

Files with missing lines Patch % Lines
...leconnector/internal/metadata/generated_metrics.go 91.83% 27 Missing and 2 partials ⚠️
...pleconnector/internal/metadata/generated_config.go 82.85% 8 Missing and 4 partials ⚠️
...econnector/internal/metadata/generated_resource.go 91.11% 4 Missing ⚠️

❌ Your patch check has failed because the patch coverage (90.62%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12403      +/-   ##
==========================================
- Coverage   92.00%   91.97%   -0.03%     
==========================================
  Files         469      473       +4     
  Lines       25355    25835     +480     
==========================================
+ Hits        23327    23762     +435     
- Misses       1619     1658      +39     
- Partials      409      415       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Dainerx Dainerx force-pushed the fix/cmd/mdatada-gen-metrics branch from bb83847 to 4355c04 Compare February 17, 2025 16:22
@bogdandrutu
Copy link
Member

@Dainerx what other component do you have that emits metrics?

@Dainerx
Copy link
Contributor Author

Dainerx commented Feb 17, 2025

@bogdandrutu in my use case, processors and connectors do emit metrics.

My main concern is the if statement surrounding only the function signature. Also, I expected adding a new class in the metadata schema.

@bogdandrutu
Copy link
Member

My main concern is the if statement surrounding only the function signature. Also, I expected adding a new class in the metadata schema.

That should be fixed.

processors and connectors do emit metrics.

How come? I can see why connectors may do it, but how come the processors?

@Dainerx
Copy link
Contributor Author

Dainerx commented Feb 18, 2025

How come? I can see why connectors may do it, but how come the processors?

Processors can have mutate data capabilities, the metrics generation processor does generate metrics. Although, this is possible, I agree with you it's not a best practice to use a processor to generate metrics.

I am fine with only supporting connector scrapper, and receiver. We should also:

  1. Add a sample connector to be used for testing purposes to check the output of mdatagen against it
  2. Update the README file.

WDYT?

@Dainerx Dainerx changed the title [chore] Remove conditional statement on metrics.go.tmpl NewMetricsBuilder [chore] Support connector in metrics.go.tmpl NewMetricsBuilder Feb 18, 2025
@Dainerx Dainerx force-pushed the fix/cmd/mdatada-gen-metrics branch from 4355c04 to 9dded0f Compare February 18, 2025 12:28
@bogdandrutu
Copy link
Member

I am ok with this proposal.

@Dainerx Dainerx force-pushed the fix/cmd/mdatada-gen-metrics branch 2 times, most recently from 0a0f205 to 7d5fcd2 Compare February 18, 2025 16:57
Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what changed, but this looks very strange that every line is updated.

@Dainerx Dainerx force-pushed the fix/cmd/mdatada-gen-metrics branch 2 times, most recently from 31d7313 to 54a8c7c Compare February 20, 2025 12:14
@Dainerx Dainerx force-pushed the fix/cmd/mdatada-gen-metrics branch from d410125 to 4207422 Compare February 26, 2025 17:51
description: Attribute with a map value.
type: map

metrics:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this added to a connector? The metrics section is supposed to be set on scraping receivers only

Copy link
Member

@dmitryax dmitryax Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed the discussion above... Do you have a connector emitting metrics open sourced? It's not in contrib, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed the discussion above... Do you have a connector emitting metrics open sourced? It's not in contrib, right?

Right

@@ -13,15 +13,15 @@ generated_package_name: string
# Required for components (Optional for subcomponents): A high-level view of the development status and use of this component
status:
# Required: The class of the component (For example receiver)
class: <receiver|processor|exporter|connector|extension|cmd|pkg|scraper|converter|provider>
class: <receiver|processor|exporter|connector|extension|scraper|cmd|pkg>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert changes here

@Dainerx Dainerx force-pushed the fix/cmd/mdatada-gen-metrics branch from 4207422 to 380f3b1 Compare February 27, 2025 17:09
Copy link

linux-foundation-easycla bot commented Feb 27, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: Dainerx / name: Oussama Ben Ghorbel (c496a2f)

@Dainerx Dainerx force-pushed the fix/cmd/mdatada-gen-metrics branch 4 times, most recently from 26d7c6d to acdde27 Compare February 28, 2025 14:05
@Dainerx Dainerx force-pushed the fix/cmd/mdatada-gen-metrics branch from acdde27 to c496a2f Compare February 28, 2025 15:10
@@ -293,7 +290,7 @@ func (mb *MetricsBuilder) EmitForResource(options ...ResourceMetricsOption) {
rm.SetSchemaUrl(conventions.SchemaURL)
{{- end }}
ils := rm.ScopeMetrics().AppendEmpty()
ils.Scope().SetName(ScopeName)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why whit change?

@@ -13,7 +13,7 @@ generated_package_name: string
# Required for components (Optional for subcomponents): A high-level view of the development status and use of this component
status:
# Required: The class of the component (For example receiver)
class: <receiver|processor|exporter|connector|extension|cmd|pkg|scraper|converter|provider>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

@bogdandrutu bogdandrutu dismissed their stale review February 28, 2025 18:10

No longer blocking this.

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.

metadata generated_metrics compilation error (v119.0)
4 participants