Skip to content

Batch span processor env variables breaks C++20 aggregate initializationΒ #3778

@lalitb

Description

@lalitb

@marcalff @nikhilbhatia08, this PR breaks a bunch of existing code without providing a sensible alternative.

Prior to that we were using the following syntax using C++20 aggregate initialization:

 auto processor = otel::BatchSpanProcessorFactory::Create(
            std::move(exporter),
            otel::BatchSpanProcessorOptions{
                .max_queue_size = config.batch().max_queue_size(),
                .schedule_delay_millis = std::chrono::milliseconds(config.batch().schedule_delay().MilliSeconds()),
                .max_export_batch_size = config.batch().max_export_batch_size(),
            }
        );

Originally posted by @georgthegreat in #3661 (comment)

Solution - I believe the issue comes from adding a user-defined constructor, which means BatchSpanProcessorOptions is no longer an aggregate type. That disables C++20 designated initializers, so patterns like .max_queue_size = ... stop working even though they worked earlier.
We can fix this by removing the constructor and using default member initializers along with a small set of static helper functions for the environment variable logic. This restores aggregate initialization while keeping the original behavior intact.

Metadata

Metadata

Assignees

Labels

needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions