Skip to content

Commit

Permalink
Merge branch 'main' into codeboten/govulncheck
Browse files Browse the repository at this point in the history
  • Loading branch information
codeboten authored Sep 25, 2024
2 parents 2967295 + 16f8f99 commit e9453bc
Show file tree
Hide file tree
Showing 12 changed files with 850 additions and 263 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/build-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,21 @@ jobs:

- name: validate example
run: make validate-examples

- name: generate descriptions
run: make generate-descriptions

- name: check for diff
run: |
# need to "git add" to detect any changes to descriptions which are not checked in
# select files from both /examples
git add examples**
if git diff --cached --quiet
then
echo "No diff detected."
else
echo "Diff detected - did you run 'make generate-descriptions'?"
echo $(git diff --cached --name-only)
echo $(git diff --cached)
exit 1
fi
19 changes: 16 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@

## Unreleased

* Adding initial instrumentation configuration schema
* Split MetricExporter into PullMetricExporter and PushMetricExporter and ensure only PushMetricExporters can be associated with PeriodicMetricReader [#110](https://github.com/open-telemetry/opentelemetry-configuration/pull/110)
* Update `attribute_keys` from array to to Include type [#111](https://github.com/open-telemetry/opentelemetry-configuration/pull/111)
## [v0.3.0] - 2024-05-08

* Add metric producers to meter_provider configuration. [#90](https://github.com/open-telemetry/opentelemetry-configuration/pull/90)
* Document what configuration options are covered in the schema. [92](https://github.com/open-telemetry/opentelemetry-configuration/pull/92)
* Remove unnecessary MetricProducer in pull metric reader. [#93](https://github.com/open-telemetry/opentelemetry-configuration/pull/93)
* Add modeling rule for property name case. [#96](https://github.com/open-telemetry/opentelemetry-configuration/pull/96)
* adding instrumentation configuration. [#91](https://github.com/open-telemetry/opentelemetry-configuration/pull/91)
* Add sdk-config.yaml starter template w/ references to env vars. [#76](https://github.com/open-telemetry/opentelemetry-configuration/pull/76)
* Split MetricExporter into PullMetricExporter and PushMetricExporter and ensure only PushMetricExporters can be associated with PeriodicMetricReader. [#110](https://github.com/open-telemetry/opentelemetry-configuration/pull/110)
* Define modeling guidance for mismatches with standard env vars, add resource.attribute_list. [#106](https://github.com/open-telemetry/opentelemetry-configuration/pull/106)
* Update `attribute_keys` from array to to Include type. [#111](https://github.com/open-telemetry/opentelemetry-configuration/pull/111)
* add tool for config file validation and envvar replacement. [#94](https://github.com/open-telemetry/opentelemetry-configuration/pull/94)
* add headers_list support, similar to attributes_list. [#122](https://github.com/open-telemetry/opentelemetry-configuration/pull/122)
* Prefer arrays of name value pairs over objects. [#115](https://github.com/open-telemetry/opentelemetry-configuration/pull/115)
* stream: update stream configuration to include/exclude. [#118](https://github.com/open-telemetry/opentelemetry-configuration/pull/118)
* Project tooling to generate example property descriptions. [#104](https://github.com/open-telemetry/opentelemetry-configuration/pull/104)

## [v0.2.0] - 2024-05-08

Expand Down
61 changes: 61 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,67 @@ You can perform all checks locally using this command:
make all
```

## Description generation

The [./examples](./examples) directory contains a variety of examples, which
include important comments describing the semantics of the configuration
properties. In order to keep these comments consistent across examples, we have
tooling which automatically generates comments for each property.

How it works:

* The [./schema/type_descriptions.yaml](./schema/type_descriptions.yaml) file
defines descriptions for each of the properties of each type defines in
the [JSON schema](./schema) data model.
* The [./scripts/generate-descriptions.js](./scripts/generate-comments.js) is a
script which for a given input configuration file will:
* Parse the YAML.
* Walk through each key / value pair, and for each:
* Compute the JSON dot notation location of the current key / value pair.
* Find the first matching rule
in [type_description.yaml](./schema/type_descriptions.yaml). Iterate
through the rules and evaluate the key / value pair dot notation location
against each of the rule's `path_patterns`.
* Inject / overwrite comments for its properties according
to `type_descriptions.yaml`.
* Write the resulting content to specified output file or to the console.
The `make generate-descriptions` command runs this process against each file
in `./examples` and overwrites each file in the process.
**NOTE:** The [build](./.github/workflows/build-check.yaml) will fail
if `make generate-descriptions` produces any changes which are not checked into
version control.
To run against a single file:
- Install the latest LTS release of **[Node](https://nodejs.org/)**.
For example, using **[nvm][]** under Linux run:
```bash
nvm install --lts
```
- Install tooling packages:
```bash
npm install
```
- Run the script:
```shell
npm run-script generate-descriptions -- /absolute/path/to/input/file.yaml /absolute/path/to/output/file.yaml
```
Optionally, include the `--debug` parameter. This prints out information about
each key value pair, including the computed dot notation location, the matched
rule, the previous description, the new description, etc.
```shell
npm run-script generate-comments -- /absolute/path/to/input/file.yaml /absolute/path/to/output/file.yaml --debug
```
## Pull requests
A PR is ready to merge when:
Expand Down
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ EXAMPLE_FILES := $(shell find . -path './examples/*.yaml' -exec basename {} \; |
$(shell mkdir -p out)

.PHONY: all
all: install-tools compile-schema validate-examples
all: install-tools compile-schema generate-descriptions validate-examples

include validator/Makefile

.PHONY: compile-schema
compile-schema:
@if ! npm ls ajv-cli; then npm install; fi
@for f in $(SCHEMA_FILES); do \
npx --no ajv-cli compile --spec=draft2020 --allow-matching-properties -s ./schema/$$f -r "./schema/!($$f)" \
npx --no ajv-cli compile --spec=draft2020 --allow-matching-properties -s ./schema/$$f -r "./schema/!($$f|*.yaml)" \
|| exit 1; \
done

Expand All @@ -23,10 +23,17 @@ validate-examples:
@if ! npm ls ajv-cli; then npm install; fi
@for f in $(EXAMPLE_FILES); do \
npx envsub ./examples/$$f ./out/$$f || exit 1; \
npx --no ajv-cli validate --spec=draft2020 --allow-matching-properties --errors=text -s ./schema/opentelemetry_configuration.json -r "./schema/!(opentelemetry_configuration.json)" -d ./out/$$f \
npx --no ajv-cli validate --spec=draft2020 --allow-matching-properties --errors=text -s ./schema/opentelemetry_configuration.json -r "./schema/!(opentelemetry_configuration.json|*.yaml)" -d ./out/$$f \
|| exit 1; \
done

.PHONY: generate-descriptions
generate-descriptions:
@if ! npm ls minimatch yaml; then npm install; fi
@for f in $(EXAMPLE_FILES); do \
npm run-script generate-descriptions -- $(shell pwd)/examples/$$f $(shell pwd)/examples/$$f || exit 1; \
done

.PHONY: install-tools
install-tools:
npm install
Expand Down
32 changes: 26 additions & 6 deletions examples/anchors.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# anchors.yaml demonstrates anchor substitution to reuse OTLP exporter configuration across signals.

# The file format version.
file_format: "0.1"
exporters:
otlp: &otlp-exporter
Expand All @@ -13,33 +14,52 @@ exporters:
compression: gzip
timeout: 10000

# Configure logger provider.
logger_provider:
# Configure log record processors.
processors:
- batch:
- # Configure a batch log record processor.
batch:
# Configure exporter.
exporter:
# Configure exporter to be OTLP.
otlp:
# expand the otlp-exporter anchor
<<: *otlp-exporter
# Configure endpoint.
endpoint: http://localhost:4318/v1/logs

# Configure meter provider.
meter_provider:
# Configure metric readers.
readers:
- periodic:
- # Configure a periodic metric reader.
periodic:
# Configure delay interval (in milliseconds) between start of two consecutive exports.
interval: 5000
# Configure maximum allowed time (in milliseconds) to export data.
timeout: 30000
# Configure exporter.
exporter:
# Configure exporter to be OTLP.
otlp:
# expand the otlp-exporter anchor and add metric specific configuration
<<: *otlp-exporter
# Configure endpoint.
endpoint: http://localhost:4318/v1/metrics
# Configure temporality preference.
temporality_preference: delta
# Configure default histogram aggregation.
default_histogram_aggregation: base2_exponential_bucket_histogram

# Configure tracer provider.
tracer_provider:
# Configure span processors.
processors:
- batch:
- # Configure a batch span processor.
batch:
# Configure exporter.
exporter:
# Configure exporter to be OTLP.
otlp:
# expand the otlp-exporter anchor
<<: *otlp-exporter
# Configure endpoint.
endpoint: http://localhost:4318/v1/traces
Loading

0 comments on commit e9453bc

Please sign in to comment.