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

[ENHANCEMENT] Use resource attributes for multiplying span metrics #4210

Merged
merged 4 commits into from
Oct 22, 2024

Conversation

JunhoeKim
Copy link
Contributor

@JunhoeKim JunhoeKim commented Oct 21, 2024

What this PR does:
The property previously named span_multiplier_key is now renamed to multiplier_key, utilizing the resource attributes.
Which issue(s) this PR fixes:
Fixes #4202

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@CLAassistant
Copy link

CLAassistant commented Oct 21, 2024

CLA assistant check
All committers have signed the CLA.

CHANGELOG.md Outdated
@@ -1,5 +1,5 @@
## main / unreleased

* [ENHANCEMENT] The property previously named span_multiplier_key is now renamed to multiplier_key, utilizing the resource attributes. [#4210](https://github.com/grafana/tempo/pull/4210)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be marked as a breaking change since the configuration name is changing from span_multiplier_key to multiplier_key? We'll need to make sure that we add this to the upgrade notes for the next release.

Copy link
Contributor

@knylander-grafana knylander-grafana left a comment

Choose a reason for hiding this comment

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

Thank you for updating the docs with your changes! Much appreciated!

Docs approved, but I'm not adding an approval since there are code changes. I can only approve doc changes.

Should we consider the config property rename to be a breaking change?

Copy link
Member

@joe-elliott joe-elliott left a comment

Choose a reason for hiding this comment

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

thanks for giving this a shot!

if kv.Key == ratioKey {
v := kv.Value.GetDoubleValue()
if v > 0 {
spanMultiplier = 1.0 / v
multiplier = 1.0 / v
Copy link
Member

Choose a reason for hiding this comment

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

we should return after we find the appropriate value. no reason to keep iterating. i'm not sure why the original code didn't return.

if ratioKey != "" {
for _, kv := range span.Attributes {
for _, kv := range append(span.Attributes, rs.Attributes...) {
Copy link
Member

Choose a reason for hiding this comment

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

this append will unnecessarily alloc. it would be preferred to just iterate each attribute slice separately.

# Attribute Key to multiply span metrics
[span_multiplier_key: <string> | default = ""]
# Attribute Key to multiply metrics
[multiplier_key: <string> | default = ""]
Copy link
Member

Choose a reason for hiding this comment

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

we can change this config name, but we need to mark it a breaking change. i don't see a particularly strong reason to change it. the behavior has changed some, but it still is a "multiplier for span metrics".

@@ -412,8 +412,8 @@ metrics_generator:
# Enable traces_target_info metrics
[enable_target_info: <bool> | default = false]

# Attribute Key to multiply span metrics
[span_multiplier_key: <string> | default = ""]
# Attribute Key to multiply metrics
Copy link
Member

Choose a reason for hiding this comment

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

we should indicate that the attribute name is searched for in both resource and span level attributes

@JunhoeKim
Copy link
Contributor Author

@knylander-grafana @joe-elliott
Thank you for the review. I have updated it to ensure no breaking changes occur based on your feedback.

Copy link
Member

@joe-elliott joe-elliott left a comment

Choose a reason for hiding this comment

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

nice addition! thank you 🙏

@joe-elliott joe-elliott merged commit ea7ae52 into grafana:main Oct 22, 2024
17 checks passed
@JunhoeKim JunhoeKim deleted the feat/enhance-span-multiplier branch October 22, 2024 23:28
knylander-grafana pushed a commit that referenced this pull request Oct 29, 2024
…4210)

* feat: Use resource attribute too, rename property from span_multiplier_key to multiplier_key

* chore: update CHANGELOG.md

* fix: apply review

* fix: minor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable SpanMultiplier Calculation from Resource Attributes, not Just Span Attributes
4 participants