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

[receiver/cloudfoundry]: move datapoint level attributes to resource level #34905

Merged
merged 4 commits into from
Dec 20, 2024

Conversation

odubajDT
Copy link
Contributor

@odubajDT odubajDT commented Aug 28, 2024

Description:
Introduce a feature gate enable copying envelope tags to the metrics as resource attributes instead of datapoint attributes.

Link to tracking Issue: #34824

@github-actions github-actions bot requested a review from crobert-1 August 28, 2024 12:11
@odubajDT odubajDT changed the title [receiver/cloudfoundry]: duplicate datapoint attributes to resource [receiver/cloudfoundry]: move datapoint level attributes to resource level Aug 29, 2024
@odubajDT odubajDT marked this pull request as ready for review August 29, 2024 09:36
@odubajDT odubajDT requested a review from a team August 29, 2024 09:36
Copy link
Member

@crobert-1 crobert-1 left a comment

Choose a reason for hiding this comment

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

Just a high level review this round, I'll review again once naming is a bit more sorted out 👍

receiver/cloudfoundryreceiver/converter.go Outdated Show resolved Hide resolved
receiver/cloudfoundryreceiver/README.md Outdated Show resolved Hide resolved
receiver/cloudfoundryreceiver/README.md Outdated Show resolved Hide resolved
receiver/cloudfoundryreceiver/README.md Outdated Show resolved Hide resolved
receiver/cloudfoundryreceiver/converter.go Outdated Show resolved Hide resolved
@odubajDT odubajDT requested a review from crobert-1 August 30, 2024 05:52
for _, envelope := range envelopes {
if envelope != nil {
// There is no concept of startTime in CF loggregator, and we do not know the uptime of the component
// from which the metric originates, so just provide receiver start time as metric start time
convertEnvelopeToMetrics(envelope, libraryMetrics, cfr.receiverStartTime)
convertEnvelopeToMetrics(envelope, metrics.ResourceMetrics().AppendEmpty(), cfr.receiverStartTime)
Copy link
Member

Choose a reason for hiding this comment

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

To be able to conform to OTel metrics formatting with resource attributes, we need to try to create more of a hierarchy here with resource metrics, rather than a flat layout as we have without resource attributes here.

If two metrics share the same resource attributes, they should be in the same resource metric. However, the way the logic currently is written, each metric is in its own resource metric, regardless of whether or not it shares identical resource attributes with other metrics.

I could see two main ways of doing this:

  1. When converting envelopes to metrics, check if a resource metric already exists with the parsed resource attributes. If yes, insert the new metric into the existing resource metric.
  2. After all envelopes have been converted to metrics, deduplicate the resource metrics to merge them.

I think option 1. may be more straight forward and clear to follow the logic of, but I'd welcome more input here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, will adapt using the 1. option

Copy link
Contributor Author

Choose a reason for hiding this comment

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

adapted to the new logic, please have a look if you have time. Still adding some more tests, but not done with those yet, so please keep that i mind for now

namePrefix := envelope.Tags["origin"] + "."

if allowResourceAttributes.IsEnabled() {
Copy link
Member

Choose a reason for hiding this comment

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

As @jriguera pointed out in the original issue, not all of the attributes can be considered resource attributes. We should have a predefined list of resource attributes that are copied when the feature gate is enabled.

When the feature gate is enabled the predefined attributes are copied to resource attributes. The rest of the attributes will be datapoint attributes as they are today. The predefined list will only be resource attributes, they will not be both resource attributes and datapoint attributes.

     -> org.cloudfoundry.index: Str(4b406f26-f1ec-4d66-8b92-f09ab6105d46)
     -> org.cloudfoundry.ip: Str(10.0.4.8)
     -> org.cloudfoundry.job: Str(compute)
     -> org.cloudfoundry.instance_group: Str(compute)
     -> org.cloudfoundry.origin: Str(system_metrics_agent)
     -> org.cloudfoundry.source_id: Str(system_metrics_agent)

@jriguera From your comment on the original issue it sounded like you don't believe the above attributes should be considered resource attributes. Is that correct? If so, can you expand your reasoning? My understanding is that since they describe the resource the metrics are coming from they can be considered resource attributes. Source

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok so the list above is the full list of resource attributes, is that correct?

Copy link
Contributor Author

@odubajDT odubajDT Sep 2, 2024

Choose a reason for hiding this comment

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

AFAIK, this should be the full list of resource attributes, please correct me if I am missing something

-> org.cloudfoundry.index
-> org.cloudfoundry.ip
-> org.cloudfoundry.deployment
-> org.cloudfoundry.id
-> org.cloudfoundry.job
-> org.cloudfoundry.product
-> org.cloudfoundry.instance_group
-> org.cloudfoundry.instance_id
-> org.cloudfoundry.origin
-> org.cloudfoundry.system_domain
-> org.cloudfoundry.source_id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

adapted the logic, here is the list (for now) of resource attributes

@odubajDT odubajDT marked this pull request as draft September 2, 2024 10:53
@odubajDT odubajDT force-pushed the move-attributes branch 2 times, most recently from 6cfb0b8 to 827da54 Compare September 3, 2024 09:45
@odubajDT odubajDT marked this pull request as ready for review September 3, 2024 11:48
@odubajDT odubajDT force-pushed the move-attributes branch 2 times, most recently from 8c6601c to 6f34911 Compare September 10, 2024 13:16
@github-actions github-actions bot added the cmd/otelcontribcol otelcontribcol command label Sep 10, 2024
@odubajDT
Copy link
Contributor Author

@crobert-1 would you have time to take another look?

@crobert-1
Copy link
Member

@crobert-1 would you have time to take another look?

I was hoping to hear back from @jriguera to try and get a consensus around which attributes should be moved to resource attributes here. If we don't hear back soon we can move this forward. 👍

@odubajDT odubajDT requested a review from a team as a code owner September 23, 2024 06:31
@jriguera
Copy link
Contributor

I will continue with my reviewing tomorrow

@odubajDT
Copy link
Contributor Author

I will continue with my reviewing tomorrow

Hi @jriguera, any other comments?

@odubajDT
Copy link
Contributor Author

odubajDT commented Oct 4, 2024

cc @jriguera

@odubajDT
Copy link
Contributor Author

cc @jriguera

Copy link
Contributor

@jriguera jriguera left a comment

Choose a reason for hiding this comment

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

Apart of the issues with names of some tests and the flags, it looks good to me.

If I have enough time next days, I would like to test it in my environment.

@odubajDT
Copy link
Contributor Author

@crobert-1 any objections against merging this?

@jriguera
Copy link
Contributor

@odubajDT I think @crobert-1 is not available for now, we need to find other person to review and approve the merge

@jriguera
Copy link
Contributor

After this is merged, I also will need to apply the same functionality to traces (another PR as a draft which I need to finish)

@odubajDT odubajDT force-pushed the move-attributes branch 2 times, most recently from 8d75948 to 5cb6ed4 Compare December 4, 2024 13:35
Copy link
Member

@dmitryax dmitryax left a comment

Choose a reason for hiding this comment

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

The code LGTM

# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking
Copy link
Member

Choose a reason for hiding this comment

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

Is it breaking, given that the feature gate is in alpha? Feel free to submit a PR changing it to enhancement if you agree.

@dmitryax dmitryax merged commit 96368fa into open-telemetry:main Dec 20, 2024
161 checks passed
@github-actions github-actions bot added this to the next release milestone Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants