Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .bcr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# BCR Publishing Configuration

This directory contains the template files required for publishing opentelemetry-cpp to the [Bazel Central Registry (BCR)](https://github.com/bazelbuild/bazel-central-registry).

## Files

### metadata.template.json
Contains the module metadata including homepage, maintainers, and repository information. This is used to create/update the BCR metadata for the module.

### source.template.json
Defines the source archive location and format. Placeholders like `{OWNER}`, `{REPO}`, `{TAG}`, and `{VERSION}` are automatically replaced during publishing.

### presubmit.yml
Defines the BCR presubmit tests that run when a new version is published. Currently configured to test on:
- Platforms: debian10, macos, ubuntu2004, windows
- Bazel versions: 7.x, 8.x, 9.*

## Publishing Process

The publish-to-bcr workflow (`.github/workflows/publish-to-bcr.yml`) automates publishing to BCR.

### Prerequisites

**Create a Personal Access Token (PAT)**:
- Create a Classic PAT with `workflow` and `repo` permissions
- Add it as a secret named `BCR_PUBLISH_TOKEN` in repository settings

### How to Publish

The workflow can be triggered in two ways:

1. **Automatically**: When a new GitHub release is published
2. **Manually**: Via workflow dispatch in GitHub Actions UI
- Go to Actions → Publish to BCR → Run workflow
- Enter the tag name (e.g., `v1.24.0`)

### What Happens

When triggered, the workflow:
1. Generates a BCR entry using these templates
2. Pushes the entry to your BCR fork
3. Opens a pull request against the upstream BCR

### Using a Fork Registry

For development and testing, you can use a fork of the Bazel Central Registry:

1. Fork https://github.com/bazelbuild/bazel-central-registry
2. Configure your fork URL in the workflow (modify the `publish-to-bcr.yml` file)
3. Test changes in your fork before submitting to the official BCR

The configuration in this repository points to the **official** Bazel Central Registry at https://github.com/bazelbuild/bazel-central-registry. However, using a fork registry is recommended for testing and development to avoid polluting the official registry during experimentation.

## References

- [Publish to BCR Action](https://github.com/bazel-contrib/publish-to-bcr)
- [Bazel Central Registry](https://github.com/bazelbuild/bazel-central-registry)
- [BCR Module: opentelemetry-cpp](https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/opentelemetry-cpp)
22 changes: 22 additions & 0 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"homepage": "https://github.com/open-telemetry/opentelemetry-cpp",
"maintainers": [
{
"name": "Keith Smiley",
"email": "keithbsmiley@gmail.com",
"github": "keith",
"github_user_id": 283886
},
{
"name": "Marc Alff",
"email": "marc.alff@oracle.com",
"github": "marcalff",
"github_user_id": 17238896
}
],
"repository": [
"github:open-telemetry/opentelemetry-cpp"
],
"versions": [],
"yanked_versions": {}
}
14 changes: 14 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0
matrix:
platform: ["debian10", "macos", "ubuntu2004", "windows"]
bazel: ["7.x", "8.x", "9.*"]
tasks:
verify_targets:
platform: ${{ platform }}
bazel: ${{ bazel }}
build_flags:
- '--cxxopt=-std=c++14'
- '--host_cxxopt=-std=c++14'
build_targets:
- '@opentelemetry-cpp//api'
5 changes: 5 additions & 0 deletions .bcr/source.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"integrity": "",
"strip_prefix": "opentelemetry-cpp-{VERSION}",
"url": "https://github.com/{OWNER}/{REPO}/archive/refs/tags/{TAG}.tar.gz"
}
24 changes: 24 additions & 0 deletions .github/workflows/publish-to-bcr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish to BCR

on:
# Allow manual triggering for testing and recovery
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name to publish (e.g., v1.24.0)'
required: true
type: string
# Automatically trigger after a release is created
release:
types: [published]

jobs:
publish:
permissions:
contents: write
uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v1.0.0
with:
tag_name: ${{ inputs.tag_name || github.event.release.tag_name }}
attest: false
secrets:
publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ functional/cert/server_cert_b.csr
functional/cert/server_cert_b.pem
functional/cert/server_cert_b-key.pem
functional/cert/unreadable.pem

# CodeQL build artifacts
_codeql_build_dir/
_codeql_detected_source_root
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ license requirements.

Please refer to [INSTALL.md](./INSTALL.md).

### Bazel Central Registry

This project is available in the [Bazel Central Registry (BCR)](https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/opentelemetry-cpp).
To use it with Bazel, add the following to your `MODULE.bazel` file:

```python
bazel_dep(name = "opentelemetry-cpp", version = "x.y.z")
```

For the latest version, see [BCR: opentelemetry-cpp](https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/opentelemetry-cpp).

## Getting Started

As an application owner or the library author, you can find the getting started
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,71 @@ namespace sdk
namespace logs
{

namespace batch_log_record_processor_options_env
{

/// @brief Returns the max queue size from the OTEL_BLRP_MAX_QUEUE_SIZE environment variable
/// or the default value (2048) if not set.
OPENTELEMETRY_EXPORT size_t GetMaxQueueSizeFromEnv();

/// @brief Returns the schedule delay from the OTEL_BLRP_SCHEDULE_DELAY environment variable
/// or the default value (1000ms) if not set.
OPENTELEMETRY_EXPORT std::chrono::milliseconds GetScheduleDelayFromEnv();

/// @brief Returns the export timeout from the OTEL_BLRP_EXPORT_TIMEOUT environment variable
/// or the default value (30000ms) if not set.
OPENTELEMETRY_EXPORT std::chrono::milliseconds GetExportTimeoutFromEnv();

/// @brief Returns the max export batch size from the OTEL_BLRP_MAX_EXPORT_BATCH_SIZE environment
/// variable or the default value (512) if not set.
OPENTELEMETRY_EXPORT size_t GetMaxExportBatchSizeFromEnv();

} // namespace batch_log_record_processor_options_env

/**
* Struct to hold batch LogRecordProcessor options.
*
* This is an aggregate type that supports C++20 designated initializers.
* Default values are read from environment variables when an instance is created:
* - OTEL_BLRP_MAX_QUEUE_SIZE (default: 2048)
* - OTEL_BLRP_SCHEDULE_DELAY (default: 1000ms)
* - OTEL_BLRP_EXPORT_TIMEOUT (default: 30000ms)
* - OTEL_BLRP_MAX_EXPORT_BATCH_SIZE (default: 512)
*
* Usage notes:
* - If you use default initialization (e.g., `BatchLogRecordProcessorOptions opts{}`), all fields
* are set by reading the environment variables (or hardcoded defaults if unset).
* - If you use aggregate initialization with explicit values (positional or designated),
* those values override the environment variable defaults for the specified fields.
* - With C++20 designated initializers, you can override only specific fields; unspecified
* fields will use environment variables or hardcoded defaults.
*/
struct OPENTELEMETRY_EXPORT BatchLogRecordProcessorOptions
{
BatchLogRecordProcessorOptions();
/**
* The maximum buffer/queue size. After the size is reached, spans are
* The maximum buffer/queue size. After the size is reached, log records are
* dropped.
*/
size_t max_queue_size;
size_t max_queue_size = batch_log_record_processor_options_env::GetMaxQueueSizeFromEnv();

/* The time interval between two consecutive exports. */
std::chrono::milliseconds schedule_delay_millis;
std::chrono::milliseconds schedule_delay_millis =
batch_log_record_processor_options_env::GetScheduleDelayFromEnv();

/**
* It is the time duration of how long the export can run before it is cancelled
* It is not currently used by the SDK and the parameter is ignored
* The maximum time allowed to export data.
* It is not currently used by the SDK and the parameter is ignored.
* TODO: Implement the parameter in BatchLogRecordProcessor
*/
std::chrono::milliseconds export_timeout_millis;
std::chrono::milliseconds export_timeout_millis =
batch_log_record_processor_options_env::GetExportTimeoutFromEnv();

/**
* The maximum batch size of every export. It must be smaller or
* equal to max_queue_size.
*/
size_t max_export_batch_size;
size_t max_export_batch_size =
batch_log_record_processor_options_env::GetMaxExportBatchSizeFromEnv();
};

} // namespace logs
Expand Down
59 changes: 52 additions & 7 deletions sdk/include/opentelemetry/sdk/trace/batch_span_processor_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <chrono>
#include <cstddef>

#include "opentelemetry/version.h"

Expand All @@ -14,33 +15,77 @@ namespace sdk
namespace trace
{

namespace batch_span_processor_options_env
{

/// @brief Returns the max queue size from the OTEL_BSP_MAX_QUEUE_SIZE environment variable
/// or the default value (2048) if not set.
OPENTELEMETRY_EXPORT size_t GetMaxQueueSizeFromEnv();

/// @brief Returns the schedule delay from the OTEL_BSP_SCHEDULE_DELAY environment variable
/// or the default value (5000ms) if not set.
OPENTELEMETRY_EXPORT std::chrono::milliseconds GetScheduleDelayFromEnv();

/// @brief Returns the export timeout from the OTEL_BSP_EXPORT_TIMEOUT environment variable
/// or the default value (30000ms) if not set.
OPENTELEMETRY_EXPORT std::chrono::milliseconds GetExportTimeoutFromEnv();

/// @brief Returns the max export batch size from the OTEL_BSP_MAX_EXPORT_BATCH_SIZE environment
/// variable or the default value (512) if not set.
OPENTELEMETRY_EXPORT size_t GetMaxExportBatchSizeFromEnv();

} // namespace batch_span_processor_options_env

/**
* Struct to hold batch SpanProcessor options.
*
* This is an aggregate type that supports C++20 designated initializers.
* Default values are read from environment variables when an instance is created:
* - OTEL_BSP_MAX_QUEUE_SIZE (default: 2048)
* - OTEL_BSP_SCHEDULE_DELAY (default: 5000ms)
* - OTEL_BSP_EXPORT_TIMEOUT (default: 30000ms)
* - OTEL_BSP_MAX_EXPORT_BATCH_SIZE (default: 512)
*
* Usage notes:
* - If you use default initialization (e.g., `BatchSpanProcessorOptions opts{}`), all fields
* are set by reading the environment variables (or hardcoded defaults if unset).
* - If you use aggregate initialization with explicit values (positional or designated),
* those values override the environment variable defaults for the specified fields.
* - With C++20 designated initializers, you can override only specific fields; unspecified
* fields will use environment variables or hardcoded defaults.
*
* Examples:
* // All fields use env vars or hardcoded defaults
* BatchSpanProcessorOptions opts1{};
*
* // C++20: Only max_queue_size overridden, other fields read from env vars/defaults
* BatchSpanProcessorOptions opts3{.max_queue_size = 100};
*/
struct OPENTELEMETRY_EXPORT BatchSpanProcessorOptions
{
BatchSpanProcessorOptions();
/**
* The maximum buffer/queue size. After the size is reached, spans are
* dropped.
*/
size_t max_queue_size;
size_t max_queue_size = batch_span_processor_options_env::GetMaxQueueSizeFromEnv();

/* The time interval between two consecutive exports. */
std::chrono::milliseconds schedule_delay_millis;
std::chrono::milliseconds schedule_delay_millis =
batch_span_processor_options_env::GetScheduleDelayFromEnv();

/**
* The maximum time allowed to to export data
* It is not currently used by the SDK and the parameter is ignored
* The maximum time allowed to export data.
* It is not currently used by the SDK and the parameter is ignored.
* TODO: Implement the parameter in BatchSpanProcessor
*/
std::chrono::milliseconds export_timeout;
std::chrono::milliseconds export_timeout =
batch_span_processor_options_env::GetExportTimeoutFromEnv();

/**
* The maximum batch size of every export. It must be smaller or
* equal to max_queue_size.
*/
size_t max_export_batch_size;
size_t max_export_batch_size = batch_span_processor_options_env::GetMaxExportBatchSizeFromEnv();
};

} // namespace trace
Expand Down
Loading
Loading