Skip to content

Split pdata into multiple packages #4832

@dmitryax

Description

@dmitryax

Problem

As a result of discussion on how to handle experimental data types, a decision was made to split pdata package into multiple modules per signal and publish them as separate modules. pdata package incapsulates internal proto data structures into private fields. Given that currently all signal data structures (logs, metrics, traces) use common structures like Resource, AttributeMap, AttributeValue, they need direct access to the private proto fields of the common structures. Splitting them as is cannot be done since it removes the access to the private fields of common data types from other signal packages. There are several ways how this can be solved, all of them have some drawbacks.

Possible solutions

1. Wrap common pdata structs

Common pdata structures like Resource and others can be wrapped into another struct that is accessible in a public module while wrapped part can be placed into an internal package that all other signals have access to.

Cons:

  • Complicates common data structures
  • Additional computation overhead to wrap/unwrap

2. Add new exported functions to common data structures to be used only by other pdata signals

Private functions of common data types that currently used to pass private proto fields can be exported. In that case other signal modules can have access to it.

For example:

func newResource(orig *otlpresource.Resource) Resource

can be changed to

func NewResourceFromProto(orig *otlpresource.Resource) Resource {

Pros:

  • Less additional complexiy

Cons:

  • Introducing exported functions that are needed for internal use only.

3. Put pdata into an internal package as is and use aliases to it in exported modules

The whole pdata package can be put as is into an internal package. And exported packages will contain only aliases to the internal pdata package.

Pros:

  • Easy to generate and maintain

Cons:

  • Slightly complicates the module structure and godoc.

Proposal

The third solution seems to be the most appropriate. It keeps the overhead minimal while introducing no changes to existing pdata structures. It just adds another layer of reference in the code and generated documentation.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions