Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…y-configuration into refactor-otlp-exporter
  • Loading branch information
jack-berg committed Dec 9, 2024
2 parents 3cad36e + ce60fda commit 2edae10
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Improved file_format documentation. [#137](https://github.com/open-telemetry/opentelemetry-configuration/pull/137)
* Periodic exporter interval default value is inconsistent [#143](https://github.com/open-telemetry/opentelemetry-configuration/pull/143)
* Fix MetricReader invalid configurations [#148](https://github.com/open-telemetry/opentelemetry-configuration/pull/148)

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

Expand Down
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,70 @@ If a property is _not_ required, it should include a [comment](./CONTRIBUTING.md

If a property `type` includes `null`, it must include a [comment](./CONTRIBUTING.md#description-generation) describing the semantics when the value is `null`. It's common for properties with primitive types to allow `null`. `object` types allow `null` if no properties are required and the presence of the property key is meaningful.

### Polymorphic types

JSON schema's [schema composition](https://json-schema.org/understanding-json-schema/reference/combining) keywords (`allOf`, `anyOf`, `oneOf`) offer a tempting mechanism for object-oriented style inheritance and polymorphic patterns. However, JSON schema code generation tools may struggle or not support these keywords. Therefore, these keywords should be used judiciously, and should not be used to extend `object` types.

For example:

```json
{
"Shape": {
"title": "Shape",
"type": "object",
"properties": {
"sides": { "type": "integer"}
}
},
"Square": {
"title": "Square",
"type": "object",
"allOf": [{"$ref": "#/$defs/Shape"}],
"properties": {
"side_length": {"type": "integer"}
}
}
}
```

`allOf` is used in the `Square` type to extend the parent `Shape` type, such that `Square` has properties `sides` and `side_length`. Avoid this type of use.

Another example:

```json
{
"AttributeNameValue": {
"title": "AttributeNameValue",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"value": {
"oneOf": [
{"type": "string"},
{"type": "number"},
{"type": "boolean"},
{"type": "null"},
{"type": "array", "items": {"type": "string"}},
{"type": "array", "items": {"type": "boolean"}},
{"type": "array", "items": {"type": "number"}}
]
},
"type": {
"type": ["string", "null"],
"enum": [null, "string", "bool", "int", "double", "string_array", "bool_array", "int_array", "double_array"]
}
},
"required": [
"name", "value"
]
}
}
```

`oneOf` is used to specify that the `value` property matches the [standard attribute](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/common#standard-attribute) definition, and is either a primitive or array of primitives. This type of use is acceptable but should be used judiciously.

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md)
Expand Down
7 changes: 3 additions & 4 deletions examples/kitchen-sink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,9 @@ meter_provider:
# If omitted, .included resource attributes are included.
excluded:
- "service.attr1"
# Configure metric producers.
producers:
- # Configure metric producer to be opencensus.
opencensus:
# Configure metric producers.
producers:
- opencensus:
- # Configure a periodic metric reader.
periodic:
# Configure delay interval (in milliseconds) between start of two consecutive exports.
Expand Down
20 changes: 13 additions & 7 deletions schema/meter_provider.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
},
"exporter": {
"$ref": "#/$defs/PushMetricExporter"
},
"producers": {
"type": "array",
"items": {
"$ref": "#/$defs/MetricProducer"
}
}
},
"required": [
Expand All @@ -57,6 +63,12 @@
"properties": {
"exporter": {
"$ref": "#/$defs/PullMetricExporter"
},
"producers": {
"type": "array",
"items": {
"$ref": "#/$defs/MetricProducer"
}
}
},
"required": [
Expand Down Expand Up @@ -148,19 +160,13 @@
"type": "object",
"additionalProperties": false,
"minProperties": 1,
"maxProperties": 2,
"maxProperties": 1,
"properties": {
"periodic": {
"$ref": "#/$defs/PeriodicMetricReader"
},
"pull": {
"$ref": "#/$defs/PullMetricReader"
},
"producers": {
"type": "array",
"items": {
"$ref": "#/$defs/MetricProducer"
}
}
}
},
Expand Down
6 changes: 4 additions & 2 deletions schema/type_descriptions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,13 @@
property_descriptions:
pull: Configure a pull based metric reader.
periodic: Configure a periodic metric reader.
producers: Configure metric producers.
path_patterns:
- .meter_provider.readers[]

- type: PullMetricReader
property_descriptions:
exporter: Configure exporter.
producers: Configure metric producers.
path_patterns:
- .meter_provider.readers[].pull

Expand All @@ -351,6 +351,7 @@
If omitted or null, 30000 is used.
exporter: Configure exporter.
producers: Configure metric producers.
path_patterns:
- .meter_provider.readers[].periodic

Expand All @@ -359,7 +360,8 @@
opencensus: Configure metric producer to be opencensus.
prometheus: Configure metric producer to be prometheus.
path_patterns:
- .meter_provider.readers[].producers[]
- .meter_provider.readers[].producers[].pull
- .meter_provider.readers[].producers[].periodic

- type: MetricExporter
property_descriptions:
Expand Down

0 comments on commit 2edae10

Please sign in to comment.