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

Provide guidance on $id keyword #158

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jack-berg
Copy link
Member

More codifying existing practices as we approach stability.

See JSON schema docs on $id and other links in the PR for context.

It may be good to eventually have automation that makes these documents accessible on opentelemetry.io, but I don't think that's strictly necessary. Base on my read of these docs, its sufficient for the URL to be in our control.

It is also best practice to include an $id property as a unique identifier for each schema. For now, just set it to a URL at a domain you control, for example:

Actually requiring upload to opentelemetry.io would require thinking about if we should encode version into the URI scheme and how that affects development in this repo. I.e. is it https://opentelemetry.io/otelconfig/opentelemetry_configuration.json or https://opentelemetry.io/otelconfig/<version>/opentelemetry_configuration.json?

Its not clear to me what we gain by making these URLs resolve on opentelemetry.io. I do think we should open an issue on https://github.com/open-telemetry/opentelemetry.io to reserve the https://opentelemetry.io/otelconfig/ path, in case we need it in the future.

Thoughts?

@jack-berg jack-berg requested a review from a team as a code owner January 15, 2025 21:04
Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

I think it's probably a good idea to have these accessible from opentelemetry.io

@@ -256,6 +256,10 @@ Or a property can reference a subschema residing in a schema document's [$defs](

In order to promote stylistic consistency and allow for reuse of concepts, `object` and `enum` types should be defined in either as a top level schema document or as a subschema in a schema document's `$defs`.

Each schema has an optional [`$id`](https://json-schema.org/understanding-json-schema/basics#declaring-a-unique-identifier) defining a unique identifier for the schema. Schemas and subschemas can be referenced in other schemas using the [`$ref`](https://json-schema.org/understanding-json-schema/structuring#dollarref) keyword, which resolves against the schema's [base URI](https://json-schema.org/understanding-json-schema/structuring#base-uri) (i.e. the `$id` of the top level schema document) using [JSON pointer](https://json-schema.org/understanding-json-schema/structuring#json-pointer) syntax.

All top level schema documents should contain a `$id` field following the form `https://opentelemetry.io/otelconfig/<name>.json`. Subschemas nested in `$defs` should not include an `$id`, and should be resolved using `$ref`s relative to their top level schema document.
Copy link
Contributor

Choose a reason for hiding this comment

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

should we have a version identifier in this path?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants