-
Notifications
You must be signed in to change notification settings - Fork 501
[TRACE SDK] Batch span processor options now using env variables #3661
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
marcalff
merged 17 commits into
open-telemetry:main
from
nikhilbhatia08:batch_span_processor
Oct 2, 2025
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
48d9536
[TRACE SDK] Batch span processor options now using env variables
nikhilbhatia08 1855553
windows fix
nikhilbhatia08 6774cff
options.cc file
nikhilbhatia08 14f1843
iwyu fix
nikhilbhatia08 4908049
Merge branch 'main' into batch_span_processor
nikhilbhatia08 0030ae0
iwyu fix
nikhilbhatia08 214c41a
Merge branch 'main' into batch_span_processor
nikhilbhatia08 9789ee0
Merge branch 'main' into batch_span_processor
nikhilbhatia08 8a7d662
Merge branch 'main' into batch_span_processor
nikhilbhatia08 dc49b61
Merge branch 'main' into batch_span_processor
nikhilbhatia08 c1f27af
Merge branch 'main' into batch_span_processor
nikhilbhatia08 7ceb2e3
minor changes
nikhilbhatia08 b422a5f
env fix
nikhilbhatia08 cadb160
iwyu fix
nikhilbhatia08 e9010eb
more iwyu fix
nikhilbhatia08 ef8cdba
Merge branch 'main' into batch_span_processor
nikhilbhatia08 f42ac79
Merge branch 'main' into batch_span_processor
nikhilbhatia08 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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// 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 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.