Skip to content
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
16 changes: 5 additions & 11 deletions schema/instrumentation.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"$id": "https://opentelemetry.io/otelconfig/instrumentation.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"additionalProperties": false,
"additionalProperties": {
"$ref": "#/$defs/ExperimentalLanguageSpecificInstrumentation"
Copy link
Member

Choose a reason for hiding this comment

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

Do you have another language in mind that needs to be represented and is not in the list of properties? If not, let's disallow additional properties until a use case emerges.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that if we dont have a language yet, we should disallow it. We can always add languages without breaking changes

Copy link
Contributor Author

@dol dol Oct 28, 2025

Choose a reason for hiding this comment

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

I don't have any other languages in mind. I was just migrating

to the additionalProperties level.

I'm hesitant to change the existing behavior by disallowing additional languages. I rather prefer creating a new pull request to get rid of the .* rule in the first place and then not include it in this pull request, which then will be merged later.

Current schema

image

Pull request schema

Image

Credits: https://jsonviewer.tools/editor was used to visualize the schema definition

Copy link
Member

Choose a reason for hiding this comment

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

Oh I see what you're saying. The current schema is contradictory. It has additionalProperties: false AND patternProperties: .*. I.e. "you're not allowed to have extra properties, but if you do, they need to conform to this schema". Nonsense!

I just ran a test locally and it appears that the patternProperties: .* is taking priority over additionalProperties: false, which is surprising to me.

But I agree with your conclusion. Let's get this PR merged as is, and open a followup to disallow additional languages (i.e. the intent of the current schema).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since patternProperties: .* has presidency over additionalProperties it's really misleading and can lead to unwanted behaviors.
Thank you for testing this.

The goal of this pull request was to get rid of this ambiguous situation. Thx for merging it.

},
"properties": {
"general": {
"$ref": "#/$defs/ExperimentalGeneralInstrumentation"
Expand Down Expand Up @@ -41,11 +43,6 @@
"$ref": "#/$defs/ExperimentalLanguageSpecificInstrumentation"
}
},
"patternProperties": {
".*": {
"$ref": "#/$defs/ExperimentalLanguageSpecificInstrumentation"
}
},
"$defs": {
"ExperimentalGeneralInstrumentation": {
"type": "object",
Expand Down Expand Up @@ -128,11 +125,8 @@
},
"ExperimentalLanguageSpecificInstrumentation": {
"type": "object",
"additionalProperties": true,
"patternProperties": {
".*": {
"type": "object"
}
"additionalProperties": {
"type": "object"
}
}
}
Expand Down
18 changes: 6 additions & 12 deletions schema/logger_provider.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@
},
"LogRecordExporter": {
"type": "object",
"additionalProperties": true,
"additionalProperties": {
"type": ["object", "null"]
},
"minProperties": 1,
"maxProperties": 1,
"properties": {
Expand All @@ -80,11 +82,6 @@
"console": {
"$ref": "common.json#/$defs/ConsoleExporter"
}
},
"patternProperties": {
".*": {
"type": ["object", "null"]
}
}
},
"LogRecordLimits": {
Expand All @@ -103,7 +100,9 @@
},
"LogRecordProcessor": {
"type": "object",
"additionalProperties": true,
"additionalProperties": {
"type": ["object"]
},
"minProperties": 1,
"maxProperties": 1,
"properties": {
Expand All @@ -113,11 +112,6 @@
"simple": {
"$ref": "#/$defs/SimpleLogRecordProcessor"
}
},
"patternProperties": {
".*": {
"type": ["object"]
}
}
},
"ExperimentalLoggerConfigurator": {
Expand Down
27 changes: 9 additions & 18 deletions schema/meter_provider.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@
},
"PushMetricExporter": {
"type": "object",
"additionalProperties": true,
"additionalProperties": {
"type": ["object", "null"]
},
"minProperties": 1,
"maxProperties": 1,
"properties": {
Expand All @@ -142,43 +144,32 @@
"console": {
"$ref": "common.json#/$defs/ConsoleExporter"
}
},
"patternProperties": {
".*": {
"type": ["object", "null"]
}
}
},
"PullMetricExporter": {
"type": ["object"],
"additionalProperties": true,
"additionalProperties": {
"type": ["object", "null"]
},
"minProperties": 1,
"maxProperties": 1,
"properties": {
"prometheus/development": {
"$ref": "#/$defs/ExperimentalPrometheusMetricExporter"
}
},
"patternProperties": {
".*": {
"type": ["object", "null"]
}
}
},
"MetricProducer": {
"type": "object",
"additionalProperties": true,
"additionalProperties": {
"type": ["object", "null"]
},
"minProperties": 1,
"maxProperties": 1,
"properties": {
"opencensus": {
"$ref": "#/$defs/OpenCensusMetricProducer"
}
},
"patternProperties": {
".*": {
"type": ["object", "null"]
}
}
},
"OpenCensusMetricProducer": {
Expand Down
9 changes: 3 additions & 6 deletions schema/propagator.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"$defs": {
"TextMapPropagator": {
"type": "object",
"additionalProperties": true,
"additionalProperties": {
"type": ["object", "null"]
},
"minProperties": 1,
"maxProperties": 1,
"properties": {
Expand All @@ -38,11 +40,6 @@
"ottrace": {
"$ref": "#/$defs/OpenTracingPropagator"
}
},
"patternProperties": {
".*": {
"type": ["object", "null"]
}
}
},
"TraceContextPropagator": {
Expand Down
9 changes: 3 additions & 6 deletions schema/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@
},
"ExperimentalResourceDetector": {
"type": "object",
"additionalProperties": true,
"additionalProperties": {
"type": ["object", "null"]
},
"minProperties": 1,
"maxProperties": 1,
"properties": {
Expand All @@ -94,11 +96,6 @@
"service": {
"$ref": "#/$defs/ExperimentalServiceResourceDetector"
}
},
"patternProperties": {
".*": {
"type": ["object", "null"]
}
}
},
"ExperimentalContainerResourceDetector": {
Expand Down
27 changes: 9 additions & 18 deletions schema/tracer_provider.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@
},
"Sampler": {
"type": "object",
"additionalProperties": true,
"additionalProperties": {
"type": ["object", "null"]
},
"minProperties": 1,
"maxProperties": 1,
"properties": {
Expand All @@ -74,11 +76,6 @@
"trace_id_ratio_based": {
"$ref": "#/$defs/TraceIdRatioBasedSampler"
}
},
"patternProperties": {
".*": {
"type": ["object", "null"]
}
}
},
"AlwaysOffSampler": {
Expand Down Expand Up @@ -149,7 +146,9 @@
},
"SpanExporter": {
"type": "object",
"additionalProperties": true,
"additionalProperties": {
"type": ["object", "null"]
},
"minProperties": 1,
"maxProperties": 1,
"properties": {
Expand All @@ -168,11 +167,6 @@
"zipkin": {
"$ref": "#/$defs/ZipkinSpanExporter"
}
},
"patternProperties": {
".*": {
"type": ["object", "null"]
}
}
},
"SpanLimits": {
Expand Down Expand Up @@ -207,7 +201,9 @@
},
"SpanProcessor": {
"type": "object",
"additionalProperties": true,
"additionalProperties": {
"type": ["object", "null"]
},
"minProperties": 1,
"maxProperties": 1,
"properties": {
Expand All @@ -217,11 +213,6 @@
"simple": {
"$ref": "#/$defs/SimpleSpanProcessor"
}
},
"patternProperties": {
".*": {
"type": ["object", "null"]
}
}
},
"ZipkinSpanExporter": {
Expand Down
2 changes: 1 addition & 1 deletion schema/type_descriptions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# propertyB: The propertyB description. # The description for MyType.propertyB
# path_patterns: # Array of patterns where this type occurs in the schema. Each key-value in an example configuration file is transformed
# - .foo # into its JSON dot-notation location in the file, which is matched against these patterns. Each pattern is turned in a regex,
# after escaping special characters and replacing "*" with ".*".
# after escaping special characters and replacing "*" with ".+".

# START OpenTelemetryConfiguration
- type: OpenTelemetryConfiguration
Expand Down
4 changes: 2 additions & 2 deletions scripts/generate-descriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ if (outputFile === null) {
// Helper functions

// Converts an input pattern to a regular expression.
// Converts any "*" to a ".*".
// Converts any "*" to a ".+".
// Escapes all other regex special characters.
// Prefixes with "^", and adds "$" suffix.
function toRegex(pattern) {
let parts = pattern.split("*");
if (parts.length === 0) parts = [pattern];
const escaped = parts
.map(chunk => chunk.replace(/[-[\]{}()*+?.,\\^$|]/g, "\\$&"))
.join("(.*)");
.join("(.+)");
return "^" + escaped + "$";
}

Expand Down
Loading