diff --git a/.github/workflows/build-check.yaml b/.github/workflows/build-check.yaml index 96111b94..084a2d67 100644 --- a/.github/workflows/build-check.yaml +++ b/.github/workflows/build-check.yaml @@ -30,9 +30,8 @@ jobs: - name: check for diff run: | - # need to "git add" to detect any changes to descriptions which are not checked in + # need to "git add" to detect any changes which are not checked in # select files from locations managed by meta schema - git add examples** git add schema/meta_schema_* git add schema-docs.md if git diff --cached --quiet diff --git a/Makefile b/Makefile index 32dbc004..ac11284b 100644 --- a/Makefile +++ b/Makefile @@ -38,19 +38,12 @@ update-file-format: fix-meta-schema: npm run-script fix-meta-schema || exit 1; \ -.PHONY: generate-descriptions -generate-descriptions: - @if ! npm ls minimatch yaml; then npm install; fi - @for f in $(EXAMPLE_FILES); do \ - npm run-script generate-descriptions -- $(shell pwd)/examples/$$f $(shell pwd)/examples/$$f || exit 1; \ - done - .PHONY: generate-markdown generate-markdown: npm run-script generate-markdown || exit 1; \ .PHONY: all-meta-schema -all-meta-schema: fix-meta-schema generate-descriptions generate-markdown +all-meta-schema: fix-meta-schema generate-markdown .PHONY: install-tools install-tools: diff --git a/examples/kitchen-sink.yaml b/examples/kitchen-sink.yaml index 8d323245..f3057f4e 100644 --- a/examples/kitchen-sink.yaml +++ b/examples/kitchen-sink.yaml @@ -1,528 +1,180 @@ -# kitchen-sink.yaml demonstrates all configurable surface area, including explanatory comments. +# kitchen-sink.yaml demonstrates all configurable surface area. # # It DOES NOT represent expected real world configuration, as it makes strange configuration # choices in an effort to exercise the full surface area. # # Configuration values are set to their defaults when default values are defined. - -# The file format version. -# The yaml format is documented at -# https://github.com/open-telemetry/opentelemetry-configuration/tree/main/schema +# +# For schema documentation, including required properties, semantics, default behavior, etc, +# see: https://github.com/open-telemetry/opentelemetry-configuration/blob/main/schema-docs.md file_format: "1.0-rc.2" -# Configure if the SDK is disabled or not. -# If omitted or null, false is used. disabled: false -# Configure the log level of the internal logger used by the SDK. -# If omitted, info is used. log_level: info -# Configure general attribute limits. See also tracer_provider.limits, logger_provider.limits. attribute_limits: - # Configure max attribute value size. - # Value must be non-negative. - # If omitted or null, there is no limit. attribute_value_length_limit: 4096 - # Configure max attribute count. - # Value must be non-negative. - # If omitted or null, 128 is used. attribute_count_limit: 128 -# Configure logger provider. -# If omitted, a noop logger provider is used. logger_provider: - # Configure log record processors. processors: - - # Configure a batch log record processor. - batch: - # Configure delay interval (in milliseconds) between two consecutive exports. - # Value must be non-negative. - # If omitted or null, 1000 is used. + - batch: schedule_delay: 5000 - # Configure maximum allowed time (in milliseconds) to export data. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 30000 is used. export_timeout: 30000 - # Configure maximum queue size. Value must be positive. - # If omitted or null, 2048 is used. max_queue_size: 2048 - # Configure maximum batch size. Value must be positive. - # If omitted or null, 512 is used. max_export_batch_size: 512 - # Configure exporter. exporter: - # Configure exporter to be OTLP with HTTP transport. otlp_http: - # Configure endpoint, including the signal specific path. - # If omitted or null, the http://localhost:4318/v1/{signal} (where signal is 'traces', 'logs', or 'metrics') is used. endpoint: http://localhost:4318/v1/logs - # Configure TLS settings for the exporter. tls: - # Configure certificate used to verify a server's TLS credentials. - # Absolute path to certificate file in PEM format. - # If omitted or null, system default certificate verification is used for secure connections. certificate_file: /app/cert.pem - # Configure mTLS private client key. - # Absolute path to client key file in PEM format. If set, .client_certificate must also be set. - # If omitted or null, mTLS is not used. client_key_file: /app/cert.pem - # Configure mTLS client certificate. - # Absolute path to client certificate file in PEM format. If set, .client_key must also be set. - # If omitted or null, mTLS is not used. client_certificate_file: /app/cert.pem - # Configure headers. Entries have higher priority than entries from .headers_list. - # If an entry's .value is null, the entry is ignored. headers: - - # The name of the pair. - name: api-key - # The value of the pair. + - name: api-key value: "1234" - # Configure headers. Entries have lower priority than entries from .headers. - # The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options for details. - # If omitted or null, no headers are added. headers_list: "api-key=1234" - # Configure compression. - # Values include: gzip, none. Implementations may support other compression algorithms. - # If omitted or null, none is used. compression: gzip - # Configure max time (in milliseconds) to wait for each export. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 10000 is used. timeout: 10000 - # Configure the encoding used for messages. - # Values include: protobuf, json. Implementations may not support json. - # If omitted or null, protobuf is used. encoding: protobuf - - # Configure a batch log record processor. - batch: - # Configure exporter. + - batch: exporter: - # Configure exporter to be OTLP with gRPC transport. otlp_grpc: - # Configure endpoint. - # If omitted or null, http://localhost:4317 is used. endpoint: http://localhost:4317 - # Configure TLS settings for the exporter. tls: - # Configure certificate used to verify a server's TLS credentials. - # Absolute path to certificate file in PEM format. - # If omitted or null, system default certificate verification is used for secure connections. certificate_file: /app/cert.pem - # Configure mTLS private client key. - # Absolute path to client key file in PEM format. If set, .client_certificate must also be set. - # If omitted or null, mTLS is not used. client_key_file: /app/cert.pem - # Configure mTLS client certificate. - # Absolute path to client certificate file in PEM format. If set, .client_key must also be set. - # If omitted or null, mTLS is not used. client_certificate_file: /app/cert.pem - # Configure client transport security for the exporter's connection. - # Only applicable when .endpoint is provided without http or https scheme. Implementations may choose to ignore .insecure. - # If omitted or null, false is used. insecure: false - # Configure headers. Entries have higher priority than entries from .headers_list. - # If an entry's .value is null, the entry is ignored. headers: - - # The name of the pair. - name: api-key - # The value of the pair. + - name: api-key value: "1234" - # Configure headers. Entries have lower priority than entries from .headers. - # The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options for details. - # If omitted or null, no headers are added. headers_list: "api-key=1234" - # Configure compression. - # Values include: gzip, none. Implementations may support other compression algorithms. - # If omitted or null, none is used. compression: gzip - # Configure max time (in milliseconds) to wait for each export. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 10000 is used. timeout: 10000 - - # Configure a batch log record processor. - batch: - # Configure exporter. + - batch: exporter: - # Configure exporter to be OTLP with file transport. - # This property is experimental and subject to breaking changes in minor versions. otlp_file/development: - # Configure output stream. - # Values include stdout, or scheme+destination. For example: file:///path/to/file.jsonl. - # If omitted or null, stdout is used. output_stream: file:///var/log/logs.jsonl - - # Configure a batch log record processor. - batch: - # Configure exporter. + - batch: exporter: - # Configure exporter to be OTLP with file transport. - # This property is experimental and subject to breaking changes in minor versions. otlp_file/development: - # Configure output stream. - # Values include stdout, or scheme+destination. For example: file:///path/to/file.jsonl. - # If omitted or null, stdout is used. output_stream: stdout - - # Configure a simple log record processor. - simple: - # Configure exporter. + - simple: exporter: - # Configure exporter to be console. console: - # Configure log record limits. See also attribute_limits. limits: - # Configure max attribute value size. Overrides .attribute_limits.attribute_value_length_limit. - # Value must be non-negative. - # If omitted or null, there is no limit. attribute_value_length_limit: 4096 - # Configure max attribute count. Overrides .attribute_limits.attribute_count_limit. - # Value must be non-negative. - # If omitted or null, 128 is used. attribute_count_limit: 128 - # Configure loggers. - # This property is experimental and subject to breaking changes in minor versions. logger_configurator/development: - # Configure the default logger config used there is no matching entry in .logger_configurator/development.loggers. default_config: - # Configure if the logger is enabled or not. - # If omitted or null, false is used. disabled: true - # Configure loggers. loggers: - - # Configure logger names to match, evaluated as follows: - # - # * If the logger name exactly matches. - # * If the logger name matches the wildcard pattern, where '?' matches any single character and '*' matches any number of characters including none. - name: io.opentelemetry.contrib.* - # The logger config. + - name: io.opentelemetry.contrib.* config: - # Configure if the logger is enabled or not. - # If omitted or null, false is used. disabled: false - # Configure severity filtering. - # Log records with an non-zero (i.e. unspecified) severity number which is less than minimum_severity are not processed. - # Values include: TRACE, TRACE2, TRACE3, TRACE4, DEBUG, DEBUG2, DEBUG3, DEBUG4, INFO, INFO2, INFO3, INFO4, WARN, WARN2, WARN3, WARN4, ERROR, ERROR2, ERROR3, ERROR4, FATAL, FATAL2, FATAL3, FATAL4. - # If omitted or null, severity filtering is not applied. minimum_severity: INFO - # Configure trace based filtering. - # If true, log records associated with unsampled trace contexts traces are not processed. If false, or if a log record is not associated with a trace context, trace based filtering is not applied. - # If omitted or null, trace based filtering is not applied. trace_based: true -# Configure meter provider. -# If omitted, a noop meter provider is used. meter_provider: - # Configure metric readers. readers: - - # Configure a pull based metric reader. - pull: - # Configure exporter. + - pull: exporter: - # Configure exporter to be prometheus. - # This property is experimental and subject to breaking changes in minor versions. prometheus/development: - # Configure host. - # If omitted or null, localhost is used. host: localhost - # Configure port. - # If omitted or null, 9464 is used. port: 9464 - # Configure Prometheus Exporter to produce metrics without a scope info metric. - # If omitted or null, false is used. without_scope_info: false - # Configure Prometheus Exporter to produce metrics without a target info metric for the resource. - # If omitted or null, false is used. without_target_info: false - # Configure Prometheus Exporter to add resource attributes as metrics attributes, where the resource attribute keys match the patterns. with_resource_constant_labels: - # Configure list of value patterns to include. - # Values are evaluated to match as follows: - # * If the value exactly matches. - # * If the value matches the wildcard pattern, where '?' matches any single character and '*' matches any number of characters including none. - # If omitted, all values are included. included: - "service*" - # Configure list of value patterns to exclude. Applies after .included (i.e. excluded has higher priority than included). - # Values are evaluated to match as follows: - # * If the value exactly matches. - # * If the value matches the wildcard pattern, where '?' matches any single character and '*' matches any number of characters including none. - # If omitted, .included attributes are included. excluded: - "service.attr1" - # Configure how Prometheus metrics are exposed. Values include: - # - # * UnderscoreEscapingWithSuffixes, the default. This fully escapes metric names for classic Prometheus metric name compatibility, and includes appending type and unit suffixes. - # * UnderscoreEscapingWithoutSuffixes, metric names will continue to escape special characters to _, but suffixes won't be attached. - # * NoUTF8EscapingWithSuffixes will disable changing special characters to _. Special suffixes like units and _total for counters will be attached. - # * NoTranslation. This strategy bypasses all metric and label name translation, passing them through unaltered. - # - # If omitted or null, UnderscoreEscapingWithSuffixes is used. translation_strategy: UnderscoreEscapingWithSuffixes - # Configure metric producers. producers: - - # Configure metric producer to be opencensus. - opencensus: - # Configure cardinality limits. + - opencensus: cardinality_limits: - # Configure default cardinality limit for all instrument types. - # Instrument-specific cardinality limits take priority. - # If omitted or null, 2000 is used. default: 2000 - # Configure default cardinality limit for counter instruments. - # If omitted or null, the value from .default is used. counter: 2000 - # Configure default cardinality limit for gauge instruments. - # If omitted or null, the value from .default is used. gauge: 2000 - # Configure default cardinality limit for histogram instruments. - # If omitted or null, the value from .default is used. histogram: 2000 - # Configure default cardinality limit for observable_counter instruments. - # If omitted or null, the value from .default is used. observable_counter: 2000 - # Configure default cardinality limit for observable_gauge instruments. - # If omitted or null, the value from .default is used. observable_gauge: 2000 - # Configure default cardinality limit for observable_up_down_counter instruments. - # If omitted or null, the value from .default is used. observable_up_down_counter: 2000 - # Configure default cardinality limit for up_down_counter instruments. - # If omitted or null, the value from .default is used. up_down_counter: 2000 - - # Configure a periodic metric reader. - periodic: - # Configure delay interval (in milliseconds) between start of two consecutive exports. - # Value must be non-negative. - # If omitted or null, 60000 is used. + - periodic: interval: 60000 - # Configure maximum allowed time (in milliseconds) to export data. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 30000 is used. timeout: 30000 - # Configure exporter. exporter: - # Configure exporter to be OTLP with HTTP transport. otlp_http: - # Configure endpoint, including the signal specific path. - # If omitted or null, the http://localhost:4318/v1/{signal} (where signal is 'traces', 'logs', or 'metrics') is used. endpoint: http://localhost:4318/v1/metrics - # Configure TLS settings for the exporter. tls: - # Configure certificate used to verify a server's TLS credentials. - # Absolute path to certificate file in PEM format. - # If omitted or null, system default certificate verification is used for secure connections. certificate_file: /app/cert.pem - # Configure mTLS private client key. - # Absolute path to client key file in PEM format. If set, .client_certificate must also be set. - # If omitted or null, mTLS is not used. client_key_file: /app/cert.pem - # Configure mTLS client certificate. - # Absolute path to client certificate file in PEM format. If set, .client_key must also be set. - # If omitted or null, mTLS is not used. client_certificate_file: /app/cert.pem - # Configure headers. Entries have higher priority than entries from .headers_list. - # If an entry's .value is null, the entry is ignored. headers: - - # The name of the pair. - name: api-key - # The value of the pair. + - name: api-key value: "1234" - # Configure headers. Entries have lower priority than entries from .headers. - # The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options for details. - # If omitted or null, no headers are added. headers_list: "api-key=1234" - # Configure compression. - # Values include: gzip, none. Implementations may support other compression algorithms. - # If omitted or null, none is used. compression: gzip - # Configure max time (in milliseconds) to wait for each export. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 10000 is used. timeout: 10000 - # Configure the encoding used for messages. - # Values include: protobuf, json. Implementations may not support json. - # If omitted or null, protobuf is used. encoding: protobuf - # Configure temporality preference. - # Values include: cumulative, delta, low_memory. For behavior of values, see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/otlp.md. - # If omitted or null, cumulative is used. temporality_preference: delta - # Configure default histogram aggregation. - # Values include: explicit_bucket_histogram, base2_exponential_bucket_histogram. For behavior of values, see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/otlp.md. - # If omitted or null, explicit_bucket_histogram is used. default_histogram_aggregation: base2_exponential_bucket_histogram - # Configure metric producers. producers: - - # Configure metric producer to be opencensus. - opencensus: - # Configure cardinality limits. + - opencensus: cardinality_limits: - # Configure default cardinality limit for all instrument types. - # Instrument-specific cardinality limits take priority. - # If omitted or null, 2000 is used. default: 2000 - # Configure default cardinality limit for counter instruments. - # If omitted or null, the value from .default is used. counter: 2000 - # Configure default cardinality limit for gauge instruments. - # If omitted or null, the value from .default is used. gauge: 2000 - # Configure default cardinality limit for histogram instruments. - # If omitted or null, the value from .default is used. histogram: 2000 - # Configure default cardinality limit for observable_counter instruments. - # If omitted or null, the value from .default is used. observable_counter: 2000 - # Configure default cardinality limit for observable_gauge instruments. - # If omitted or null, the value from .default is used. observable_gauge: 2000 - # Configure default cardinality limit for observable_up_down_counter instruments. - # If omitted or null, the value from .default is used. observable_up_down_counter: 2000 - # Configure default cardinality limit for up_down_counter instruments. - # If omitted or null, the value from .default is used. up_down_counter: 2000 - - # Configure a periodic metric reader. - periodic: - # Configure exporter. + - periodic: exporter: - # Configure exporter to be OTLP with gRPC transport. otlp_grpc: - # Configure endpoint. - # If omitted or null, http://localhost:4317 is used. endpoint: http://localhost:4317 - # Configure TLS settings for the exporter. tls: - # Configure certificate used to verify a server's TLS credentials. - # Absolute path to certificate file in PEM format. - # If omitted or null, system default certificate verification is used for secure connections. certificate_file: /app/cert.pem - # Configure mTLS private client key. - # Absolute path to client key file in PEM format. If set, .client_certificate must also be set. - # If omitted or null, mTLS is not used. client_key_file: /app/cert.pem - # Configure mTLS client certificate. - # Absolute path to client certificate file in PEM format. If set, .client_key must also be set. - # If omitted or null, mTLS is not used. client_certificate_file: /app/cert.pem - # Configure client transport security for the exporter's connection. - # Only applicable when .endpoint is provided without http or https scheme. Implementations may choose to ignore .insecure. - # If omitted or null, false is used. insecure: false - # Configure headers. Entries have higher priority than entries from .headers_list. - # If an entry's .value is null, the entry is ignored. headers: - - # The name of the pair. - name: api-key - # The value of the pair. + - name: api-key value: "1234" - # Configure headers. Entries have lower priority than entries from .headers. - # The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options for details. - # If omitted or null, no headers are added. headers_list: "api-key=1234" - # Configure compression. - # Values include: gzip, none. Implementations may support other compression algorithms. - # If omitted or null, none is used. compression: gzip - # Configure max time (in milliseconds) to wait for each export. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 10000 is used. timeout: 10000 - # Configure temporality preference. - # Values include: cumulative, delta, low_memory. For behavior of values, see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/otlp.md. - # If omitted or null, cumulative is used. temporality_preference: delta - # Configure default histogram aggregation. - # Values include: explicit_bucket_histogram, base2_exponential_bucket_histogram. For behavior of values, see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/otlp.md. - # If omitted or null, explicit_bucket_histogram is used. default_histogram_aggregation: base2_exponential_bucket_histogram - - # Configure a periodic metric reader. - periodic: - # Configure exporter. + - periodic: exporter: - # Configure exporter to be OTLP with file transport. - # This property is experimental and subject to breaking changes in minor versions. otlp_file/development: - # Configure output stream. - # Values include stdout, or scheme+destination. For example: file:///path/to/file.jsonl. - # If omitted or null, stdout is used. output_stream: file:///var/log/metrics.jsonl - # Configure temporality preference. - # Values include: cumulative, delta, low_memory. For behavior of values, see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/otlp.md. - # If omitted or null, cumulative is used. temporality_preference: delta - # Configure default histogram aggregation. - # Values include: explicit_bucket_histogram, base2_exponential_bucket_histogram. For behavior of values, see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/otlp.md. - # If omitted or null, explicit_bucket_histogram is used. default_histogram_aggregation: base2_exponential_bucket_histogram - - # Configure a periodic metric reader. - periodic: - # Configure exporter. + - periodic: exporter: - # Configure exporter to be OTLP with file transport. - # This property is experimental and subject to breaking changes in minor versions. otlp_file/development: - # Configure output stream. - # Values include stdout, or scheme+destination. For example: file:///path/to/file.jsonl. - # If omitted or null, stdout is used. output_stream: stdout - # Configure temporality preference. - # Values include: cumulative, delta, low_memory. For behavior of values, see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/otlp.md. - # If omitted or null, cumulative is used. temporality_preference: delta - # Configure default histogram aggregation. - # Values include: explicit_bucket_histogram, base2_exponential_bucket_histogram. For behavior of values, see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/otlp.md. - # If omitted or null, explicit_bucket_histogram is used. default_histogram_aggregation: base2_exponential_bucket_histogram - - # Configure a periodic metric reader. - periodic: - # Configure exporter. + - periodic: exporter: - # Configure exporter to be console. console: - # Configure temporality preference. - # Values include: cumulative, delta, low_memory. For behavior of values, see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/otlp.md. - # If omitted or null, cumulative is used. temporality_preference: delta - # Configure default histogram aggregation. - # Values include: explicit_bucket_histogram, base2_exponential_bucket_histogram. For behavior of values, see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/otlp.md. - # If omitted or null, explicit_bucket_histogram is used. default_histogram_aggregation: base2_exponential_bucket_histogram - # Configure views. - # Each view has a selector which determines the instrument(s) it applies to, and a configuration for the resulting stream(s). views: - - # Configure view selector. - # Selection criteria is additive as described in https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#instrument-selection-criteria. - selector: - # Configure instrument name selection criteria. - # If omitted or null, all instrument names match. + - selector: instrument_name: my-instrument - # Configure instrument type selection criteria. - # Values include: counter, gauge, histogram, observable_counter, observable_gauge, observable_up_down_counter, up_down_counter. - # If omitted or null, all instrument types match. instrument_type: histogram - # Configure the instrument unit selection criteria. - # If omitted or null, all instrument units match. unit: ms - # Configure meter name selection criteria. - # If omitted or null, all meter names match. meter_name: my-meter - # Configure meter version selection criteria. - # If omitted or null, all meter versions match. meter_version: 1.0.0 - # Configure meter schema url selection criteria. - # If omitted or null, all meter schema URLs match. meter_schema_url: https://opentelemetry.io/schemas/1.16.0 - # Configure view stream. stream: - # Configure metric name of the resulting stream(s). - # If omitted or null, the instrument's original name is used. name: new_instrument_name - # Configure metric description of the resulting stream(s). - # If omitted or null, the instrument's origin description is used. description: new_description - # Configure aggregation of the resulting stream(s). - # Values include: default, drop, explicit_bucket_histogram, base2_exponential_bucket_histogram, last_value, sum. For behavior of values see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#aggregation. - # If omitted, default is used. aggregation: - # Configure aggregation to be explicit_bucket_histogram. explicit_bucket_histogram: - # Configure bucket boundaries. - # If omitted, [0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000] is used. boundaries: [ 0.0, @@ -541,529 +193,207 @@ meter_provider: 7500.0, 10000.0 ] - # Configure record min and max. - # If omitted or null, true is used. record_min_max: true - # Configure the aggregation cardinality limit. - # If omitted or null, the metric reader's default cardinality limit is used. aggregation_cardinality_limit: 2000 - # Configure attribute keys retained in the resulting stream(s). attribute_keys: - # Configure list of value patterns to include. - # Values are evaluated to match as follows: - # * If the value exactly matches. - # * If the value matches the wildcard pattern, where '?' matches any single character and '*' matches any number of characters including none. - # If omitted, all values are included. included: - key1 - key2 - # Configure list of value patterns to exclude. Applies after .included (i.e. excluded has higher priority than included). - # Values are evaluated to match as follows: - # * If the value exactly matches. - # * If the value matches the wildcard pattern, where '?' matches any single character and '*' matches any number of characters including none. - # If omitted, .included attributes are included. excluded: - key3 - # Configure the exemplar filter. - # Values include: trace_based, always_on, always_off. For behavior of values see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#metrics-sdk-configuration. - # If omitted or null, trace_based is used. exemplar_filter: trace_based - # Configure meters. - # This property is experimental and subject to breaking changes in minor versions. meter_configurator/development: - # Configure the default meter config used there is no matching entry in .meter_configurator/development.meters. default_config: - # Configure if the meter is enabled or not. disabled: true - # Configure meters. meters: - - # Configure meter names to match, evaluated as follows: - # - # * If the meter name exactly matches. - # * If the meter name matches the wildcard pattern, where '?' matches any single character and '*' matches any number of characters including none. - name: io.opentelemetry.contrib.* - # The meter config. + - name: io.opentelemetry.contrib.* config: - # Configure if the meter is enabled or not. disabled: false -# Configure text map context propagators. -# If omitted, a noop propagator is used. propagator: - # Configure the propagators in the composite text map propagator. Entries from .composite_list are appended to the list here with duplicates filtered out. - # Built-in propagator keys include: tracecontext, baggage, b3, b3multi, jaeger, ottrace. Known third party keys include: xray. - # If the resolved list of propagators (from .composite and .composite_list) is empty, a noop propagator is used. composite: - - # Include the w3c trace context propagator. - tracecontext: - - # Include the w3c baggage propagator. - baggage: - - # Include the zipkin b3 propagator. - b3: - - # Include the zipkin b3 multi propagator. - b3multi: - - # Include the jaeger propagator. - jaeger: - - # Include the opentracing propagator. - ottrace: - # Configure the propagators in the composite text map propagator. Entries are appended to .composite with duplicates filtered out. - # The value is a comma separated list of propagator identifiers matching the format of OTEL_PROPAGATORS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#general-sdk-configuration for details. - # Built-in propagator identifiers include: tracecontext, baggage, b3, b3multi, jaeger, ottrace. Known third party identifiers include: xray. - # If the resolved list of propagators (from .composite and .composite_list) is empty, a noop propagator is used. + - tracecontext: + - baggage: + - b3: + - b3multi: + - jaeger: + - ottrace: composite_list: "tracecontext,baggage,b3,b3multi,jaeger,ottrace,xray" -# Configure tracer provider. -# If omitted, a noop tracer provider is used. tracer_provider: - # Configure span processors. processors: - - # Configure a batch span processor. - batch: - # Configure delay interval (in milliseconds) between two consecutive exports. - # Value must be non-negative. - # If omitted or null, 5000 is used. + - batch: schedule_delay: 5000 - # Configure maximum allowed time (in milliseconds) to export data. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 30000 is used. export_timeout: 30000 - # Configure maximum queue size. Value must be positive. - # If omitted or null, 2048 is used. max_queue_size: 2048 - # Configure maximum batch size. Value must be positive. - # If omitted or null, 512 is used. max_export_batch_size: 512 - # Configure exporter. exporter: - # Configure exporter to be OTLP with HTTP transport. otlp_http: - # Configure endpoint, including the signal specific path. - # If omitted or null, the http://localhost:4318/v1/{signal} (where signal is 'traces', 'logs', or 'metrics') is used. endpoint: http://localhost:4318/v1/traces - # Configure TLS settings for the exporter. tls: - # Configure certificate used to verify a server's TLS credentials. - # Absolute path to certificate file in PEM format. - # If omitted or null, system default certificate verification is used for secure connections. certificate_file: /app/cert.pem - # Configure mTLS private client key. - # Absolute path to client key file in PEM format. If set, .client_certificate must also be set. - # If omitted or null, mTLS is not used. client_key_file: /app/cert.pem - # Configure mTLS client certificate. - # Absolute path to client certificate file in PEM format. If set, .client_key must also be set. - # If omitted or null, mTLS is not used. client_certificate_file: /app/cert.pem - # Configure headers. Entries have higher priority than entries from .headers_list. - # If an entry's .value is null, the entry is ignored. headers: - - # The name of the pair. - name: api-key - # The value of the pair. + - name: api-key value: "1234" - # Configure headers. Entries have lower priority than entries from .headers. - # The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options for details. - # If omitted or null, no headers are added. headers_list: "api-key=1234" - # Configure compression. - # Values include: gzip, none. Implementations may support other compression algorithms. - # If omitted or null, none is used. compression: gzip - # Configure max time (in milliseconds) to wait for each export. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 10000 is used. timeout: 10000 - # Configure the encoding used for messages. - # Values include: protobuf, json. Implementations may not support json. - # If omitted or null, protobuf is used. encoding: protobuf - - # Configure a batch span processor. - batch: - # Configure exporter. + - batch: exporter: - # Configure exporter to be OTLP with gRPC transport. otlp_grpc: - # Configure endpoint. - # If omitted or null, http://localhost:4317 is used. endpoint: http://localhost:4317 - # Configure TLS settings for the exporter. tls: - # Configure certificate used to verify a server's TLS credentials. - # Absolute path to certificate file in PEM format. - # If omitted or null, system default certificate verification is used for secure connections. certificate_file: /app/cert.pem - # Configure mTLS private client key. - # Absolute path to client key file in PEM format. If set, .client_certificate must also be set. - # If omitted or null, mTLS is not used. client_key_file: /app/cert.pem - # Configure mTLS client certificate. - # Absolute path to client certificate file in PEM format. If set, .client_key must also be set. - # If omitted or null, mTLS is not used. client_certificate_file: /app/cert.pem - # Configure client transport security for the exporter's connection. - # Only applicable when .endpoint is provided without http or https scheme. Implementations may choose to ignore .insecure. - # If omitted or null, false is used. insecure: false - # Configure headers. Entries have higher priority than entries from .headers_list. - # If an entry's .value is null, the entry is ignored. headers: - - # The name of the pair. - name: api-key - # The value of the pair. + - name: api-key value: "1234" - # Configure headers. Entries have lower priority than entries from .headers. - # The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options for details. - # If omitted or null, no headers are added. headers_list: "api-key=1234" - # Configure compression. - # Values include: gzip, none. Implementations may support other compression algorithms. - # If omitted or null, none is used. compression: gzip - # Configure max time (in milliseconds) to wait for each export. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 10000 is used. timeout: 10000 - - # Configure a batch span processor. - batch: - # Configure exporter. + - batch: exporter: - # Configure exporter to be OTLP with file transport. - # This property is experimental and subject to breaking changes in minor versions. otlp_file/development: - # Configure output stream. - # Values include stdout, or scheme+destination. For example: file:///path/to/file.jsonl. - # If omitted or null, stdout is used. output_stream: file:///var/log/traces.jsonl - - # Configure a batch span processor. - batch: - # Configure exporter. + - batch: exporter: - # Configure exporter to be OTLP with file transport. - # This property is experimental and subject to breaking changes in minor versions. otlp_file/development: - # Configure output stream. - # Values include stdout, or scheme+destination. For example: file:///path/to/file.jsonl. - # If omitted or null, stdout is used. output_stream: stdout - - # Configure a batch span processor. - batch: - # Configure exporter. + - batch: exporter: - # Configure exporter to be zipkin. zipkin: - # Configure endpoint. - # If omitted or null, http://localhost:9411/api/v2/spans is used. endpoint: http://localhost:9411/api/v2/spans - # Configure max time (in milliseconds) to wait for each export. - # Value must be non-negative. A value of 0 indicates indefinite. - # If omitted or null, 10000 is used. timeout: 10000 - - # Configure a simple span processor. - simple: - # Configure exporter. + - simple: exporter: - # Configure exporter to be console. console: - # Configure span limits. See also attribute_limits. limits: - # Configure max attribute value size. Overrides .attribute_limits.attribute_value_length_limit. - # Value must be non-negative. - # If omitted or null, there is no limit. attribute_value_length_limit: 4096 - # Configure max attribute count. Overrides .attribute_limits.attribute_count_limit. - # Value must be non-negative. - # If omitted or null, 128 is used. attribute_count_limit: 128 - # Configure max span event count. - # Value must be non-negative. - # If omitted or null, 128 is used. event_count_limit: 128 - # Configure max span link count. - # Value must be non-negative. - # If omitted or null, 128 is used. link_count_limit: 128 - # Configure max attributes per span event. - # Value must be non-negative. - # If omitted or null, 128 is used. event_attribute_count_limit: 128 - # Configure max attributes per span link. - # Value must be non-negative. - # If omitted or null, 128 is used. link_attribute_count_limit: 128 - # Configure the sampler. - # If omitted, parent based sampler with a root of always_on is used. sampler: - # Configure sampler to be parent_based. parent_based: - # Configure root sampler. - # If omitted or null, always_on is used. root: - # Configure sampler to be trace_id_ratio_based. trace_id_ratio_based: - # Configure trace_id_ratio. - # If omitted or null, 1.0 is used. ratio: 0.0001 - # Configure remote_parent_sampled sampler. - # If omitted or null, always_on is used. remote_parent_sampled: - # Configure sampler to be always_on. always_on: - # Configure remote_parent_not_sampled sampler. - # If omitted or null, always_off is used. remote_parent_not_sampled: - # Configure sampler to be probability. - # This property is experimental and subject to breaking changes in minor versions. probability/development: - # Configure ratio. - # If omitted or null, 1.0 is used. ratio: 0.01 - # Configure local_parent_sampled sampler. - # If omitted or null, always_on is used. local_parent_sampled: - # Configure sampler to be composite. - # This property is experimental and subject to breaking changes in minor versions. composite/development: - # Configure sampler to be probability. probability: - # Configure ratio. - # If omitted or null, 1.0 is used. ratio: 0.001 - # Configure local_parent_not_sampled sampler. - # If omitted or null, always_off is used. local_parent_not_sampled: - # Configure sampler to be always_off. always_off: - # Configure tracers. - # This property is experimental and subject to breaking changes in minor versions. tracer_configurator/development: - # Configure the default tracer config used there is no matching entry in .tracer_configurator/development.tracers. default_config: - # Configure if the tracer is enabled or not. disabled: true - # Configure tracers. tracers: - - # Configure tracer names to match, evaluated as follows: - # - # * If the tracer name exactly matches. - # * If the tracer name matches the wildcard pattern, where '?' matches any single character and '*' matches any number of characters including none. - name: io.opentelemetry.contrib.* - # The tracer config. + - name: io.opentelemetry.contrib.* config: - # Configure if the tracer is enabled or not. disabled: false -# Configure resource for all signals. -# If omitted, the default resource is used. resource: - # Configure resource attributes. Entries have higher priority than entries from .resource.attributes_list. attributes: - - # The attribute name. - name: service.name - # The attribute value. - # The type of value must match .type. + - name: service.name value: unknown_service - - # The attribute name. - name: string_key - # The attribute value. - # The type of value must match .type. + - name: string_key value: value - # The attribute type. - # Values include: string, bool, int, double, string_array, bool_array, int_array, double_array. - # If omitted or null, string is used. type: string - - # The attribute name. - name: bool_key - # The attribute value. - # The type of value must match .type. + - name: bool_key value: true - # The attribute type. - # Values include: string, bool, int, double, string_array, bool_array, int_array, double_array. - # If omitted or null, string is used. type: bool - - # The attribute name. - name: int_key - # The attribute value. - # The type of value must match .type. + - name: int_key value: 1 - # The attribute type. - # Values include: string, bool, int, double, string_array, bool_array, int_array, double_array. - # If omitted or null, string is used. type: int - - # The attribute name. - name: double_key - # The attribute value. - # The type of value must match .type. + - name: double_key value: 1.1 - # The attribute type. - # Values include: string, bool, int, double, string_array, bool_array, int_array, double_array. - # If omitted or null, string is used. type: double - - # The attribute name. - name: string_array_key - # The attribute value. - # The type of value must match .type. + - name: string_array_key value: [ "value1", "value2" ] - # The attribute type. - # Values include: string, bool, int, double, string_array, bool_array, int_array, double_array. - # If omitted or null, string is used. type: string_array - - # The attribute name. - name: bool_array_key - # The attribute value. - # The type of value must match .type. + - name: bool_array_key value: [ true, false ] - # The attribute type. - # Values include: string, bool, int, double, string_array, bool_array, int_array, double_array. - # If omitted or null, string is used. type: bool_array - - # The attribute name. - name: int_array_key - # The attribute value. - # The type of value must match .type. + - name: int_array_key value: [ 1, 2 ] - # The attribute type. - # Values include: string, bool, int, double, string_array, bool_array, int_array, double_array. - # If omitted or null, string is used. type: int_array - - # The attribute name. - name: double_array_key - # The attribute value. - # The type of value must match .type. + - name: double_array_key value: [ 1.1, 2.2 ] - # The attribute type. - # Values include: string, bool, int, double, string_array, bool_array, int_array, double_array. - # If omitted or null, string is used. type: double_array - # Configure resource attributes. Entries have lower priority than entries from .resource.attributes. - # The value is a list of comma separated key-value pairs matching the format of OTEL_RESOURCE_ATTRIBUTES. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#general-sdk-configuration for details. - # If omitted or null, no resource attributes are added. attributes_list: "service.namespace=my-namespace,service.version=1.0.0" - # Configure resource detection. - # If omitted or null, resource detection is disabled. - # This property is experimental and subject to breaking changes in minor versions. detection/development: - # Configure attributes provided by resource detectors. attributes: - # Configure list of value patterns to include. - # Values are evaluated to match as follows: - # * If the value exactly matches. - # * If the value matches the wildcard pattern, where '?' matches any single character and '*' matches any number of characters including none. - # If omitted, all values are included. included: - process.* - # Configure list of value patterns to exclude. Applies after .included (i.e. excluded has higher priority than included). - # Values are evaluated to match as follows: - # * If the value exactly matches. - # * If the value matches the wildcard pattern, where '?' matches any single character and '*' matches any number of characters including none. - # If omitted, .included attributes are included. excluded: - process.command_args - # Configure resource detectors. - # Resource detector names are dependent on the SDK language ecosystem. Please consult documentation for each respective language. - # If omitted or null, no resource detectors are enabled. detectors: - - # Enable the container resource detector, which populates container.* attributes. - container: - - # Enable the host resource detector, which populates host.* and os.* attributes. - host: - - # Enable the process resource detector, which populates process.* attributes. - process: - - # Enable the service detector, which populates service.name based on the OTEL_SERVICE_NAME environment variable and service.instance.id. - service: - # Configure resource schema URL. - # If omitted or null, no schema URL is used. + - container: + - host: + - process: + - service: schema_url: https://opentelemetry.io/schemas/1.16.0 -# Configure instrumentation. -# This property is experimental and subject to breaking changes in minor versions. instrumentation/development: - # Configure general SemConv options that may apply to multiple languages and instrumentations. - # Instrumenation may merge general config options with the language specific configuration at .instrumentation.. general: - # Configure instrumentations following the peer semantic conventions. - # See peer semantic conventions: https://opentelemetry.io/docs/specs/semconv/attributes-registry/peer/ peer: - # Configure the service mapping for instrumentations following peer.service semantic conventions. - # See peer.service semantic conventions: https://opentelemetry.io/docs/specs/semconv/general/attributes/#general-remote-service-attributes service_mapping: - - # The IP address to map. - peer: 1.2.3.4 - # The logical name corresponding to the IP address of .peer. + - peer: 1.2.3.4 service: FooService - - # The IP address to map. - peer: 2.3.4.5 - # The logical name corresponding to the IP address of .peer. + - peer: 2.3.4.5 service: BarService - # Configure instrumentations following the http semantic conventions. - # See http semantic conventions: https://opentelemetry.io/docs/specs/semconv/http/ http: - # Configure instrumentations following the http client semantic conventions. client: - # Configure headers to capture for outbound http requests. request_captured_headers: - Content-Type - Accept - # Configure headers to capture for inbound http responses. response_captured_headers: - Content-Type - Content-Encoding - # Configure instrumentations following the http server semantic conventions. server: - # Configure headers to capture for inbound http requests. request_captured_headers: - Content-Type - Accept - # Configure headers to capture for outbound http responses. response_captured_headers: - Content-Type - Content-Encoding - # Configure C++ language-specific instrumentation libraries. cpp: example: property: "value" - # Configure .NET language-specific instrumentation libraries. - # Each entry's key identifies a particular instrumentation library. The corresponding value configures it. dotnet: example: property: "value" - # Configure Erlang language-specific instrumentation libraries. - # Each entry's key identifies a particular instrumentation library. The corresponding value configures it. erlang: example: property: "value" - # Configure Go language-specific instrumentation libraries. - # Each entry's key identifies a particular instrumentation library. The corresponding value configures it. go: example: property: "value" - # Configure Java language-specific instrumentation libraries. - # Each entry's key identifies a particular instrumentation library. The corresponding value configures it. java: example: property: "value" - # Configure JavaScript language-specific instrumentation libraries. - # Each entry's key identifies a particular instrumentation library. The corresponding value configures it. js: example: property: "value" - # Configure PHP language-specific instrumentation libraries. - # Each entry's key identifies a particular instrumentation library. The corresponding value configures it. php: example: property: "value" - # Configure Python language-specific instrumentation libraries. - # Each entry's key identifies a particular instrumentation library. The corresponding value configures it. python: example: property: "value" - # Configure Ruby language-specific instrumentation libraries. - # Each entry's key identifies a particular instrumentation library. The corresponding value configures it. ruby: example: property: "value" - # Configure Rust language-specific instrumentation libraries. - # Each entry's key identifies a particular instrumentation library. The corresponding value configures it. rust: example: property: "value" - # Configure Swift language-specific instrumentation libraries. - # Each entry's key identifies a particular instrumentation library. The corresponding value configures it. swift: example: property: "value" diff --git a/examples/sdk-config.yaml b/examples/sdk-config.yaml index 5c575189..8b8e031f 100644 --- a/examples/sdk-config.yaml +++ b/examples/sdk-config.yaml @@ -1,270 +1,94 @@ # sdk-config.yaml is a typical starting point for configuring the SDK, including exporting to # localhost via OTLP. - +# # NOTE: With the exception of env var substitution syntax (i.e. ${MY_ENV}), SDKs ignore # environment variables when interpreting config files. This including ignoring all env # vars defined in https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/. - -# The file format version. -# The yaml format is documented at -# https://github.com/open-telemetry/opentelemetry-configuration/tree/main/schema +# +# For schema documentation, including required properties, semantics, default behavior, etc, +# see: https://github.com/open-telemetry/opentelemetry-configuration/blob/main/schema-docs.md file_format: "1.0-rc.2" -# Configure if the SDK is disabled or not. -# If omitted or null, false is used. disabled: false -# Configure the log level of the internal logger used by the SDK. -# If omitted, info is used. log_level: info -# Configure resource for all signals. -# If omitted, the default resource is used. resource: - # Configure resource attributes. Entries have higher priority than entries from .resource.attributes_list. attributes: - - # The attribute name. - name: service.name - # The attribute value. - # The type of value must match .type. + - name: service.name value: unknown_service -# Configure general attribute limits. See also tracer_provider.limits, logger_provider.limits. attribute_limits: - # Configure max attribute value size. - # Value must be non-negative. - # If omitted or null, there is no limit. attribute_value_length_limit: - # Configure max attribute count. - # Value must be non-negative. - # If omitted or null, 128 is used. attribute_count_limit: 128 -# Configure text map context propagators. -# If omitted, a noop propagator is used. propagator: - # Configure the propagators in the composite text map propagator. Entries from .composite_list are appended to the list here with duplicates filtered out. - # Built-in propagator keys include: tracecontext, baggage, b3, b3multi, jaeger, ottrace. Known third party keys include: xray. - # If the resolved list of propagators (from .composite and .composite_list) is empty, a noop propagator is used. composite: - - # Include the w3c trace context propagator. - tracecontext: - - # Include the w3c baggage propagator. - baggage: -# Configure tracer provider. -# If omitted, a noop tracer provider is used. + - tracecontext: + - baggage: tracer_provider: - # Configure span processors. processors: - - # Configure a batch span processor. - batch: - # Configure delay interval (in milliseconds) between two consecutive exports. - # Value must be non-negative. - # If omitted or null, 5000 is used. + - batch: schedule_delay: 5000 - # Configure maximum allowed time (in milliseconds) to export data. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 30000 is used. export_timeout: 30000 - # Configure maximum queue size. Value must be positive. - # If omitted or null, 2048 is used. max_queue_size: 2048 - # Configure maximum batch size. Value must be positive. - # If omitted or null, 512 is used. max_export_batch_size: 512 - # Configure exporter. exporter: - # Configure exporter to be OTLP with HTTP transport. otlp_http: - # Configure endpoint, including the signal specific path. - # If omitted or null, the http://localhost:4318/v1/{signal} (where signal is 'traces', 'logs', or 'metrics') is used. endpoint: http://localhost:4318/v1/traces - # Configure TLS settings for the exporter. tls: - # Configure certificate used to verify a server's TLS credentials. - # Absolute path to certificate file in PEM format. - # If omitted or null, system default certificate verification is used for secure connections. certificate_file: - # Configure mTLS private client key. - # Absolute path to client key file in PEM format. If set, .client_certificate must also be set. - # If omitted or null, mTLS is not used. client_key_file: - # Configure mTLS client certificate. - # Absolute path to client certificate file in PEM format. If set, .client_key must also be set. - # If omitted or null, mTLS is not used. client_certificate_file: - # Configure compression. - # Values include: gzip, none. Implementations may support other compression algorithms. - # If omitted or null, none is used. compression: gzip - # Configure max time (in milliseconds) to wait for each export. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 10000 is used. timeout: 10000 - # Configure span limits. See also attribute_limits. limits: - # Configure max attribute value size. Overrides .attribute_limits.attribute_value_length_limit. - # Value must be non-negative. - # If omitted or null, there is no limit. attribute_value_length_limit: - # Configure max attribute count. Overrides .attribute_limits.attribute_count_limit. - # Value must be non-negative. - # If omitted or null, 128 is used. attribute_count_limit: 128 - # Configure max span event count. - # Value must be non-negative. - # If omitted or null, 128 is used. event_count_limit: 128 - # Configure max span link count. - # Value must be non-negative. - # If omitted or null, 128 is used. link_count_limit: 128 - # Configure max attributes per span event. - # Value must be non-negative. - # If omitted or null, 128 is used. event_attribute_count_limit: 128 - # Configure max attributes per span link. - # Value must be non-negative. - # If omitted or null, 128 is used. link_attribute_count_limit: 128 - # Configure the sampler. - # If omitted, parent based sampler with a root of always_on is used. sampler: - # Configure sampler to be parent_based. parent_based: - # Configure root sampler. - # If omitted or null, always_on is used. root: - # Configure sampler to be always_on. always_on: - # Configure remote_parent_sampled sampler. - # If omitted or null, always_on is used. remote_parent_sampled: - # Configure sampler to be always_on. always_on: - # Configure remote_parent_not_sampled sampler. - # If omitted or null, always_off is used. remote_parent_not_sampled: - # Configure sampler to be always_off. always_off: - # Configure local_parent_sampled sampler. - # If omitted or null, always_on is used. local_parent_sampled: - # Configure sampler to be always_on. always_on: - # Configure local_parent_not_sampled sampler. - # If omitted or null, always_off is used. local_parent_not_sampled: - # Configure sampler to be always_off. always_off: -# Configure meter provider. -# If omitted, a noop meter provider is used. meter_provider: - # Configure metric readers. readers: - - # Configure a periodic metric reader. - periodic: - # Configure delay interval (in milliseconds) between start of two consecutive exports. - # Value must be non-negative. - # If omitted or null, 60000 is used. + - periodic: interval: 60000 - # Configure maximum allowed time (in milliseconds) to export data. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 30000 is used. timeout: 30000 - # Configure exporter. exporter: - # Configure exporter to be OTLP with HTTP transport. otlp_http: - # Configure endpoint, including the signal specific path. - # If omitted or null, the http://localhost:4318/v1/{signal} (where signal is 'traces', 'logs', or 'metrics') is used. endpoint: http://localhost:4318/v1/metrics - # Configure TLS settings for the exporter. tls: - # Configure certificate used to verify a server's TLS credentials. - # Absolute path to certificate file in PEM format. - # If omitted or null, system default certificate verification is used for secure connections. certificate_file: - # Configure mTLS private client key. - # Absolute path to client key file in PEM format. If set, .client_certificate must also be set. - # If omitted or null, mTLS is not used. client_key_file: - # Configure mTLS client certificate. - # Absolute path to client certificate file in PEM format. If set, .client_key must also be set. - # If omitted or null, mTLS is not used. client_certificate_file: - # Configure compression. - # Values include: gzip, none. Implementations may support other compression algorithms. - # If omitted or null, none is used. compression: gzip - # Configure max time (in milliseconds) to wait for each export. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 10000 is used. timeout: 10000 - # Configure temporality preference. - # Values include: cumulative, delta, low_memory. For behavior of values, see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/otlp.md. - # If omitted or null, cumulative is used. temporality_preference: cumulative - # Configure default histogram aggregation. - # Values include: explicit_bucket_histogram, base2_exponential_bucket_histogram. For behavior of values, see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/otlp.md. - # If omitted or null, explicit_bucket_histogram is used. default_histogram_aggregation: explicit_bucket_histogram - # Configure the exemplar filter. - # Values include: trace_based, always_on, always_off. For behavior of values see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#metrics-sdk-configuration. - # If omitted or null, trace_based is used. exemplar_filter: trace_based -# Configure logger provider. -# If omitted, a noop logger provider is used. logger_provider: - # Configure log record processors. processors: - - # Configure a batch log record processor. - batch: - # Configure delay interval (in milliseconds) between two consecutive exports. - # Value must be non-negative. - # If omitted or null, 1000 is used. + - batch: schedule_delay: 1000 - # Configure maximum allowed time (in milliseconds) to export data. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 30000 is used. export_timeout: 30000 - # Configure maximum queue size. Value must be positive. - # If omitted or null, 2048 is used. max_queue_size: 2048 - # Configure maximum batch size. Value must be positive. - # If omitted or null, 512 is used. max_export_batch_size: 512 - # Configure exporter. exporter: - # Configure exporter to be OTLP with HTTP transport. otlp_http: - # Configure endpoint, including the signal specific path. - # If omitted or null, the http://localhost:4318/v1/{signal} (where signal is 'traces', 'logs', or 'metrics') is used. endpoint: http://localhost:4318/v1/logs - # Configure TLS settings for the exporter. tls: - # Configure certificate used to verify a server's TLS credentials. - # Absolute path to certificate file in PEM format. - # If omitted or null, system default certificate verification is used for secure connections. certificate_file: - # Configure mTLS private client key. - # Absolute path to client key file in PEM format. If set, .client_certificate must also be set. - # If omitted or null, mTLS is not used. client_key_file: - # Configure mTLS client certificate. - # Absolute path to client certificate file in PEM format. If set, .client_key must also be set. - # If omitted or null, mTLS is not used. client_certificate_file: - # Configure compression. - # Values include: gzip, none. Implementations may support other compression algorithms. - # If omitted or null, none is used. compression: gzip - # Configure max time (in milliseconds) to wait for each export. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 10000 is used. timeout: 10000 - # Configure log record limits. See also attribute_limits. limits: - # Configure max attribute value size. Overrides .attribute_limits.attribute_value_length_limit. - # Value must be non-negative. - # If omitted or null, there is no limit. attribute_value_length_limit: - # Configure max attribute count. Overrides .attribute_limits.attribute_count_limit. - # Value must be non-negative. - # If omitted or null, 128 is used. attribute_count_limit: 128 diff --git a/examples/sdk-migration-config.yaml b/examples/sdk-migration-config.yaml index 830ccc8b..611ee4d9 100644 --- a/examples/sdk-migration-config.yaml +++ b/examples/sdk-migration-config.yaml @@ -31,282 +31,93 @@ # - OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE # - OTEL_EXPORTER_OTLP_COMPRESSION # - OTEL_EXPORTER_OTLP_TIMEOUT - -# The file format version. -# The yaml format is documented at -# https://github.com/open-telemetry/opentelemetry-configuration/tree/main/schema +# +# For schema documentation, including required properties, semantics, default behavior, etc, +# see: https://github.com/open-telemetry/opentelemetry-configuration/blob/main/schema-docs.md file_format: "1.0-rc.2" -# Configure if the SDK is disabled or not. -# If omitted or null, false is used. disabled: ${OTEL_SDK_DISABLED:-false} -# Configure the log level of the internal logger used by the SDK. -# If omitted, info is used. log_level: ${OTEL_LOG_LEVEL:-info} -# Configure resource for all signals. -# If omitted, the default resource is used. resource: - # Configure resource attributes. Entries have higher priority than entries from .resource.attributes_list. attributes: - - # The attribute name. - name: service.name - # The attribute value. - # The type of value must match .type. + - name: service.name value: ${OTEL_SERVICE_NAME:-unknown_service} - # Configure resource attributes. Entries have lower priority than entries from .resource.attributes. - # The value is a list of comma separated key-value pairs matching the format of OTEL_RESOURCE_ATTRIBUTES. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#general-sdk-configuration for details. - # If omitted or null, no resource attributes are added. attributes_list: ${OTEL_RESOURCE_ATTRIBUTES} -# Configure general attribute limits. See also tracer_provider.limits, logger_provider.limits. attribute_limits: - # Configure max attribute value size. - # Value must be non-negative. - # If omitted or null, there is no limit. attribute_value_length_limit: ${OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT} - # Configure max attribute count. - # Value must be non-negative. - # If omitted or null, 128 is used. attribute_count_limit: ${OTEL_ATTRIBUTE_COUNT_LIMIT:-128} -# Configure text map context propagators. -# If omitted, a noop propagator is used. propagator: - # Configure the propagators in the composite text map propagator. Entries are appended to .composite with duplicates filtered out. - # The value is a comma separated list of propagator identifiers matching the format of OTEL_PROPAGATORS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#general-sdk-configuration for details. - # Built-in propagator identifiers include: tracecontext, baggage, b3, b3multi, jaeger, ottrace. Known third party identifiers include: xray. - # If the resolved list of propagators (from .composite and .composite_list) is empty, a noop propagator is used. composite_list: ${OTEL_PROPAGATORS:-tracecontext,baggage} -# Configure tracer provider. -# If omitted, a noop tracer provider is used. tracer_provider: - # Configure span processors. processors: - - # Configure a batch span processor. - batch: - # Configure delay interval (in milliseconds) between two consecutive exports. - # Value must be non-negative. - # If omitted or null, 5000 is used. + - batch: schedule_delay: ${OTEL_BSP_SCHEDULE_DELAY:-5000} - # Configure maximum allowed time (in milliseconds) to export data. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 30000 is used. export_timeout: ${OTEL_BSP_EXPORT_TIMEOUT:-30000} - # Configure maximum queue size. Value must be positive. - # If omitted or null, 2048 is used. max_queue_size: ${OTEL_BSP_MAX_QUEUE_SIZE:-2048} - # Configure maximum batch size. Value must be positive. - # If omitted or null, 512 is used. max_export_batch_size: ${OTEL_BSP_MAX_EXPORT_BATCH_SIZE:-512} - # Configure exporter. exporter: - # Configure exporter to be OTLP with HTTP transport. otlp_http: - # Configure endpoint, including the signal specific path. - # If omitted or null, the http://localhost:4318/v1/{signal} (where signal is 'traces', 'logs', or 'metrics') is used. endpoint: ${OTEL_EXPORTER_OTLP_TRACES_ENDPOINT:-http://localhost:4318/v1/traces} - # Configure TLS settings for the exporter. tls: - # Configure certificate used to verify a server's TLS credentials. - # Absolute path to certificate file in PEM format. - # If omitted or null, system default certificate verification is used for secure connections. certificate_file: ${OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE} - # Configure mTLS private client key. - # Absolute path to client key file in PEM format. If set, .client_certificate must also be set. - # If omitted or null, mTLS is not used. client_key_file: ${OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEY} - # Configure mTLS client certificate. - # Absolute path to client certificate file in PEM format. If set, .client_key must also be set. - # If omitted or null, mTLS is not used. client_certificate_file: ${OTEL_EXPORTER_OTLP_TRACES_CLIENT_CERTIFICATE} - # Configure compression. - # Values include: gzip, none. Implementations may support other compression algorithms. - # If omitted or null, none is used. compression: ${OTEL_EXPORTER_OTLP_TRACES_COMPRESSION:-gzip} - # Configure max time (in milliseconds) to wait for each export. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 10000 is used. timeout: ${OTEL_EXPORTER_OTLP_TRACES_TIMEOUT:-10000} - # Configure headers. Entries have lower priority than entries from .headers. - # The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options for details. - # If omitted or null, no headers are added. headers_list: ${OTEL_EXPORTER_OTLP_TRACES_HEADERS} - # Configure span limits. See also attribute_limits. limits: - # Configure max attribute value size. Overrides .attribute_limits.attribute_value_length_limit. - # Value must be non-negative. - # If omitted or null, there is no limit. attribute_value_length_limit: ${OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT} - # Configure max attribute count. Overrides .attribute_limits.attribute_count_limit. - # Value must be non-negative. - # If omitted or null, 128 is used. attribute_count_limit: ${OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT:-128} - # Configure max span event count. - # Value must be non-negative. - # If omitted or null, 128 is used. event_count_limit: ${OTEL_SPAN_EVENT_COUNT_LIMIT:-128} - # Configure max span link count. - # Value must be non-negative. - # If omitted or null, 128 is used. link_count_limit: ${OTEL_SPAN_LINK_COUNT_LIMIT:-128} - # Configure max attributes per span event. - # Value must be non-negative. - # If omitted or null, 128 is used. event_attribute_count_limit: ${OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT:-128} - # Configure max attributes per span link. - # Value must be non-negative. - # If omitted or null, 128 is used. link_attribute_count_limit: ${OTEL_LINK_ATTRIBUTE_COUNT_LIMIT:-128} - # Configure the sampler. - # If omitted, parent based sampler with a root of always_on is used. sampler: - # Configure sampler to be parent_based. parent_based: - # Configure root sampler. - # If omitted or null, always_on is used. root: - # Configure sampler to be always_on. always_on: - # Configure remote_parent_sampled sampler. - # If omitted or null, always_on is used. remote_parent_sampled: - # Configure sampler to be always_on. always_on: - # Configure remote_parent_not_sampled sampler. - # If omitted or null, always_off is used. remote_parent_not_sampled: - # Configure sampler to be always_off. always_off: - # Configure local_parent_sampled sampler. - # If omitted or null, always_on is used. local_parent_sampled: - # Configure sampler to be always_on. always_on: - # Configure local_parent_not_sampled sampler. - # If omitted or null, always_off is used. local_parent_not_sampled: - # Configure sampler to be always_off. always_off: - - -# Configure meter provider. -# If omitted, a noop meter provider is used. meter_provider: - # Configure metric readers. readers: - - # Configure a periodic metric reader. - periodic: - # Configure delay interval (in milliseconds) between start of two consecutive exports. - # Value must be non-negative. - # If omitted or null, 60000 is used. + - periodic: interval: ${OTEL_METRIC_EXPORT_INTERVAL:-60000} - # Configure maximum allowed time (in milliseconds) to export data. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 30000 is used. timeout: ${OTEL_METRIC_EXPORT_TIMEOUT:-30000} - # Configure exporter. exporter: - # Configure exporter to be OTLP with HTTP transport. otlp_http: - # Configure endpoint, including the signal specific path. - # If omitted or null, the http://localhost:4318/v1/{signal} (where signal is 'traces', 'logs', or 'metrics') is used. endpoint: ${OTEL_EXPORTER_OTLP_METRICS_ENDPOINT:-http://localhost:4318/v1/metrics} - # Configure TLS settings for the exporter. tls: - # Configure certificate used to verify a server's TLS credentials. - # Absolute path to certificate file in PEM format. - # If omitted or null, system default certificate verification is used for secure connections. certificate_file: ${OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE} - # Configure mTLS private client key. - # Absolute path to client key file in PEM format. If set, .client_certificate must also be set. - # If omitted or null, mTLS is not used. client_key_file: ${OTEL_EXPORTER_OTLP_METRICS_CLIENT_KEY} - # Configure mTLS client certificate. - # Absolute path to client certificate file in PEM format. If set, .client_key must also be set. - # If omitted or null, mTLS is not used. client_certificate_file: ${OTEL_EXPORTER_OTLP_METRICS_CLIENT_CERTIFICATE} - # Configure compression. - # Values include: gzip, none. Implementations may support other compression algorithms. - # If omitted or null, none is used. compression: ${OTEL_EXPORTER_OTLP_METRICS_COMPRESSION:-gzip} - # Configure max time (in milliseconds) to wait for each export. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 10000 is used. timeout: ${OTEL_EXPORTER_OTLP_METRICS_TIMEOUT:-10000} - # Configure headers. Entries have lower priority than entries from .headers. - # The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options for details. - # If omitted or null, no headers are added. headers_list: ${OTEL_EXPORTER_OTLP_METRICS_HEADERS} - # Configure temporality preference. - # Values include: cumulative, delta, low_memory. For behavior of values, see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/otlp.md. - # If omitted or null, cumulative is used. temporality_preference: ${OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE:-cumulative} - # Configure default histogram aggregation. - # Values include: explicit_bucket_histogram, base2_exponential_bucket_histogram. For behavior of values, see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/otlp.md. - # If omitted or null, explicit_bucket_histogram is used. default_histogram_aggregation: ${OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION:-explicit_bucket_histogram} - # Configure the exemplar filter. - # Values include: trace_based, always_on, always_off. For behavior of values see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#metrics-sdk-configuration. - # If omitted or null, trace_based is used. exemplar_filter: ${OTEL_METRICS_EXEMPLAR_FILTER:-trace_based} -# Configure logger provider. -# If omitted, a noop logger provider is used. logger_provider: - # Configure log record processors. processors: - - # Configure a batch log record processor. - batch: - # Configure delay interval (in milliseconds) between two consecutive exports. - # Value must be non-negative. - # If omitted or null, 1000 is used. + - batch: schedule_delay: ${OTEL_BLRP_SCHEDULE_DELAY:-1000} - # Configure maximum allowed time (in milliseconds) to export data. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 30000 is used. export_timeout: ${OTEL_BLRP_EXPORT_TIMEOUT:-30000} - # Configure maximum queue size. Value must be positive. - # If omitted or null, 2048 is used. max_queue_size: ${OTEL_BLRP_MAX_QUEUE_SIZE:-2048} - # Configure maximum batch size. Value must be positive. - # If omitted or null, 512 is used. max_export_batch_size: ${OTEL_BLRP_MAX_EXPORT_BATCH_SIZE:-512} - # Configure exporter. exporter: - # Configure exporter to be OTLP with HTTP transport. otlp_http: - # Configure endpoint, including the signal specific path. - # If omitted or null, the http://localhost:4318/v1/{signal} (where signal is 'traces', 'logs', or 'metrics') is used. endpoint: ${OTEL_EXPORTER_OTLP_LOGS_ENDPOINT:-http://localhost:4318/v1/logs} - # Configure TLS settings for the exporter. tls: - # Configure certificate used to verify a server's TLS credentials. - # Absolute path to certificate file in PEM format. - # If omitted or null, system default certificate verification is used for secure connections. certificate_file: ${OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE} - # Configure mTLS private client key. - # Absolute path to client key file in PEM format. If set, .client_certificate must also be set. - # If omitted or null, mTLS is not used. client_key_file: ${OTEL_EXPORTER_OTLP_LOGS_CLIENT_KEY} - # Configure mTLS client certificate. - # Absolute path to client certificate file in PEM format. If set, .client_key must also be set. - # If omitted or null, mTLS is not used. client_certificate_file: ${OTEL_EXPORTER_OTLP_LOGS_CLIENT_CERTIFICATE} - # Configure compression. - # Values include: gzip, none. Implementations may support other compression algorithms. - # If omitted or null, none is used. compression: ${OTEL_EXPORTER_OTLP_LOGS_COMPRESSION:-gzip} - # Configure max time (in milliseconds) to wait for each export. - # Value must be non-negative. A value of 0 indicates no limit (infinity). - # If omitted or null, 10000 is used. timeout: ${OTEL_EXPORTER_OTLP_LOGS_TIMEOUT:-10000} - # Configure headers. Entries have lower priority than entries from .headers. - # The value is a list of comma separated key-value pairs matching the format of OTEL_EXPORTER_OTLP_HEADERS. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options for details. - # If omitted or null, no headers are added. headers_list: ${OTEL_EXPORTER_OTLP_LOGS_HEADERS} - # Configure log record limits. See also attribute_limits. limits: - # Configure max attribute value size. Overrides .attribute_limits.attribute_value_length_limit. - # Value must be non-negative. - # If omitted or null, there is no limit. attribute_value_length_limit: ${OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT} - # Configure max attribute count. Overrides .attribute_limits.attribute_count_limit. - # Value must be non-negative. - # If omitted or null, 128 is used. attribute_count_limit: ${OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT:-128} diff --git a/package.json b/package.json index 33fb909f..e8ac384f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,6 @@ { "type": "module", "scripts": { - "generate-descriptions": "node scripts/generate-descriptions.js", "generate-markdown": "node scripts/generate-markdown.js", "fix-meta-schema": "node scripts/fix-meta-schema.js" }, diff --git a/scripts/generate-descriptions.js b/scripts/generate-descriptions.js deleted file mode 100644 index cf1f1b2d..00000000 --- a/scripts/generate-descriptions.js +++ /dev/null @@ -1,172 +0,0 @@ -import fs from 'fs'; -import yaml from 'yaml'; -import {readAndFixMetaSchema} from "./meta-schema.js"; -import {readJsonSchemaTypes} from "./json-schema.js"; -import {isExperimentalProperty, rootTypeName} from "./util.js"; - -// Extract input file arg or throw -const usageString = "Usage: \n npm run-script generate-descriptions -- /absolute/path/to/input/file.yaml /absolute/path/to/output/file.yaml [--debug]"; -if (process.argv.length < 3) { - throw new Error("Missing file to generate descriptions for. " + usageString); -} -const inputFile = process.argv[2]; -if (!fs.existsSync(inputFile)) { - throw new Error("File \"" + inputFile + "\" not found."); -} - -// Extract output file arg -let outputFile = null; -if (process.argv.length >= 4 && process.argv[3].startsWith("/")) { - outputFile = process.argv[3]; -} - -// Extract options -const options = { - debug: false -} -for (let i = 3; i < process.argv.length; i++) { - if (process.argv[i] === '--debug') { - options['debug'] = true; - } -} - -// Read JSON schema and meta schema -const { messages, metaSchema } = readAndFixMetaSchema(); -const metaSchemaTypesByType = {}; -metaSchema.types.forEach(type => metaSchemaTypesByType[type.type] = type); -if (messages.length > 0) { - throw new Error("Meta schema has problems. Please run fix-meta-schema and try again."); -} -const jsonSchemaTypesByType = {}; -readJsonSchemaTypes().forEach(type => jsonSchemaTypesByType[type.type] = type); - -// Read and process the input file -// Visit each key/value pair in the input file YAML, attempting to match against description rules -// and setting a comment with the description from the matching rule -const fileContent = fs.readFileSync(inputFile, "utf-8"); -const fileDoc = yaml.parseDocument(fileContent); -let counter = 0; -let lastNode = null; -yaml.visit(fileDoc, { - Pair: (key, node, path) => { - if (yaml.isSeq(node.value)) { - node.value.items.forEach(item => item.commentBefore = null); - } - let prevLastNode = lastNode; - lastNode = node; - counter++; - const propertyKey = node.key.value; - const jsonPath = yamlPathToJsonPath(path, propertyKey); - - // Resolve jsonSchemaType, metaSchemaType, metaSchemaProperty, or return - debug(""); - debug(`Resolving description for ${jsonPath}`); - let jsonSchemaType; - try { - jsonSchemaType = resolveJsonSchemaType(jsonSchemaTypesByType, path); - } catch (error) { - debug(`Unable to resolve JSON schema type: ${error.message}`); - return; - } - const metaSchemaType = metaSchemaTypesByType[jsonSchemaType.type]; - if (!metaSchemaType) { - throw new Error(`JSON schema type not found for meta schema type ${jsonSchemaType.type}.`); - } - const metaSchemaProperty = metaSchemaType.properties.find(item => item.property === propertyKey); - if (!metaSchemaProperty) { - debug(`No meta schema property ${propertyKey} for type ${metaSchemaType.type}.`); - return; - } - let fullDescription = metaSchemaProperty.description; - if (isExperimentalProperty(metaSchemaProperty.property)) { - if (!fullDescription.endsWith('\n')) { - fullDescription += '\n'; - } - fullDescription += `This property is experimental and subject to breaking changes in minor versions.`; - } - debug(`Resolved type ${jsonSchemaType.type}, property ${metaSchemaProperty.property}, description:\n${fullDescription}`); - - // Set the description - let formattedDescription = fullDescription - .replace(/\n$/, '') - .split('\n') - .map(line => ' ' + line) - .join('\n'); - // If we're on the first element, prefix the formatted description with the existing commentBefore to retain the comments at the top of the file - if (counter === 1 && node.key.commentBefore) { - const index = node.key.commentBefore.lastIndexOf(formattedDescription); - formattedDescription = (index === -1) - ? node.key.commentBefore + formattedDescription - : node.key.commentBefore.substring(0, index) + formattedDescription; - } - node.key.commentBefore = formattedDescription; - node.value.commentBefore = null; - // yaml parser sometimes misidentifies a pair's commentBefore as the previously processed pair.value.comment - // we detect and fix that by keeping a reference to the previous node and setting the comment to null - // this works because we only use commentBefore in this project - if (prevLastNode !== null) { - node.key.spaceBefore = null; - prevLastNode.value.comment = null; - } - } -}); - -// Print the output, or write it to a file -if (outputFile === null) { - console.log("No output file arg set, logging to console."); - console.log(String(fileDoc)) -} else { - console.log(`Writing output to ${outputFile}`); - fs.writeFileSync(outputFile, String(fileDoc)) -} - -// Helper functions -// Log the message to the console if the script was run with `--debug` argument -function debug(message) { - if (options.debug) { - console.debug(message); - } -} - -function yamlPathToJsonPath(yamlPath, propertyKey) { - const elements = [] - yamlPath.slice().forEach(entry => { - if (yaml.isSeq(entry)) { - elements.push("[]"); - } - if (yaml.isPair(entry)) { - elements.push("."); - elements.push(entry.key.value); - } - }); - let jsonPath = elements.join(''); - if (!jsonPath.endsWith('.')) { - jsonPath += '.'; - } - jsonPath += propertyKey; - return jsonPath; -} - -function resolveJsonSchemaType(jsonSchemaTypesByType, yamlPath) { - let last = jsonSchemaTypesByType[rootTypeName]; - if (!last) { - throw new Error(`JSON schema missing root type '${rootTypeName}'`); - } - for (let i = 0; i < yamlPath.length; i++) { - const entry = yamlPath[i]; - if (yaml.isPair(entry)) { - const jsonSchemaProperty = last.properties.find(property => property.property === entry.key.value); - if (!jsonSchemaProperty) { - throw new Error(`Unknown property ${entry.key.value} in type ${last.type}.`); - } - // A property may have multiple types. Naively, resolve the type to be the first one that exists in jsonSchemaTypesByType. - const resolvedTypes = jsonSchemaProperty.types.map(type => jsonSchemaTypesByType[type]).filter(Boolean); - if (resolvedTypes.length > 0) { - last = resolvedTypes[0]; - } else { - throw new Error(`Unable to resolve JSON schema type for property ${entry.key.value} in type ${last.type}.`); - } - } - } - return last; -}