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

feature request: compatibility between published Go types to collector's own types #4254

Closed
errordeveloper opened this issue Oct 25, 2021 · 8 comments
Labels

Comments

@errordeveloper
Copy link

errordeveloper commented Oct 25, 2021

Right now it's not easily possible to covert data that was constructed using published Go types (go.opentelemetry.io/proto/otlp) and the internal version of the same (go.opentelemetry.io/collector/model). This makes it very complicated for someone to build a collector component externally, e.g. they need to fork the collector repo or do other tricks, like marshalling and unmarshalling. Some types can be constructed using exported helpers, but it's hard to work with those and many fields are not settable.

@errordeveloper errordeveloper changed the title conversion between published Go types and collector's own types feature request: compatibility between published Go types to collector's own types Oct 25, 2021
@bogdandrutu
Copy link
Member

This is intentionally, and encourage to construct use directly the go.opentelemetry.io/collector/model/pdata instead of go.opentelemetry.io/proto/otlp

@bogdandrutu
Copy link
Member

Alternative you can "Marshal" the go "otlp" and unmarshal as "pdata"

@errordeveloper
Copy link
Author

This is intentionally, and encourage to construct use directly the go.opentelemetry.io/collector/model/pdata instead of go.opentelemetry.io/proto/otlp

I found it very limited and unintuitive to use.

@errordeveloper
Copy link
Author

Alternative you can "Marshal" the go "otlp" and unmarshal as "pdata"

Sure, if you don't care about performance...

@bogdandrutu
Copy link
Member

" many fields are not settable." all the fields are settable, we are actually using them to construct everything.

@errordeveloper
Copy link
Author

errordeveloper commented Nov 11, 2021

I've tried, and couldn't rewrite this code: https://github.com/cilium/hubble-otel/blob/acc3a282a62b35fa432b1d47200904082fbaf797/common/common.go#L178

It wasn't possible to handle AnyValue in the generic way with pdata. I don't remember exact details now, I'm afraid.

@errordeveloper
Copy link
Author

@bogdandrutu this illustrates what I am actually referring to:

// NewResourceSpans creates a new empty ResourceSpans.
//
// This must be used only in testing code since no "Set" method available.
func NewResourceSpans() ResourceSpans {
return newResourceSpans(&otlptrace.ResourceSpans{})
}

The thing is that Inside the collector you can set any fields you like cause internal structs can still be accessed, but not in another project... You see what I'm saying now?

@bogdandrutu
Copy link
Member

bogdandrutu commented Nov 11, 2021

@errordeveloper no I don't see what you are trying to say. If you need to create a new "ResourceSpans" you do from top to bottom:

td := pdata.NewTraces()
rs := td.ResourceSpans().AppendEmpty()

vs

rs := pdata.NewResourceSpans()
pdata.NewTraces().Append(rs) // or Set.

This is optimal to reduce the amount of allocations, as well as avoid common mistakes as "sharing" the same object between multiple data objects.

The thing is that Inside the collector you can set any fields you like cause internal structs can still be accessed, but not in another project...

Inside the collector we use "model" module and we don't have access to internal as any other project.

@github-actions github-actions bot added the Stale label Nov 12, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants