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

Improve error messages for built-in configuration JSON schema #184

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Changes from all commits
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
36 changes: 21 additions & 15 deletions packages/otelbin/src/components/monaco-editor/JSONSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,28 @@ export const schema: JSONSchemaType<IOtelConfig> = {
type: "object",
additionalProperties: true,
errorMessage: {
type: "receivers property must be yaml map/dictionary",
type: "The 'receivers' entry must be a map, see https://opentelemetry.io/docs/collector/configuration/#receivers",
},
},
processors: {
type: "object",
additionalProperties: true,
errorMessage: {
type: "processors property must be yaml map/dictionary",
type: "The 'processors' entry must be a map, see https://opentelemetry.io/docs/collector/configuration/#processors",
},
},
exporters: {
type: "object",
additionalProperties: true,
errorMessage: {
type: "exporters property must be yaml map/dictionary",
type: "The 'exporters' entry must be a map, see https://opentelemetry.io/docs/collector/configuration/#exporters",
},
},
extensions: {
type: "object",
additionalProperties: true,
errorMessage: {
type: "extensions property must be yaml map/dictionary",
type: "The 'extensions' entry must be a map, see https://opentelemetry.io/docs/collector/configuration/#extensions",
},
},
service: {
Expand All @@ -75,7 +75,8 @@ export const schema: JSONSchemaType<IOtelConfig> = {
type: "array",
minItems: 1,
errorMessage: {
minItems: "At least one receiver is required",
minItems:
"The pipeline must reference at least one receiver, see https://opentelemetry.io/docs/collector/configuration/#pipelines",
},
},
processors: {
Expand All @@ -85,40 +86,45 @@ export const schema: JSONSchemaType<IOtelConfig> = {
type: "array",
minItems: 1,
errorMessage: {
minItems: "At least one exporter is required",
minItems:
"The pipeline must reference at least one exporter, see https://opentelemetry.io/docs/collector/configuration/#pipelines",
},
},
},
required: ["receivers", "exporters"],
errorMessage: {
required: {
receivers: "receivers property is required",
exporters: "exporters property is required",
receivers:
"The pipeline must reference at least one receiver, see https://opentelemetry.io/docs/collector/configuration/#pipelines",
exporters:
"The pipeline must reference at least one exporter, see https://opentelemetry.io/docs/collector/configuration/#pipelines",
},
},
},
errorMessage: {
type: "pipelines property must be yaml map/dictionary",
type: "The 'pipeline' entry must be a map, see https://opentelemetry.io/docs/collector/configuration/#pipelines",
},
},
},
required: ["pipelines"],
errorMessage: {
required: "pipelines property is required",
type: "service property must be yaml map/dictionary",
required:
"At least one pipeline must be specified, see https://opentelemetry.io/docs/collector/configuration/#pipelines",
type: "The 'pipeline' entry must be a map, see https://opentelemetry.io/docs/collector/configuration/#pipelines",
},
},
connectors: {
type: "object",
additionalProperties: true,
errorMessage: {
type: "connectors property must be yaml map/dictionary",
type: "The 'connectors' entry must be a map, see https://opentelemetry.io/docs/collector/configuration/#connectors",
},
},
},
errorMessage: {
type: "Must be a valid OpenTelemetry Collector configuration",
required: "service property is required",
type: "The configuration must be a map, see https://opentelemetry.io/docs/collector/configuration",
required:
"The configuration must specify at least the 'receivers', 'exporters, and 'service' entries, see https://opentelemetry.io/docs/collector/configuration",
},
required: ["service"],
required: ["service", "receivers", "exporters"],
};