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

Update attribute processor for stable metrics #524

Merged
merged 2 commits into from
Mar 21, 2024

Conversation

yangjian
Copy link
Contributor

@yangjian yangjian commented Mar 7, 2024

Previously AttribtueProcessor is a class and not open. It can't be customized externally. Now it's changed to procotol and its static functions are moved into SimpleAttributeProcessor (now it's public).

Also duplicated NoopAttributesProcessor is removed and more tests are added.

Copy link

linux-foundation-easycla bot commented Mar 7, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: yangjian / name: Yang Jian (6e5ad4b)
  • ✅ login: nachoBonafonte / name: Ignacio Bonafonte (7a271ed)

@yangjian yangjian force-pushed the main branch 2 times, most recently from a949fa0 to 5acd512 Compare March 7, 2024 02:08
@nachoBonafonte
Copy link
Member

I would like to understand the use case for this change, whyy the need to inherit AttributeProcessor instead of extending it

@yangjian
Copy link
Contributor Author

yangjian commented Mar 8, 2024

There're common labels for all metrics in our iOS app. Attribute processor can be used to merge them into final labels. But one of these labels can be changed by user or server. Customized attribute processor can be more flexible to support it. Something like this:

class GlobalSharedLabels: AttributeProcessor {
    let attributes: ManagedAtomic<AtomicContainer<[String: AttributeValue]>>

    public updateLabels(...) {
        attributes.store(...)
    }

    public func process(incoming: [String: AttributeValue]) -> [String: AttributeValue] {
        incoming.merging(attributes.load(...), uniquingKeysWith: { $1 })
    }
}

Alternatively, it can return a SimpleAttributeProcessor, but it isn't exported before.

Previously AttribtueProcessor is a class and not open. It can't be
customized externally. Now it's changed to procotol and its static
functions are moved into SimpleAttributeProcessor (now it's public).

Also duplicated NoopAttributesProcessor is removed and more tests are
added.
Copy link
Member

@nachoBonafonte nachoBonafonte left a comment

Choose a reason for hiding this comment

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

LGTM, I had some doubts at the beginning but keeping the base code as part of the protocol with an extension makes total sense. Thanks a lot for your contribution,

Copy link

codecov bot commented Mar 21, 2024

Codecov Report

Attention: Patch coverage is 69.23077% with 8 lines in your changes are missing coverage. Please review.

❗ No coverage uploaded for pull request base (main@4d1502b). Click here to learn what that means.

Files Patch % Lines
...TelemetrySdk/Metrics/Stable/View/ViewBuilder.swift 0.00% 5 Missing ⚠️
...rySdk/Metrics/Stable/View/AttributeProcessor.swift 85.71% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #524   +/-   ##
=======================================
  Coverage        ?   67.45%           
=======================================
  Files           ?      335           
  Lines           ?    14585           
  Branches        ?        0           
=======================================
  Hits            ?     9839           
  Misses          ?     4746           
  Partials        ?        0           

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

@nachoBonafonte nachoBonafonte merged commit 1535a05 into open-telemetry:main Mar 21, 2024
7 checks passed
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.

2 participants