-
Notifications
You must be signed in to change notification settings - Fork 516
[SDK] Fix BatchSpanProcessorOptions and BatchLogRecordProcessorOptions to restore C++20 aggregate initialization support #3780
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
38df9af
Initial plan
Copilot 75adeaf
Fix BatchSpanProcessorOptions to restore C++20 aggregate initializati…
Copilot 32720c2
Update PR progress
Copilot 5dec8e8
Remove accidentally committed CodeQL build artifacts and update .giti…
Copilot 100ed3b
Fix C++14 compatibility: remove inline variables from header
Copilot e069099
Fix Windows DLL compatibility: move helper functions to .cc files
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,69 +1,8 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #include <stddef.h> | ||
| #include <chrono> | ||
| #include <cstdint> | ||
|
|
||
| #include "opentelemetry/sdk/common/env_variables.h" | ||
| #include "opentelemetry/sdk/trace/batch_span_processor_options.h" | ||
| #include "opentelemetry/version.h" | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace trace | ||
| { | ||
|
|
||
| constexpr const char *kMaxQueueSizeEnv = "OTEL_BSP_MAX_QUEUE_SIZE"; | ||
| constexpr const char *kScheduleDelayEnv = "OTEL_BSP_SCHEDULE_DELAY"; | ||
| constexpr const char *kExportTimeoutEnv = "OTEL_BSP_EXPORT_TIMEOUT"; | ||
| constexpr const char *kMaxExportBatchSizeEnv = "OTEL_BSP_MAX_EXPORT_BATCH_SIZE"; | ||
|
|
||
| const size_t kDefaultMaxQueueSize = 2084; | ||
| const std::chrono::milliseconds kDefaultScheduleDelayMillis = std::chrono::milliseconds(5000); | ||
| const std::chrono::milliseconds kDefaultExportTimeout = std::chrono::milliseconds(3000); | ||
| const size_t kDefaultMaxExportBatchSize = 512; | ||
|
|
||
| inline size_t GetMaxQueueSizeFromEnv() | ||
| { | ||
| std::uint32_t value{}; | ||
| if (!opentelemetry::sdk::common::GetUintEnvironmentVariable(kMaxQueueSizeEnv, value)) | ||
| { | ||
| return kDefaultMaxQueueSize; | ||
| } | ||
| return static_cast<size_t>(value); | ||
| } | ||
|
|
||
| inline std::chrono::milliseconds GetDurationFromEnv( | ||
| const char *env_var, | ||
| const std::chrono::milliseconds &default_duration) | ||
| { | ||
| std::chrono::system_clock::duration duration{0}; | ||
| if (!opentelemetry::sdk::common::GetDurationEnvironmentVariable(env_var, duration)) | ||
| { | ||
| return default_duration; | ||
| } | ||
| return std::chrono::duration_cast<std::chrono::milliseconds>(duration); | ||
| } | ||
|
|
||
| inline size_t GetMaxExportBatchSizeFromEnv() | ||
| { | ||
| std::uint32_t value{}; | ||
| if (!opentelemetry::sdk::common::GetUintEnvironmentVariable(kMaxExportBatchSizeEnv, value)) | ||
| { | ||
| return kDefaultMaxExportBatchSize; | ||
| } | ||
| return static_cast<size_t>(value); | ||
| } | ||
|
|
||
| BatchSpanProcessorOptions::BatchSpanProcessorOptions() | ||
| : max_queue_size(GetMaxQueueSizeFromEnv()), | ||
| schedule_delay_millis(GetDurationFromEnv(kScheduleDelayEnv, kDefaultScheduleDelayMillis)), | ||
| export_timeout(GetDurationFromEnv(kExportTimeoutEnv, kDefaultExportTimeout)), | ||
| max_export_batch_size(GetMaxExportBatchSizeFromEnv()) | ||
| {} | ||
|
|
||
| } // namespace trace | ||
| } // namespace sdk | ||
| OPENTELEMETRY_END_NAMESPACE | ||
| // This file is intentionally kept empty for ABI compatibility. | ||
| // BatchSpanProcessorOptions is now an aggregate type with default member initializers | ||
| // defined in the header file. The environment variable reading logic has been moved | ||
| // to inline helper functions in the header to restore C++20 aggregate initialization | ||
| // support (designated initializers). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.