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

Collector Reporter #208

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

dmathieu
Copy link
Member

This sets up a new reporter that allows passing data to a collector consumer.

@dmathieu
Copy link
Member Author

I've done this as close as possible from what the OTLP reporter does.

@rockdaboot
Copy link
Contributor

This adds a lot of code duplication, collector_reporter is basically a copy of otlp_reporter. What is the rationale behind that decision?

@dmathieu
Copy link
Member Author

While the way it works is very similar, the data types are very different. We need to use the pdata data types for communicate with the collector.
This reporter also doesn't handle gRPC.

Ultimately, the OTLP reporter should also disappear.

@rockdaboot
Copy link
Contributor

Ultimately, the OTLP reporter should also disappear.

That makes sense, hopefully in a relatively near future :)

@dmathieu
Copy link
Member Author

dmathieu commented Nov 4, 2024

@open-telemetry/ebpf-profiler-approvers this is ready for review.

// Next step: Dynamically configure the size of this LRU.
// Currently, we use the length of the JSON array in
// hostmetadata/hostmetadata.json.
hostmetadata, err := lru.NewSynced[string, string](115, hashString)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what the rationale was for choosing an LRU here instead of a map 🤔
We don't have to change it in this PR, though.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's just the same than we use in the OTLP reporter.

Copy link
Contributor

Choose a reason for hiding this comment

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

I know, same thoughts on that code. Here, we just copied technical debt. But I am just raising this for awareness, it's not meant as a blocker.

reporter/collector_reporter.go Outdated Show resolved Hide resolved
reporter/collector_reporter.go Outdated Show resolved Hide resolved
Copy link
Contributor

@rockdaboot rockdaboot left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@florianl florianl left a comment

Choose a reason for hiding this comment

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

There are mostly exact code duplications. I'm aware that go.opentelemetry.io/collector/pdata/pprofile is not an exact replacement for profiles "go.opentelemetry.io/proto/otlp/profiles/v1experimental" but the amount of duplication is significant.


// ReportTraceEvent enqueues reported trace events for the Collector reporter.
func (r *CollectorReporter) ReportTraceEvent(trace *libpf.Trace, meta *TraceEventMeta) {
if r.nextConsumer == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering, if this should generate a log in some way. So far, there can only be a single reporter. If CollectorReporter is configured as such single reporter, then silently returning here will result in massive data/information loss without notice.

Copy link
Member Author

Choose a reason for hiding this comment

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

This case can only happen in tests, where we mock structs. At runtime, the collector will refuse to boot if the data is exported nowhere.

}

// lookupCgroupv2 returns the cgroupv2 ID for pid.
func (r *CollectorReporter) lookupCgroupv2(pid libpf.PID) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a copy of func (r *OTLPReporter) lookupCgroupv2(pid libpf.PID) (string, error) {..}. Can we reduce duplicate code?
In both implementations the reporter details matter less and the common ground is the use of cgroupv2ID *lru.SyncedLRU[libpf.PID, string].

Copy link
Member Author

Choose a reason for hiding this comment

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

See #227

reporter/collector_reporter.go Outdated Show resolved Hide resolved

// addPdataProfileAttributes adds attributes to Profile.attribute_table and returns
// the indices to these attributes.
func addPdataProfileAttributes(profile pprofile.Profile,
Copy link
Contributor

Choose a reason for hiding this comment

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

With code duplication we miss out on changes like #212 in some parts.

case int64:
strVal := strconv.FormatInt(val, 10)
attributeCompositeKey = attr.key + "_" + strVal
attributeValue = strVal
Copy link
Contributor

@florianl florianl Nov 8, 2024

Choose a reason for hiding this comment

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

While #212 differentiate between string and int64 this now encodes again everything as string. process.PID are considered to be a numeric value by OTel SemConv, they should be added as int64 to the AttributeTable instead of string.

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.

3 participants