Commit Graph

200 Commits

Author SHA1 Message Date
Florian Lehner d87c6ce3a8
fix pprofile protoIDs (#13839)
#### Description

Fix `protoID`s that were changed with breaking changes of the Profiling
protocol and were missed in the initial change #13758.

---------

Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
2025-09-15 14:13:03 +00:00
Damien Mathieu 2e9dda5297
Fix pprofile timestamp unix nano to be a fixed64 (#13825)
This was missed in my previous PR. The `timestamp_unix_nano` field has
changed to be a fixed rather than uint.
See
https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/profiles/v1development/profiles.proto#L257
2025-09-14 16:19:01 +00:00
Damien Mathieu 8b3a08ca2a
Upgrade OTLP to 1.8.0 (#13758)
This PR upgrades OTLP to 1.8.0.
See
https://github.com/open-telemetry/opentelemetry-proto/releases/tag/v1.8.0

-contrib counterpart coming soon (I will move this out of draft once
both PRs are ready).
2025-09-11 09:05:42 +00:00
Jade Guiton 826dfcda3a
[internal/cmd/pdatagen] Parsing of non-packed primitive arrays (#13730)
#### Description

Protobuf has two possible encodings for a repeated field with wire type
VARINT/I32/I64:
- repeat the field tag for each value (like for repeated fields with
other wire types)
- use a "packed" representation: use a single field tag with wire type
LEN containing all the values

The packed representation is the default, but [the Protobuf
documentation](https://protobuf.dev/programming-guides/encoding/#repeated)
notes that:

> Protocol buffer parsers must be able to parse repeated fields that
were compiled as packed as if they were not packed, and vice versa. This
permits adding [packed=true] to existing fields in a forward- and
backward-compatible way.

The current Protobuf parser generated by pdatagen expects the packed
representation and returns an error if the "unpacked" representation is
provided instead, causing slightly off-spec clients to fail exporting
telemetry to the Collector. This PR fixes that by implementing parsing
of unpacked repeated fields.

#### Link to tracking issue
Fixes #13727

#### Testing

I added a test in `pdata/internal` which "manually" encodes a
`HistogramDataPoint` and an `ExponentialHistogramDataPoint_Buckets`
using unpacked fields, and checks that we successfully unmarshal them.

Profile payloads are also heavily affected, but I didn't add tests for
them to avoid the tests failing when there are breaking changes in the
profile proto.
2025-08-29 17:30:51 +00:00
Bogdan Drutu 04a7e7ae67
Add custom grpc/encoding that replaces proto and calls into our formats first (#13719)
This change should not affect other gRPC calls since it fallbacks to the
default grpc/proto encoding if requests are not pdata/otlp requests.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-27 18:57:43 +00:00
Bogdan Drutu 84758243b0
[chore] Change AnyValue proto funcs to be auto-generated by pdatagen (#13693)
Updates
https://github.com/open-telemetry/opentelemetry-collector/issues/13631

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-25 14:37:17 +00:00
Bogdan Drutu 97c2ac9672
[chore] Remove delete call after oneOf message added to the pool (#13701)
Accessing the oneOf object (e.g. `Metric_Sum`) to reset the
`Metric_Sum.Sum` after `Metric_Sum` was added back to the free pool is a
race condition because `Metric_Sum` may already be re-used and then we
delete something that was just added.

Updates
https://github.com/open-telemetry/opentelemetry-collector/issues/13631

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-25 04:08:10 +00:00
Bogdan Drutu e5e965c59c
[chore] Use pooling when CopyTo and SetEmpty oneOf fields (#13696)
Updates
https://github.com/open-telemetry/opentelemetry-collector/issues/13631

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-24 16:36:21 +00:00
Bogdan Drutu 213afc4ee7
[chore] Remove TODO about generated code for oneofgroup marshal proto/json and proto size (#13694)
Updates
https://github.com/open-telemetry/opentelemetry-collector/issues/13631

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-23 19:01:47 +00:00
Bogdan Drutu 32f03e9fcd
[chore] Fix oneof delete issue, free up and delete the message (#13695)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-23 13:42:29 +00:00
Bogdan Drutu cbe449b18a
[chore] Implement pooling support for oneOf messages (#13692)
Updates
https://github.com/open-telemetry/opentelemetry-collector/issues/13631

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-22 23:51:08 +00:00
Bogdan Drutu 1a001d98c3
[chore] Add manual AnyValue unmarshal to allow using memory pools (#13687)
Updates
https://github.com/open-telemetry/opentelemetry-collector/issues/13631

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-22 18:57:14 +00:00
Bogdan Drutu d09cfe5180
[chore] Auto generate ArrayValue and KeyValueList (#13688)
Replace manually written code for dealing with ArrayValue and
KeyValueList in favor of generating this code with pdatagen.

Updates
https://github.com/open-telemetry/opentelemetry-collector/issues/13631

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-22 17:25:15 +00:00
Bogdan Drutu 1d58da30d5
Implement refcounting for pipeline data owned memory (#13650)
This feature is protected by the beta featuregate
`pdata.enableRefCounting` so that if unexpected problems occur to have a
simple way to disable the problematic logic. If nothing goes wrong for 2
versions this featuregate will be marked as stable.

Updates
https://github.com/open-telemetry/opentelemetry-collector/issues/13631

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-22 17:12:05 +00:00
Bogdan Drutu 2ed38f571b
[chore] Remove internal dead code from pdata (#13681)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-21 13:11:38 +00:00
Bogdan Drutu 313db34110
Optimize CopyTo messages to avoid any copy when same source and destination (#13680)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-21 11:19:29 +00:00
Bogdan Drutu 6db7374e2f
Add support for local memory pooling for data objects (#13678)
This feature is protected by a featuregate that is not yet enabled and
only marked as alpha. Preliminary results show > 20% CPU performance
improvement and at least 40% allocations improvement. I still need to
generate UnmarshalProto for AnyValue which should improve even more
results.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-21 03:19:49 +00:00
Bogdan Drutu caed03a4d1
[chore] Move UnmarshalJSON to use the ProtoField to generate (#13675)
Also, this PR improves JSON unmarshal logic by avoiding stack calls
caused by using the Read[Array|Object]CB and replace with simple
non-recursive iterations.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-19 20:47:42 +00:00
Bogdan Drutu 5d5ada5d6a
[chore] Remove internal.NewOrig* that returns directly the value (#13676)
The only non-test change is in the Unmarshal proto but that generates
exactly the same code using the "defaultValue" for the message.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-19 19:14:04 +00:00
Bogdan Drutu 6db802a019
[chore] Enhance TestEncodingValues to test for all cases (#13667)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-19 16:47:43 +00:00
Bogdan Drutu d041e81650
Add featuregate to protect enabling the proto custom marshaling logic (#13649)
Just in case there are problems, let's give users a way to disable the
new custom marshaling logic.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-16 21:50:46 +00:00
Bogdan Drutu 044e0920e5
[chore] Call NewOrig* func instead of manually create new objects in slices (#13647)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-15 22:13:24 +00:00
Bogdan Drutu 5934839229
[chore] Call NewOrig* func instead of manually create new objects (#13646)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-15 21:45:34 +00:00
Bogdan Drutu b302feba10
[chore] Re-write the internal.State in pdata to support multiple properties. (#13633)
Part of
https://github.com/open-telemetry/opentelemetry-collector/issues/13631

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-15 16:38:54 +00:00
Bogdan Drutu eb9588bb3b
[chore] Fix custom marshaling code to preserve arrays order (#13641)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-14 18:03:50 +00:00
Bogdan Drutu 9b90d9f910
[chore] Generate custom proto unmarshal (#13626)
Benchmark results are in
https://github.com/open-telemetry/opentelemetry-collector/pull/13602

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-14 03:50:41 +00:00
Bogdan Drutu c6594a2b5e
[chore] Change JSON/Proto tests to tests for empty and filled types (#13618)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-12 04:51:35 +00:00
Bogdan Drutu 787ae29ad2
[chore] pdatagen: Change JSON marshal to directly use the ProtoFields (#13616)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-11 20:40:52 +00:00
Bogdan Drutu 72f03cf4c0
Generate Logs/Traces/Metrics and ExportResponse (#13597)
This removes lots of hand written JSON encoding code, and will help when
start using generated proto size/marshal/unmarshal.

This also adds tests for all previously hand written funcs.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-11 15:48:56 +00:00
Bogdan Drutu c74560c80b
[chore] Generate proto marshal (#13596)
No changelog because this code is not yet publicly exposed in any way.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-10 07:17:43 +00:00
Bogdan Drutu 64e5220195
[chore] Add support to calculate proto size in pdata (#13592)
Add support to generate the proto Size by pdatagen. Not yet used, will
update after more tests are added.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-08 17:45:07 +00:00
Bogdan Drutu 56d8c8f8ff
[chore] Move marshal/unmarshal JSON to work with origin (#13581)
Remove the complication about internal/public for all funcs that only
need origin. Also improves significant testing.

This simplified a lot the fields (no more isCommon/isBaseCommon/etc.)

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-06 23:24:03 +00:00
Bogdan Drutu cb546d8654
[chore] Move FillOrigTest to use orig and always in internal (#13578)
This PR allows to add tests for CopyOrig directly in the internal
package, also enables us to move more things to internal (including
tests) for Marshal/Unmarshal.

After this PR is merged we can generate the ProtoSize and other proto
helpers in internal.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-06 18:30:28 +00:00
Bogdan Drutu 53528d4bfc
[chore] Move CopyOrig funcs all to internal (#13570)
Main idea is to have all funcs that work on "origin" in internal, so
that we simplify access to them (see field access to this). Also will
remove duplicate generated code like copying the slice of KeyValue
(followup PR).

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-05 18:58:04 +00:00
Bogdan Drutu 85b47ce850
[chore] Refactor pdatagen to use the proto types for fields (#13545)
Part of the effort in
https://github.com/open-telemetry/opentelemetry-collector/pull/13531.

Would also help with:
1. Help with trying to remove the need of manually define these extra
structs and generate them from the protoc parsed code.
1. Simplifies what we need to manually generate, only the proto type is
enough.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-08-01 20:24:18 +00:00
Matthieu MOREL bf4324d1fa
[chore]: enable extra-rules from gofumpt and paramTypeCombine from go-critic (#13479)
#### Description

Check if code and import statements are formatted, with additional
rules.

* https://golangci-lint.run/usage/formatters/#gofumpt
* https://go-critic.com/overview.html#paramtypecombine

This is the application of golangci-lint fmt ./... , the Makefile has
been update to include this behavior

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2025-07-30 14:57:53 +00:00
Bogdan Drutu 7e45e34f41
[chore] Auto-generate pcommon.Slice, only 3 funcs are special and manual (#13528)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-07-29 23:33:58 +00:00
Bogdan Drutu c684ed4919
[chore] Apply improvements and fixes for RemoveIf and CopyOrig to manually writen structs (#13526)
Applies fixes from
https://github.com/open-telemetry/opentelemetry-collector/pull/13522 and
https://github.com/open-telemetry/opentelemetry-collector/pull/13523

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-07-29 22:48:44 +00:00
Bogdan Drutu 79e6823db2
Fix null pointer access when copying into a slice with larger cap but smaller len (#13523)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-07-29 19:01:54 +00:00
Bogdan Drutu c1c9314c6d
[chore] Change to auto-generate UnmarshalJSON logic with pdatagen (#13508)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-07-29 15:46:25 +00:00
Bogdan Drutu 3c0fd3946f
[chore] Change to auto-generate UnmarshalJSON logic with pdatagen for slices (#13503)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-07-28 20:24:31 +00:00
Bogdan Drutu 1666e4b6ac
[chore] Ensure that Inf is converted as Infinity (#13499)
No changelog because this bug was not released.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-07-28 05:17:09 +00:00
Bogdan Drutu 11dffd6891
[chore] Change to use wrapper of jsoniter.Iterator to simplify ReadXYZ calls (#13498)
This is a preparation to auto-generate the UnmarshalJSON using pdatagen.
By doing this we simplify to have all funcs on the Iterator and not
having some on the json package some on the Iterator.

Also, this is less error prune since it forces that all numbers are
correctly handle the string option.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-07-28 04:23:36 +00:00
Bogdan Drutu 95e5ac6476
[chore] Refactor data.*ID to mathch the new jsoniter helpers (#13495)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-07-27 18:34:15 +00:00
Bogdan Drutu bfac96cd66
Remove all usages of jsonpb from pdata (#13494)
No changelog since already have one for the main data transition.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-07-26 17:45:00 +00:00
Bogdan Drutu 424a12102d
Generate marshal JSON without gogo proto jsonpb (#13450)
This PR is part of an effort to remove usage of gogo proto in pdata and
switch to a model where we enhance the pdatagen tool to generate compact
(reflection free to avoid DCE disabling) and faster code.

The list of the PRs will do:
1. Auto generate the JSON marshaling logic (this PR).
1. Auto generate the JSON unmarshaling logic and replace manually
written code.
1. Auto generate the proto marshaling logic.
1. Auto generate the proto unmarshaling logic.
1. Remove the usage of auto-generate gogo proto code completely and
generate field members in the pdata objects.
1. Add support for lazy unmarshaling. 

Performance improvements are more than 30x:

**Before:**
```
BenchmarkLogsMarshalJSON
BenchmarkLogsMarshalJSON-12    	      94	  12541041 ns/op	 8458944 B/op	  196458 allocs/op
BenchmarkMetricsMarshalJSON
BenchmarkMetricsMarshalJSON-12    	       3	 452309069 ns/op	350229024 B/op	 8131400 allocs/op
BenchmarkProfilesMarshalJSON
BenchmarkProfilesMarshalJSON-12    	      30	  36731071 ns/op	20317088 B/op	  531652 allocs/op
BenchmarkTracesMarshalJSON
BenchmarkTracesMarshalJSON-12    	       8	 132521260 ns/op	95920588 B/op	 2208765 allocs/op
```

**After:**
```
BenchmarkLogsMarshalJSON
BenchmarkLogsMarshalJSON-12    	    3000	    403587 ns/op	  282465 B/op	    1487 allocs/op
BenchmarkMetricsMarshalJSON
BenchmarkMetricsMarshalJSON-12    	      72	  16772373 ns/op	11856529 B/op	   72833 allocs/op
BenchmarkProfilesMarshalJSON
BenchmarkProfilesMarshalJSON-12    	    1460	    849419 ns/op	  674545 B/op	    1145 allocs/op
BenchmarkTracesMarshalJSON
BenchmarkTracesMarshalJSON-12    	     271	   4344647 ns/op	 3010259 B/op	   16237 allocs/op
```

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-07-25 19:29:53 +00:00
Bogdan Drutu 467db83ad3
Fix profiles JSON unmarshaling logic for byte arrays (#13483)
Add generated test values for primitive slices to ensure we test all
paths.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-07-24 21:02:55 +00:00
Bogdan Drutu 811b19c99b
Fix JSON unmarshal and add e2e tests (#13480)
When Entity was added, we forgot to update the unmarshal logic. Add e2e
tests so that this cannot happened in the future.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-07-24 19:38:30 +00:00
Bogdan Drutu d1830eed9a
[chore] Move JSON unmarshaling funcs to match other internal helpers (#13470)
Extracted from
https://github.com/open-telemetry/opentelemetry-collector/pull/13450

---------

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-07-23 23:34:50 +00:00
Bogdan Drutu 9b036ad72f
Extract pdatagen as standalone tool/package (#13398)
Updates
https://github.com/open-telemetry/opentelemetry-collector/issues/12747

Removes one source of DCE disable which is the usage of text/template.

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
2025-07-15 19:25:33 +00:00