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
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,21 @@ jobs:
name: benchmark_reports
path: /home/runner/benchmark

validate_otel_config:
Comment thread
marcalff marked this conversation as resolved.
Resolved
name: OTel Config YAML Validation
runs-on: ubuntu-24.04
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: audit

- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: install dependencies
run: sudo ./ci/install_format_tools.sh
- name: validate
run: ./ci/do_ci.sh validate.otel.config

format:
name: Format
runs-on: ubuntu-24.04
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ Increment the:
* [BUILD] Run the ext_http component install test on Windows
[#4326](https://github.com/open-telemetry/opentelemetry-cpp/pull/4326)

* [CONFIGURATION] validate and update config files to yaml schema 1.1.0
[#4374](https://github.com/open-telemetry/opentelemetry-cpp/pull/4374)

* [SDK] Convert SpinLockMutex to std::mutex part 1
Replace SpinLockMutex with std::mutex in SimpleProcessor,
SimpleLogRecordProcessor, MeterContext and Meter.
Expand Down
15 changes: 15 additions & 0 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ markdownlint .
shellcheck --severity=error <path to shell script>.sh
```

### OTel Configuration YAML Validation

Validates all OpenTelemetry declarative configuration YAML files in the repo
against the JSON schema pinned in `third_party_release`:

```sh
./ci/do_ci.sh validate.otel.config
```

To use a local schema file:

```sh
OTEL_CONFIG_SCHEMA=/path/to/opentelemetry_configuration.json ./ci/do_ci.sh validate.otel.config
```

### Testing

```sh
Expand Down
20 changes: 17 additions & 3 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,10 @@ elif [[ "$1" == "bazel.ubsan" ]]; then
bazel $BAZEL_STARTUP_OPTIONS test --config=ubsan $BAZEL_TEST_OPTIONS_ASYNC //...
exit 0
elif [[ "$1" == "bazel.tsan" ]]; then
# TODO - potential race condition in Civetweb server used by prometheus-cpp during shutdown
# https://github.com/civetweb/civetweb/issues/861, so removing prometheus from the test
bazel $BAZEL_STARTUP_OPTIONS test --config=tsan $BAZEL_TEST_OPTIONS_ASYNC -- //... -//exporters/prometheus/...
# Known intentional race in civetweb (used by prometheus-cpp) during shutdown
# https://github.com/civetweb/civetweb/issues/1184, so excluding targets that
# start the civetweb server from the test
bazel $BAZEL_STARTUP_OPTIONS test --config=tsan $BAZEL_TEST_OPTIONS_ASYNC -- //... -//exporters/prometheus/... -//examples/configuration:example_yaml_kitchen_sink
exit 0
elif [[ "$1" == "bazel.valgrind" ]]; then
bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS_ASYNC //...
Expand Down Expand Up @@ -657,6 +658,19 @@ elif [[ "$1" == "format" ]]; then
exit 1
fi
exit 0
elif [[ "$1" == "validate.otel.config" ]]; then
OTELCFG_VERSION=$(grep "^opentelemetry-configuration=" "${SRC_DIR}/third_party_release" | cut -d= -f2)
if [[ -n "${OTEL_CONFIG_SCHEMA:-}" ]]; then
SCHEMA_FILE="${OTEL_CONFIG_SCHEMA}"
SCHEMA_TMPFILE=""
else
SCHEMA_TMPFILE=$(mktemp --suffix=.json)
SCHEMA_FILE="${SCHEMA_TMPFILE}"
curl -fsSL "https://raw.githubusercontent.com/open-telemetry/opentelemetry-configuration/${OTELCFG_VERSION}/opentelemetry_configuration.json" -o "${SCHEMA_FILE}"
fi
python3 "${SRC_DIR}/tools/validate_otel_config_yaml.py" --schema "${SCHEMA_FILE}" --schema-version "${OTELCFG_VERSION}"
[[ -n "${SCHEMA_TMPFILE}" ]] && rm -f "${SCHEMA_TMPFILE}"
exit 0
elif [[ "$1" == "code.coverage" ]]; then
cd "${BUILD_DIR}"
rm -rf *
Expand Down
3 changes: 3 additions & 0 deletions ci/install_format_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ apt install -y clang-format-${CLANG_VERSION} python3 python3-pip git curl
# Install cmake_format
pip3 install --break-system-packages cmake_format==${CMAKE_FORMAT_VERSION}

# Install jsonschema and pyyaml (for YAML configuration schema validation)
pip3 install --break-system-packages jsonschema pyyaml

# Install buildifier
curl -L -o /usr/local/bin/buildifier https://github.com/bazelbuild/buildtools/releases/download/${BUILDIFIER_VERSION}/buildifier
chmod +x /usr/local/bin/buildifier
38 changes: 37 additions & 1 deletion examples/configuration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
load("@rules_cc//cc:cc_test.bzl", "cc_test")

cc_test(
name = "example_yaml",
name = "example_yaml_kitchen_sink",
size = "medium",
srcs = glob(["*.cc"]) + glob(["*.h"]),
args = [
"--test",
"--yaml",
"$(location kitchen-sink.yaml)",
],
data = ["kitchen-sink.yaml"],
defines = [
"OTEL_HAVE_OTLP_HTTP",
"OTEL_HAVE_OTLP_GRPC",
Expand Down Expand Up @@ -42,3 +48,33 @@ cc_test(
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "example_yaml_extensions",
size = "medium",
srcs = glob(["*.cc"]) + glob(["*.h"]),
args = [
"--test",
"--yaml",
"$(location extensions.yaml)",
],
data = ["extensions.yaml"],
tags = [
"test",
"yaml",
],
deps = [
"//api",
"//examples/common/logs_foo_library:common_logs_foo_library",
"//examples/common/metrics_foo_library:common_metrics_foo_library",
"//exporters/ostream:ostream_log_record_exporter_builder",
"//exporters/ostream:ostream_metric_exporter_builder",
"//exporters/ostream:ostream_span_exporter_builder",
"//sdk:headers",
"//sdk/src/configuration",
"//sdk/src/logs",
"//sdk/src/metrics",
"//sdk/src/trace",
"@com_google_googletest//:gtest_main",
],
)
13 changes: 12 additions & 1 deletion examples/configuration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,16 @@ else()
endif()

if(BUILD_TESTING)
add_test(NAME examples.example_yaml COMMAND "$<TARGET_FILE:example_yaml>")
if(WITH_OTLP_HTTP
AND WITH_OTLP_GRPC
AND WITH_OTLP_FILE
AND WITH_PROMETHEUS)
add_test(NAME examples.example_yaml_kitchen_sink
COMMAND $<TARGET_FILE:example_yaml> --test --yaml
${CMAKE_CURRENT_SOURCE_DIR}/kitchen-sink.yaml)
endif()

add_test(NAME examples.example_yaml_extensions
COMMAND $<TARGET_FILE:example_yaml> --test --yaml
${CMAKE_CURRENT_SOURCE_DIR}/extensions.yaml)
endif()
63 changes: 30 additions & 33 deletions examples/configuration/extensions.yaml
Original file line number Diff line number Diff line change
@@ -1,82 +1,79 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# The file format version
file_format: "1.0"
# extensions.yaml demonstrates the extension points in the configuration model.
# Each my_custom_* key maps to a builder that can be registered via Registry::SetExtension*Builder (see main.cc).
file_format: "1.1"

# Configure if the SDK is disabled or not. This is not required to be provided
# to ensure the SDK isn't disabled, the default value when this is not provided
# is for the SDK to be enabled.
#
# Environment variable: OTEL_SDK_DISABLED
# Configure if the SDK is disabled or not.
# If omitted or null, false is used.
disabled: false

# Configure text map context propagators.
#
# Environment variable: OTEL_PROPAGATORS
# If omitted, a noop propagator is used.
propagator:
# composite: [tracecontext, baggage, b3, b3multi, jaeger, xray, ottrace]
composite: tracecontext
composite:
- tracecontext:

# Configure tracer provider.
tracer_provider:
# Configure span processors.
processors:
# Configure a batch span processor.
Comment thread
marcalff marked this conversation as resolved.
Resolved
- batch:
# Configure exporter.
#
# Environment variable: OTEL_TRACES_EXPORTER
exporter:
# Configure exporter to be zipkin.
zipkin:
# Configure endpoint.
#
# Environment variable: OTEL_EXPORTER_ZIPKIN_ENDPOINT
endpoint: http://localhost:9411/api/v2/spans
# Configure max time (in milliseconds) to wait for each export.
#
# Environment variable: OTEL_EXPORTER_ZIPKIN_TIMEOUT
timeout: 10000
# Configure a simple span processor.
- simple:
# Configure exporter.
exporter:
# Configure exporter to be console.
console: {}
console:
# Registry::SetExtensionSpanProcessorBuilder, see custom_span_processor.cc.
- my_custom_span_processor:
comment: "This is a span processor extension point, with properties."
- batch:
exporter:
# Registry::SetExtensionSpanExporterBuilder, see custom_span_exporter.cc.
my_custom_span_exporter:
comment: "This is a span exporter extension point, with properties."

# Configure the sampler.
sampler:
# Registry::SetExtensionSamplerBuilder, see custom_sampler.cc.
my_custom_sampler:
comment: "This is a sampler extension point, with properties."

meter_provider:
readers:
- periodic:
exporter:
console:
- pull:
exporter:
# Registry::SetExtensionPullMetricExporterBuilder, see custom_pull_metric_exporter.cc.
my_custom_pull_metric_exporter:
comment: "This is a pull metric exporter extension point, with properties."
- periodic:
exporter:
# Registry::SetExtensionPushMetricExporterBuilder, see custom_push_metric_exporter.cc.
my_custom_push_metric_exporter:
comment: "This is a push metric exporter extension point, with properties."
producers:
# Registry::SetExtensionMetricProducerBuilder. No example implementation in this directory.
- my_custom_metric_producer:
comment: "This is a metric producer extension point, with properties."

logger_provider:
processors:
- simple:
# Configure exporter.
exporter:
# Configure exporter to be console.
console: {}
console:
# Registry::SetExtensionLogRecordProcessorBuilder, see custom_log_record_processor.cc.
- my_custom_log_record_processor:
comment: "This is a log record processor extension point, with properties."
- batch:
exporter:
# Registry::SetExtensionLogRecordExporterBuilder, see custom_log_record_exporter.cc.
my_custom_log_record_exporter:
comment: "This is a log record exporter extension point, with properties."
resource:
detection/development:
detectors:
# Registry::SetExtensionResourceDetectorBuilder. No example implementation in this directory.
- my_custom_detector:
comment: "This is a resource detector extension point, with properties."
Loading
Loading