Skip to content

Remove usage of gogoproto and generate the structs with pdatagen#14069

Closed
bogdandrutu wants to merge 1 commit into
open-telemetry:mainfrom
bogdandrutu:rm-gogo-proto
Closed

Remove usage of gogoproto and generate the structs with pdatagen#14069
bogdandrutu wants to merge 1 commit into
open-telemetry:mainfrom
bogdandrutu:rm-gogo-proto

Conversation

@bogdandrutu
Copy link
Copy Markdown
Member

@bogdandrutu bogdandrutu commented Oct 22, 2025

This is a huge PR that does not touch any of the critical logic "marshaling/unmarshaling" of the pdata. We have e2e tests with the go official generated protobufs to ensure nothing breaks.

The easy way to review this is to only look at what change publicly in "pdata/pcommon", "pdata/plog", "pdata/ptrace", "pdata/pmetric", "pdata/pprofile", "pdata/xpdata".

This PR also switches the xpada request to use the same generating mechanism as pdatagen.

Binary size before:

42246018 bin/otelcorecol_darwin_arm64

Binary size after:

40709202 bin/otelcorecol_darwin_arm64

@bogdandrutu bogdandrutu requested review from a team, dmathieu, dmitryax and mx-psi as code owners October 22, 2025 20:34
@bogdandrutu bogdandrutu marked this pull request as draft October 22, 2025 20:35
@bogdandrutu bogdandrutu force-pushed the rm-gogo-proto branch 10 times, most recently from 5b3da2e to 29032fa Compare October 23, 2025 22:52
@bogdandrutu bogdandrutu marked this pull request as ready for review October 23, 2025 22:52
@bogdandrutu bogdandrutu force-pushed the rm-gogo-proto branch 2 times, most recently from 0180604 to 217b0f4 Compare October 23, 2025 23:18
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 23, 2025

Codecov Report

❌ Patch coverage is 96.36185% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.23%. Comparing base (0f3b0c9) to head (4d508ba).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pdata/internal/generated_proto_anyvalue.go 97.25% 9 Missing and 5 partials ⚠️
pdata/internal/generated_proto_arrayvalue.go 92.90% 5 Missing and 5 partials ⚠️
pdata/internal/generated_proto_entityref.go 96.36% 4 Missing and 4 partials ⚠️
pdata/internal/generated_proto_exemplar.go 96.57% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14069      +/-   ##
==========================================
- Coverage   92.50%   92.23%   -0.28%     
==========================================
  Files         660      656       -4     
  Lines       36196    41110    +4914     
==========================================
+ Hits        33483    37916    +4433     
- Misses       1892     2183     +291     
- Partials      821     1011     +190     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bogdandrutu bogdandrutu force-pushed the rm-gogo-proto branch 4 times, most recently from d3b139a to e30fc3c Compare October 24, 2025 15:38
Comment on lines 31 to -76
@@ -41,7 +41,7 @@ func new{{ .structName }}(orig *{{ .originFullName }}, state *internal.State) {{
// This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice,
// OR directly access the member if this is embedded in another struct.
func New{{ .structName }}() {{ .structName }} {
return new{{ .structName }}(internal.NewOrig{{ .originName }}(), internal.NewState())
return new{{ .structName }}(internal.New{{ .originName }}(), internal.NewState())
}

// MoveTo moves all properties from the current struct overriding the destination and
@@ -53,7 +53,7 @@ func (ms {{ .structName }}) MoveTo(dest {{ .structName }}) {
if ms.{{ .origAccessor }} == dest.{{ .origAccessor }} {
return
}
internal.DeleteOrig{{ .originName }}(dest.{{ .origAccessor }}, false)
internal.Delete{{ .originName }}(dest.{{ .origAccessor }}, false)
*dest.{{ .origAccessor }}, *ms.{{ .origAccessor }} = *ms.{{ .origAccessor }}, *dest.{{ .origAccessor }}
}

@@ -64,15 +64,15 @@ func (ms {{ .structName }}) MoveTo(dest {{ .structName }}) {
// CopyTo copies all properties from the current struct overriding the destination.
func (ms {{ .structName }}) CopyTo(dest {{ .structName }}) {
dest.{{ .stateAccessor }}.AssertMutable()
internal.CopyOrig{{ .originName }}(dest.{{ .origAccessor }}, ms.{{ .origAccessor }})
internal.Copy{{ .originName }}(dest.{{ .origAccessor }}, ms.{{ .origAccessor }})
}

{{ if .hasWrapper -}}
func (ms {{ .structName }}) getOrig() *{{ .originFullName }} {
return internal.GetOrig{{ .structName }}(internal.{{ .structName }}(ms))
func (ms {{ .structName }}) getOrig() *internal.{{ .originName }} {
return internal.Get{{ .structName }}Orig(internal.{{ .structName }}Wrapper(ms))
}

func (ms {{ .structName }}) getState() *internal.State {
return internal.Get{{ .structName }}State(internal.{{ .structName }}(ms))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Idea how to reduce the size of this change, is that each change in this file looks unnecessary but nice-to-have for clarity.

  • Insertion of "Wrapper"
  • originFullName -> internal.originName
  • NewOrig -> New
  • DeleteOrig -> Delete
  • CopyOrig -> Copy
  • etc

If the modified code generator were to preserve everything the way it has been, the change would be smaller. We could apply the improvements in a subsequent PRs, they would be more mechanical and easy to review.

Copy link
Copy Markdown
Member Author

@bogdandrutu bogdandrutu Oct 24, 2025

Choose a reason for hiding this comment

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

Insertion of "Wrapper"

The new protos will conflict with the names of the proto.

@bogdandrutu bogdandrutu force-pushed the rm-gogo-proto branch 2 times, most recently from eec0bbb to 02f819d Compare October 24, 2025 20:27
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
@bogdandrutu
Copy link
Copy Markdown
Member Author

Replaced by #14078

@bogdandrutu bogdandrutu deleted the rm-gogo-proto branch October 24, 2025 22:10
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