Skip to content
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

Add guidance around use of title and description keywords #157

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,15 @@ Another example:

`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.

### Annotations - title and description

The JSON schema [`title` and `description` annotations](https://json-schema.org/understanding-json-schema/reference/annotations) are keywords which are not involved in validation. Instead, they act as a mechanism to help schemas be self-documenting, and may be used by code generation tools.

Despite these potential benefits, these keywords should be omitted:

* The titles of `object` and `enum` types produced by code generation tools should be defined using key values in [$defs](https://json-schema.org/understanding-json-schema/structuring#defs). Setting the `title` keyword introduces multiple sources of truth and possible conflict.
* As described in [description generation](./CONTRIBUTING.md#description-generation), we use a different mechanism to describe the semantics of types and properties. Setting the `description` keyword introduces multiple sources of truth and possible conflict.

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md)
Expand Down
3 changes: 0 additions & 3 deletions schema/common.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"$id": "https://opentelemetry.io/otelconfig/common.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Common",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notably, removing title in top level schema like this, which collect types for re-use but which aren't referenced anywhere in the schema directly tidies up the result of code generation.

Previously, the opentelemetry-java implementation generated a CommonModel type. It wasn't used anywhere, but it still was generated. With this change, its goes away as it should. I could probably find some way to explicitly omit generation for these kind of types, but it is a nice side affect of what seems like a sensible change for other reasons.

"$defs": {
"IncludeExclude": {
"type": "object",
Expand Down Expand Up @@ -37,7 +36,6 @@
]
},
"OtlpHttpExporter": {
"title": "OtlpHttpExporter",
"type": ["object", "null"],
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -79,7 +77,6 @@
}
},
"OtlpGrpcExporter": {
"title": "OtlpGrpcExporter",
"type": ["object", "null"],
"additionalProperties": false,
"properties": {
Expand Down
1 change: 0 additions & 1 deletion schema/instrumentation.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"$id": "https://opentelemetry.io/otelconfig/instrumentation.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Instrumentation",
"type": "object",
"additionalProperties": false,
"properties": {
Expand Down
1 change: 0 additions & 1 deletion schema/logger_provider.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"$id": "https://opentelemetry.io/otelconfig/logger_provider.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "LoggerProvider",
"type": "object",
"additionalProperties": false,
"properties": {
Expand Down
14 changes: 2 additions & 12 deletions schema/meter_provider.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"$id": "https://opentelemetry.io/otelconfig/meter_provider.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "MeterProvider",
"type": "object",
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -54,8 +53,7 @@
},
"required": [
"exporter"
],
"title": "PeriodicMetricReader"
]
},
"PullMetricReader": {
"type": "object",
Expand All @@ -73,8 +71,7 @@
},
"required": [
"exporter"
],
"title": "PullMetricReader"
]
},
"PushMetricExporter": {
"type": "object",
Expand Down Expand Up @@ -132,7 +129,6 @@
}
},
"PrometheusMetricExporter": {
"title": "PrometheusMetricExporter",
"type": ["object", "null"],
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -171,7 +167,6 @@
}
},
"ExporterTemporalityPreference": {
"title": "ExporterTemporalityPreference",
"type": ["string", "null"],
"enum": [
"cumulative",
Expand All @@ -180,15 +175,13 @@
]
},
"ExporterDefaultHistogramAggregation": {
"title": "ExporterDefaultHistogramAggregation",
"type": ["string", "null"],
"enum": [
"explicit_bucket_histogram",
"base2_exponential_bucket_histogram"
]
},
"OtlpHttpMetricExporter": {
"title": "OtlpHttpMetricExporter",
"type": ["object", "null"],
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -236,7 +229,6 @@
}
},
"OtlpGrpcMetricExporter": {
"title": "OtlpGrpcMetricExporter",
"type": ["object", "null"],
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -284,7 +276,6 @@
"additionalProperties": false,
"properties": {
"selector": {
"title": "Selector",
"type": "object",
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -317,7 +308,6 @@
}
},
"stream": {
"title": "Stream",
"type": "object",
"additionalProperties": false,
"properties": {
Expand Down
30 changes: 24 additions & 6 deletions schema/opentelemetry_configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@
"$ref": "#/$defs/AttributeLimits"
},
"logger_provider": {
"$ref": "logger_provider.json"
"$ref": "#/$defs/LoggerProvider"
},
"meter_provider": {
"$ref": "meter_provider.json"
"$ref": "#/$defs/MeterProvider"
},
"propagator": {
"$ref": "propagator.json"
"$ref": "#/$defs/Propagator"
},
"tracer_provider": {
"$ref": "tracer_provider.json"
"$ref": "#/$defs/TracerProvider"
},
"resource": {
"$ref": "resource.json"
"$ref": "#/$defs/Resource"
},
"instrumentation": {
"$ref": "instrumentation.json"
"$ref": "#/$defs/Instrumentation"
}
},
"required": [
Expand All @@ -48,6 +48,24 @@
"type": ["integer", "null"]
}
}
},
"LoggerProvider": {
"$ref": "logger_provider.json"
},
"MeterProvider": {
"$ref": "meter_provider.json"
},
"TracerProvider": {
"$ref": "tracer_provider.json"
},
"Propagator": {
"$ref": "propagator.json"
},
"Resource": {
"$ref": "resource.json"
},
"Instrumentation": {
"$ref": "instrumentation.json"
}
}
}
1 change: 0 additions & 1 deletion schema/propagator.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"$id": "https://opentelemetry.io/otelconfig/propagator.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Propagator",
"type": "object",
"properties": {
"composite": {
Expand Down
3 changes: 0 additions & 3 deletions schema/resource.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"$id": "https://opentelemetry.io/otelconfig/resource.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Resource",
"type": "object",
"additionalProperties": false,
"properties": {
Expand All @@ -23,7 +22,6 @@
},
"$defs": {
"AttributeNameValue": {
"title": "AttributeNameValue",
"type": "object",
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -61,7 +59,6 @@
]
},
"Detectors": {
"title": "Detectors",
"type": "object",
"additionalProperties": false,
"properties": {
Expand Down
4 changes: 0 additions & 4 deletions schema/tracer_provider.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"$id": "https://opentelemetry.io/otelconfig/tracer_provider.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "TracerProvider",
"type": "object",
"additionalProperties": false,
"properties": {
Expand All @@ -25,7 +24,6 @@
"BatchSpanProcessor": {
"type": "object",
"additionalProperties": false,
"title": "BatchSpanProcessor",
"properties": {
"schedule_delay": {
"type": ["integer", "null"],
Expand Down Expand Up @@ -121,7 +119,6 @@
"SimpleSpanProcessor": {
"type": "object",
"additionalProperties": false,
"title": "SimpleSpanProcessor",
"properties": {
"exporter": {
"$ref": "#/$defs/SpanExporter"
Expand Down Expand Up @@ -206,7 +203,6 @@
}
},
"ZipkinSpanExporter": {
"title": "ZipkinSpanExporter",
"type": ["object", "null"],
"additionalProperties": false,
"properties": {
Expand Down
Loading