Skip to content

[connector/spanmetricsconnector] add separate additional dimensions for calls and duration metrics #39134

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

Merged
merged 3 commits into from
May 2, 2025

Conversation

Frapschen
Copy link
Contributor

Description

fix: #36805

@Frapschen Frapschen requested a review from a team as a code owner April 3, 2025 09:47
@Frapschen Frapschen requested a review from MovieStoreGuy April 3, 2025 09:47
@github-actions github-actions bot requested a review from portertech April 3, 2025 09:47
@MovieStoreGuy MovieStoreGuy changed the title [connector/spanmetricsconnector] add separate additional dmensions for calls and duration metrics [connector/spanmetricsconnector] add separate additional dimensions for calls and duration metrics Apr 8, 2025
@Frapschen
Copy link
Contributor Author

@portertech Hi please review

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@Frapschen
Copy link
Contributor Author

wait PR #39664

@@ -422,9 +438,8 @@ func (p *connectorImp) aggregateMetrics(traces ptrace.Traces) {

rscAndEventAttrs.EnsureCapacity(resourceAttr.Len() + event.Attributes().Len())
resourceAttr.CopyTo(rscAndEventAttrs)
// We cannot use CopyTo because it overrides the existing keys.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should keep this comment because what cannot be done is to do event.Attributes().CopyTo(rscAdnEventAttrs)

Copy link
Contributor Author

@Frapschen Frapschen Apr 30, 2025

Choose a reason for hiding this comment

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

Note that event.Attributes().CopyTo(rscAdnEventAttrs) will overwrite the existing data in rscAdnEventAttrs.

On the other hand, using rscAndEventAttrs.PutStr(k, v.Str()) may lead to loss of type information due to v.Str().

A better alternative is to use v.CopyTo(rscAndEventAttrs.PutEmpty(k)), which preserves the type information, making the comment unnecessary.

For a similar use case:

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with your comments and fine changing this from rscAndEventAttrs.PutStr to v.CopyTo(rscAndEventAttrs.PutEmpty(k)) (didn't know we can do this) I changed from event.Attributes().CopyTo(rscAdnEventAttrs) to the current code in my previous PR becuase of the issue you mentioned.

The reason why I would like to preserve the comment is because I don't want somebody in the future replace this:

event.Attributes().Range(func(k string, v pcommon.Value) bool {
							v.CopyTo(rscAndEventAttrs.PutEmpty(k))
							return true
						})

with this:

event.Attributes().CopyTo(rscAdnEventAttrs)

and introduce a regression. Because it is not obvious that .CopyTo replaces evertyhing.

@@ -422,9 +438,8 @@ func (p *connectorImp) aggregateMetrics(traces ptrace.Traces) {

rscAndEventAttrs.EnsureCapacity(resourceAttr.Len() + event.Attributes().Len())
resourceAttr.CopyTo(rscAndEventAttrs)
// We cannot use CopyTo because it overrides the existing keys.
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with your comments and fine changing this from rscAndEventAttrs.PutStr to v.CopyTo(rscAndEventAttrs.PutEmpty(k)) (didn't know we can do this) I changed from event.Attributes().CopyTo(rscAdnEventAttrs) to the current code in my previous PR becuase of the issue you mentioned.

The reason why I would like to preserve the comment is because I don't want somebody in the future replace this:

event.Attributes().Range(func(k string, v pcommon.Value) bool {
							v.CopyTo(rscAndEventAttrs.PutEmpty(k))
							return true
						})

with this:

event.Attributes().CopyTo(rscAdnEventAttrs)

and introduce a regression. Because it is not obvious that .CopyTo replaces evertyhing.

@Frapschen Frapschen requested a review from iblancasa May 1, 2025 00:29
@iblancasa
Copy link
Contributor

@open-telemetry/collector-contrib-approvers can you merge this?

@songy23 songy23 merged commit dbe4075 into open-telemetry:main May 2, 2025
190 checks passed
@github-actions github-actions bot added this to the next release milestone May 2, 2025
vincentfree pushed a commit to ing-bank/opentelemetry-collector-contrib that referenced this pull request May 6, 2025
…or calls and duration metrics (open-telemetry#39134)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
fix: open-telemetry#36805
vincentfree pushed a commit to ing-bank/opentelemetry-collector-contrib that referenced this pull request May 20, 2025
…or calls and duration metrics (open-telemetry#39134)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
fix: open-telemetry#36805
dragonlord93 pushed a commit to dragonlord93/opentelemetry-collector-contrib that referenced this pull request May 23, 2025
…or calls and duration metrics (open-telemetry#39134)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
fix: open-telemetry#36805
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.

Separate Dimensions for calls and duration metrics in Span Metrics
6 participants