From 02c3f562db05583b0c268e342a577fd496c08e7e Mon Sep 17 00:00:00 2001 From: JamieDanielson Date: Mon, 27 Oct 2025 18:32:27 -0400 Subject: [PATCH 1/7] wip generate types for otel config schema --- .../opentelemetry-configuration/README.md | 14 +- .../opentelemetry-configuration/package.json | 1 + .../generated/opentelemetry-configuration.ts | 638 ++++++++++++++++++ package-lock.json | 73 +- package.json | 3 +- scripts/config/generate-config.js | 128 ++++ scripts/config/generate-config.sh | 30 + 7 files changed, 869 insertions(+), 18 deletions(-) create mode 100644 experimental/packages/opentelemetry-configuration/src/generated/opentelemetry-configuration.ts create mode 100644 scripts/config/generate-config.js create mode 100755 scripts/config/generate-config.sh diff --git a/experimental/packages/opentelemetry-configuration/README.md b/experimental/packages/opentelemetry-configuration/README.md index 7c4b2576bfb..c3de65d8a70 100644 --- a/experimental/packages/opentelemetry-configuration/README.md +++ b/experimental/packages/opentelemetry-configuration/README.md @@ -1,4 +1,4 @@ -# OpenTelemetry SDK for Node.js +# OpenTelemetry Configuration for Node.js [![Apache License][license-image]][license-image] @@ -20,6 +20,18 @@ To get started you need to install `@opentelemetry/configuration`. npm install @opentelemetry/configuration ``` +## Type Definitions + +This package includes TypeScript type definitions generated from the official [OpenTelemetry Configuration Schema](https://github.com/open-telemetry/opentelemetry-configuration). + +### Regenerating Types + +To regenerate the TypeScript types from the latest schema: + +```sh +npm run generate:config +``` + ## Useful links - For more information on OpenTelemetry, visit: diff --git a/experimental/packages/opentelemetry-configuration/package.json b/experimental/packages/opentelemetry-configuration/package.json index e278964a173..4f9c98076ae 100644 --- a/experimental/packages/opentelemetry-configuration/package.json +++ b/experimental/packages/opentelemetry-configuration/package.json @@ -10,6 +10,7 @@ "prepublishOnly": "npm run compile", "compile": "tsc --build", "clean": "tsc --build --clean", + "generate:config": "node ../../../scripts/config/generate-config.js", "test": "nyc mocha test/**/*.test.ts", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", diff --git a/experimental/packages/opentelemetry-configuration/src/generated/opentelemetry-configuration.ts b/experimental/packages/opentelemetry-configuration/src/generated/opentelemetry-configuration.ts new file mode 100644 index 00000000000..96321ab84e1 --- /dev/null +++ b/experimental/packages/opentelemetry-configuration/src/generated/opentelemetry-configuration.ts @@ -0,0 +1,638 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + +export type OtlpHttpExporter = { + endpoint?: string | null; + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + headers?: NameStringValuePair[]; + headers_list?: string | null; + compression?: string | null; + timeout?: number | null; + encoding?: ('protobuf' | 'json') | null; +} & ({ + endpoint?: string | null; + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + headers?: NameStringValuePair[]; + headers_list?: string | null; + compression?: string | null; + timeout?: number | null; + encoding?: ('protobuf' | 'json') | null; +} | null) & { + endpoint?: string | null; + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + headers?: NameStringValuePair[]; + headers_list?: string | null; + compression?: string | null; + timeout?: number | null; + encoding?: ('protobuf' | 'json') | null; + } & ({ + endpoint?: string | null; + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + headers?: NameStringValuePair[]; + headers_list?: string | null; + compression?: string | null; + timeout?: number | null; + encoding?: ('protobuf' | 'json') | null; + } | null); +export type OtlpGrpcExporter = { + endpoint?: string | null; + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + headers?: NameStringValuePair[]; + headers_list?: string | null; + compression?: string | null; + timeout?: number | null; + insecure?: boolean | null; +} & ({ + endpoint?: string | null; + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + headers?: NameStringValuePair[]; + headers_list?: string | null; + compression?: string | null; + timeout?: number | null; + insecure?: boolean | null; +} | null) & { + endpoint?: string | null; + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + headers?: NameStringValuePair[]; + headers_list?: string | null; + compression?: string | null; + timeout?: number | null; + insecure?: boolean | null; + } & ({ + endpoint?: string | null; + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + headers?: NameStringValuePair[]; + headers_list?: string | null; + compression?: string | null; + timeout?: number | null; + insecure?: boolean | null; + } | null); +export type ExperimentalOtlpFileExporter = { + output_stream?: string | null; +} & ({ + output_stream?: string | null; +} | null) & { + output_stream?: string | null; + } & ({ + output_stream?: string | null; + } | null); +export type ConsoleExporter = {} | null; +export type OtlpHttpMetricExporter = { + endpoint?: string | null; + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + headers?: NameStringValuePair[]; + headers_list?: string | null; + compression?: string | null; + timeout?: number | null; + encoding?: ('protobuf' | 'json') | null; + temporality_preference?: ('cumulative' | 'delta' | 'low_memory') | null; + default_histogram_aggregation?: + | ('explicit_bucket_histogram' | 'base2_exponential_bucket_histogram') + | null; +} & ({ + endpoint?: string | null; + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + headers?: NameStringValuePair[]; + headers_list?: string | null; + compression?: string | null; + timeout?: number | null; + encoding?: ('protobuf' | 'json') | null; + temporality_preference?: ('cumulative' | 'delta' | 'low_memory') | null; + default_histogram_aggregation?: + | ('explicit_bucket_histogram' | 'base2_exponential_bucket_histogram') + | null; +} | null); +export type OtlpGrpcMetricExporter = { + endpoint?: string | null; + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + headers?: NameStringValuePair[]; + headers_list?: string | null; + compression?: string | null; + timeout?: number | null; + insecure?: boolean | null; + temporality_preference?: ('cumulative' | 'delta' | 'low_memory') | null; + default_histogram_aggregation?: + | ('explicit_bucket_histogram' | 'base2_exponential_bucket_histogram') + | null; +} & ({ + endpoint?: string | null; + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + headers?: NameStringValuePair[]; + headers_list?: string | null; + compression?: string | null; + timeout?: number | null; + insecure?: boolean | null; + temporality_preference?: ('cumulative' | 'delta' | 'low_memory') | null; + default_histogram_aggregation?: + | ('explicit_bucket_histogram' | 'base2_exponential_bucket_histogram') + | null; +} | null); +export type ExperimentalOtlpFileMetricExporter = { + output_stream?: string | null; + temporality_preference?: ('cumulative' | 'delta' | 'low_memory') | null; + default_histogram_aggregation?: + | ('explicit_bucket_histogram' | 'base2_exponential_bucket_histogram') + | null; +} & ({ + output_stream?: string | null; + temporality_preference?: ('cumulative' | 'delta' | 'low_memory') | null; + default_histogram_aggregation?: + | ('explicit_bucket_histogram' | 'base2_exponential_bucket_histogram') + | null; +} | null); +export type OpenCensusMetricProducer = {} | null; +export type ExperimentalPrometheusMetricExporter = { + host?: string | null; + port?: number | null; + without_scope_info?: boolean | null; + with_resource_constant_labels?: IncludeExclude; + translation_strategy?: + | ( + | 'UnderscoreEscapingWithSuffixes' + | 'UnderscoreEscapingWithoutSuffixes' + | 'NoUTF8EscapingWithSuffixes' + | 'NoTranslation' + ) + | null; +} & ({ + host?: string | null; + port?: number | null; + without_scope_info?: boolean | null; + with_resource_constant_labels?: IncludeExclude; + translation_strategy?: + | ( + | 'UnderscoreEscapingWithSuffixes' + | 'UnderscoreEscapingWithoutSuffixes' + | 'NoUTF8EscapingWithSuffixes' + | 'NoTranslation' + ) + | null; +} | null); +export type DefaultAggregation = {} | null; +export type DropAggregation = {} | null; +export type ExplicitBucketHistogramAggregation = { + boundaries?: number[]; + record_min_max?: boolean | null; +} & ({ + boundaries?: number[]; + record_min_max?: boolean | null; +} | null); +export type Base2ExponentialBucketHistogramAggregation = { + max_scale?: number | null; + max_size?: number | null; + record_min_max?: boolean | null; +} & ({ + max_scale?: number | null; + max_size?: number | null; + record_min_max?: boolean | null; +} | null); +export type LastValueAggregation = {} | null; +export type SumAggregation = {} | null; +export type TraceContextPropagator = {} | null; +export type BaggagePropagator = {} | null; +export type B3Propagator = {} | null; +export type B3MultiPropagator = {} | null; +export type JaegerPropagator = {} | null; +export type OpenTracingPropagator = {} | null; +export type ZipkinSpanExporter = { + endpoint?: string | null; + timeout?: number | null; +} & ({ + endpoint?: string | null; + timeout?: number | null; +} | null); +export type AlwaysOffSampler = {} | null; +export type AlwaysOnSampler = {} | null; +export type JaegerRemoteSampler = { + endpoint?: string | null; + interval?: number | null; + initial_sampler?: Sampler; +} & ({ + endpoint?: string | null; + interval?: number | null; + initial_sampler?: Sampler; +} | null); +export type ParentBasedSampler = { + root?: Sampler; + remote_parent_sampled?: Sampler; + remote_parent_not_sampled?: Sampler; + local_parent_sampled?: Sampler; + local_parent_not_sampled?: Sampler; +} & ({ + root?: Sampler; + remote_parent_sampled?: Sampler; + remote_parent_not_sampled?: Sampler; + local_parent_sampled?: Sampler; + local_parent_not_sampled?: Sampler; +} | null); +export type TraceIdRatioBasedSampler = { + ratio?: number | null; +} & ({ + ratio?: number | null; +} | null); +export type ExperimentalContainerResourceDetector = {} | null; +export type ExperimentalHostResourceDetector = {} | null; +export type ExperimentalProcessResourceDetector = {} | null; +export type ExperimentalServiceResourceDetector = {} | null; + +export interface OpenTelemetryConfiguration { + file_format: string; + disabled?: boolean | null; + log_level?: string | null; + attribute_limits?: AttributeLimits; + logger_provider?: HttpsOpentelemetryIoOtelconfigLoggerProviderJson; + meter_provider?: HttpsOpentelemetryIoOtelconfigMeterProviderJson; + propagator?: HttpsOpentelemetryIoOtelconfigPropagatorJson; + tracer_provider?: HttpsOpentelemetryIoOtelconfigTracerProviderJson; + resource?: HttpsOpentelemetryIoOtelconfigResourceJson; + 'instrumentation/development'?: HttpsOpentelemetryIoOtelconfigInstrumentationJson; + [k: string]: any | undefined; +} +export interface AttributeLimits { + attribute_value_length_limit?: number | null; + attribute_count_limit?: number | null; + [k: string]: any | undefined; +} +export interface HttpsOpentelemetryIoOtelconfigLoggerProviderJson { + /** + * @minItems 1 + */ + processors: [LogRecordProcessor, ...LogRecordProcessor[]]; + limits?: LogRecordLimits; + 'logger_configurator/development'?: ExperimentalLoggerConfigurator; +} +export interface LogRecordProcessor { + batch?: BatchLogRecordProcessor; + simple?: SimpleLogRecordProcessor; + [k: string]: + | { + [k: string]: any | undefined; + } + | undefined; +} +export interface BatchLogRecordProcessor { + schedule_delay?: number | null; + export_timeout?: number | null; + max_queue_size?: number | null; + max_export_batch_size?: number | null; + exporter: LogRecordExporter; +} +export interface LogRecordExporter { + otlp_http?: OtlpHttpExporter; + otlp_grpc?: OtlpGrpcExporter; + 'otlp_file/development'?: ExperimentalOtlpFileExporter; + console?: ConsoleExporter; + [k: string]: + | ({ + [k: string]: any | undefined; + } | null) + | undefined; +} +export interface NameStringValuePair { + name: string; + value: string | null; +} +export interface SimpleLogRecordProcessor { + exporter: LogRecordExporter; +} +export interface LogRecordLimits { + attribute_value_length_limit?: number | null; + attribute_count_limit?: number | null; +} +export interface ExperimentalLoggerConfigurator { + default_config?: ExperimentalLoggerConfig; + loggers?: ExperimentalLoggerMatcherAndConfig[]; +} +export interface ExperimentalLoggerConfig { + disabled?: boolean; +} +export interface ExperimentalLoggerMatcherAndConfig { + name?: string; + config?: ExperimentalLoggerConfig; +} +export interface HttpsOpentelemetryIoOtelconfigMeterProviderJson { + /** + * @minItems 1 + */ + readers: [MetricReader, ...MetricReader[]]; + views?: View[]; + exemplar_filter?: ('always_on' | 'always_off' | 'trace_based') | null; + 'meter_configurator/development'?: ExperimentalMeterConfigurator; +} +export interface MetricReader { + periodic?: PeriodicMetricReader; + pull?: PullMetricReader; +} +export interface PeriodicMetricReader { + interval?: number | null; + timeout?: number | null; + exporter: PushMetricExporter; + producers?: MetricProducer[]; + cardinality_limits?: CardinalityLimits; +} +export interface PushMetricExporter { + otlp_http?: OtlpHttpMetricExporter; + otlp_grpc?: OtlpGrpcMetricExporter; + 'otlp_file/development'?: ExperimentalOtlpFileMetricExporter; + console?: ConsoleExporter; + [k: string]: + | ({ + [k: string]: any | undefined; + } | null) + | undefined; +} +export interface MetricProducer { + opencensus?: OpenCensusMetricProducer; + [k: string]: + | ({ + [k: string]: any | undefined; + } | null) + | undefined; +} +export interface CardinalityLimits { + default?: number | null; + counter?: number | null; + gauge?: number | null; + histogram?: number | null; + observable_counter?: number | null; + observable_gauge?: number | null; + observable_up_down_counter?: number | null; + up_down_counter?: number | null; +} +export interface PullMetricReader { + exporter: PullMetricExporter; + producers?: MetricProducer[]; + cardinality_limits?: CardinalityLimits; +} +export interface PullMetricExporter { + 'prometheus/development'?: ExperimentalPrometheusMetricExporter; + [k: string]: + | ({ + [k: string]: any | undefined; + } | null) + | undefined; +} +export interface IncludeExclude { + included?: string[]; + excluded?: string[]; +} +export interface View { + selector?: ViewSelector; + stream?: ViewStream; +} +export interface ViewSelector { + instrument_name?: string | null; + instrument_type?: + | ( + | 'counter' + | 'gauge' + | 'histogram' + | 'observable_counter' + | 'observable_gauge' + | 'observable_up_down_counter' + | 'up_down_counter' + ) + | null; + unit?: string | null; + meter_name?: string | null; + meter_version?: string | null; + meter_schema_url?: string | null; +} +export interface ViewStream { + name?: string | null; + description?: string | null; + aggregation?: Aggregation; + aggregation_cardinality_limit?: number | null; + attribute_keys?: IncludeExclude; +} +export interface Aggregation { + default?: DefaultAggregation; + drop?: DropAggregation; + explicit_bucket_histogram?: ExplicitBucketHistogramAggregation; + base2_exponential_bucket_histogram?: Base2ExponentialBucketHistogramAggregation; + last_value?: LastValueAggregation; + sum?: SumAggregation; +} +export interface ExperimentalMeterConfigurator { + default_config?: ExperimentalMeterConfig; + meters?: ExperimentalMeterMatcherAndConfig[]; +} +export interface ExperimentalMeterConfig { + disabled?: boolean; +} +export interface ExperimentalMeterMatcherAndConfig { + name?: string; + config?: ExperimentalMeterConfig; +} +export interface HttpsOpentelemetryIoOtelconfigPropagatorJson { + composite?: TextMapPropagator[]; + composite_list?: string | null; + [k: string]: any | undefined; +} +export interface TextMapPropagator { + tracecontext?: TraceContextPropagator; + baggage?: BaggagePropagator; + b3?: B3Propagator; + b3multi?: B3MultiPropagator; + jaeger?: JaegerPropagator; + ottrace?: OpenTracingPropagator; + [k: string]: + | ({ + [k: string]: any | undefined; + } | null) + | undefined; +} +export interface HttpsOpentelemetryIoOtelconfigTracerProviderJson { + /** + * @minItems 1 + */ + processors: [SpanProcessor, ...SpanProcessor[]]; + limits?: SpanLimits; + sampler?: Sampler; + 'tracer_configurator/development'?: ExperimentalTracerConfigurator; +} +export interface SpanProcessor { + batch?: BatchSpanProcessor; + simple?: SimpleSpanProcessor; + [k: string]: + | ({ + [k: string]: any | undefined; + } | null) + | undefined; +} +export interface BatchSpanProcessor { + schedule_delay?: number | null; + export_timeout?: number | null; + max_queue_size?: number | null; + max_export_batch_size?: number | null; + exporter: SpanExporter; +} +export interface SpanExporter { + otlp_http?: OtlpHttpExporter; + otlp_grpc?: OtlpGrpcExporter; + 'otlp_file/development'?: ExperimentalOtlpFileExporter; + console?: ConsoleExporter; + zipkin?: ZipkinSpanExporter; + [k: string]: + | ({ + [k: string]: any | undefined; + } | null) + | undefined; +} +export interface SimpleSpanProcessor { + exporter: SpanExporter; +} +export interface SpanLimits { + attribute_value_length_limit?: number | null; + attribute_count_limit?: number | null; + event_count_limit?: number | null; + link_count_limit?: number | null; + event_attribute_count_limit?: number | null; + link_attribute_count_limit?: number | null; +} +export interface Sampler { + always_off?: AlwaysOffSampler; + always_on?: AlwaysOnSampler; + jaeger_remote?: JaegerRemoteSampler; + parent_based?: ParentBasedSampler; + trace_id_ratio_based?: TraceIdRatioBasedSampler; + [k: string]: + | ({ + [k: string]: any | undefined; + } | null) + | undefined; +} +export interface ExperimentalTracerConfigurator { + default_config?: ExperimentalTracerConfig; + tracers?: ExperimentalTracerMatcherAndConfig[]; +} +export interface ExperimentalTracerConfig { + disabled?: boolean; +} +export interface ExperimentalTracerMatcherAndConfig { + name?: string; + config?: ExperimentalTracerConfig; +} +export interface HttpsOpentelemetryIoOtelconfigResourceJson { + attributes?: AttributeNameValue[]; + 'detection/development'?: ExperimentalResourceDetection; + schema_url?: string | null; + attributes_list?: string | null; +} +export interface AttributeNameValue { + name: string; + value: string | number | boolean | null | string[] | boolean[] | number[]; + type?: + | null + | 'string' + | 'bool' + | 'int' + | 'double' + | 'string_array' + | 'bool_array' + | 'int_array' + | 'double_array'; +} +export interface ExperimentalResourceDetection { + attributes?: IncludeExclude; + detectors?: ExperimentalResourceDetector[]; +} +export interface ExperimentalResourceDetector { + container?: ExperimentalContainerResourceDetector; + host?: ExperimentalHostResourceDetector; + process?: ExperimentalProcessResourceDetector; + service?: ExperimentalServiceResourceDetector; + [k: string]: + | ({ + [k: string]: any | undefined; + } | null) + | undefined; +} +export interface HttpsOpentelemetryIoOtelconfigInstrumentationJson { + general?: ExperimentalGeneralInstrumentation; + cpp?: ExperimentalLanguageSpecificInstrumentation; + dotnet?: ExperimentalLanguageSpecificInstrumentation; + erlang?: ExperimentalLanguageSpecificInstrumentation; + go?: ExperimentalLanguageSpecificInstrumentation; + java?: ExperimentalLanguageSpecificInstrumentation; + js?: ExperimentalLanguageSpecificInstrumentation; + php?: ExperimentalLanguageSpecificInstrumentation; + python?: ExperimentalLanguageSpecificInstrumentation; + ruby?: ExperimentalLanguageSpecificInstrumentation; + rust?: ExperimentalLanguageSpecificInstrumentation; + swift?: ExperimentalLanguageSpecificInstrumentation; + [k: string]: + | ExperimentalLanguageSpecificInstrumentation + | ExperimentalGeneralInstrumentation + | undefined; +} +export interface ExperimentalGeneralInstrumentation { + peer?: ExperimentalPeerInstrumentation; + http?: ExperimentalHttpInstrumentation; +} +export interface ExperimentalPeerInstrumentation { + service_mapping?: { + peer: string; + service: string; + }[]; +} +export interface ExperimentalHttpInstrumentation { + client?: { + request_captured_headers?: string[]; + response_captured_headers?: string[]; + }; + server?: { + request_captured_headers?: string[]; + response_captured_headers?: string[]; + }; +} +export interface ExperimentalLanguageSpecificInstrumentation { + [k: string]: + | { + [k: string]: any | undefined; + } + | undefined; +} diff --git a/package-lock.json b/package-lock.json index 60381ec8049..fd257a67840 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,6 +37,7 @@ "eslint-plugin-prettier": "5.5.4", "gh-pages": "6.3.0", "glob": "^11.0.0", + "json-schema-to-typescript": "^15.0.4", "karma": "6.4.4", "karma-chrome-launcher": "3.1.0", "karma-coverage": "2.2.1", @@ -1335,22 +1336,6 @@ "@opentelemetry/api": "^1.3.0" } }, - "experimental/packages/sampler-composite/node_modules/@opentelemetry/resources": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.0.1.tgz", - "integrity": "sha512-dZOB3R6zvBwDKnHDTB4X1xtMArB/d324VsbiPkX/Yu0Q8T2xceRthoIVFhJdvgVM2QhGVUyX9tzwiNxGtoBJUw==", - "license": "Apache-2.0", - "dependencies": { - "@opentelemetry/core": "2.0.1", - "@opentelemetry/semantic-conventions": "^1.29.0" - }, - "engines": { - "node": "^18.19.0 || >=20.6.0" - }, - "peerDependencies": { - "@opentelemetry/api": ">=1.3.0 <1.10.0" - } - }, "experimental/packages/sampler-composite/node_modules/chokidar": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", @@ -1679,6 +1664,24 @@ "node": ">=6.0.0" } }, + "node_modules/@apidevtools/json-schema-ref-parser": { + "version": "11.9.3", + "resolved": "https://registry.npmjs.org/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-11.9.3.tgz", + "integrity": "sha512-60vepv88RwcJtSHrD6MjIL6Ta3SOYbgfnkHb+ppAVK+o9mXprRtulx7VlRl3lN3bbvysAfCS7WMVfhUYemB0IQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jsdevtools/ono": "^7.1.3", + "@types/json-schema": "^7.0.15", + "js-yaml": "^4.1.0" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/philsturgeon" + } + }, "node_modules/@babel/code-frame": { "version": "7.27.1", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz", @@ -4400,6 +4403,13 @@ "url": "https://opencollective.com/js-sdsl" } }, + "node_modules/@jsdevtools/ono": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz", + "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==", + "dev": true, + "license": "MIT" + }, "node_modules/@jsdoc/salty": { "version": "0.2.9", "resolved": "https://registry.npmjs.org/@jsdoc/salty/-/salty-0.2.9.tgz", @@ -7240,6 +7250,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/lodash": { + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.20.tgz", + "integrity": "sha512-H3MHACvFUEiujabxhaI/ImO6gUrd8oOurg7LQtS7mbwIXA/cUqWrvBsaeJ23aZEPk1TAYkurjfMbSELfoCXlGA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/markdown-it": { "version": "14.1.2", "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-14.1.2.tgz", @@ -14857,6 +14874,30 @@ "dev": true, "license": "MIT" }, + "node_modules/json-schema-to-typescript": { + "version": "15.0.4", + "resolved": "https://registry.npmjs.org/json-schema-to-typescript/-/json-schema-to-typescript-15.0.4.tgz", + "integrity": "sha512-Su9oK8DR4xCmDsLlyvadkXzX6+GGXJpbhwoLtOGArAG61dvbW4YQmSEno2y66ahpIdmLMg6YUf/QHLgiwvkrHQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@apidevtools/json-schema-ref-parser": "^11.5.5", + "@types/json-schema": "^7.0.15", + "@types/lodash": "^4.17.7", + "is-glob": "^4.0.3", + "js-yaml": "^4.1.0", + "lodash": "^4.17.21", + "minimist": "^1.2.8", + "prettier": "^3.2.5", + "tinyglobby": "^0.2.9" + }, + "bin": { + "json2ts": "dist/src/cli.js" + }, + "engines": { + "node": ">=16.0.0" + } + }, "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", diff --git a/package.json b/package.json index 5f9505df3ff..4efccb859f5 100644 --- a/package.json +++ b/package.json @@ -87,6 +87,7 @@ "eslint-plugin-prettier": "5.5.4", "gh-pages": "6.3.0", "glob": "^11.0.0", + "json-schema-to-typescript": "^15.0.4", "karma": "6.4.4", "karma-chrome-launcher": "3.1.0", "karma-coverage": "2.2.1", @@ -97,9 +98,9 @@ "lerna": "9.0.0", "linkinator": "7.1.3", "markdownlint-cli2": "0.18.1", + "nx": "20.8.2", "prettier": "3.6.2", "process": "0.11.10", - "nx": "20.8.2", "semver": "7.7.3", "ts-node": "10.9.2", "typedoc": "0.27.9", diff --git a/scripts/config/generate-config.js b/scripts/config/generate-config.js new file mode 100644 index 00000000000..9e1667aae66 --- /dev/null +++ b/scripts/config/generate-config.js @@ -0,0 +1,128 @@ +#!/usr/bin/env node + +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Configuration generation wrapper script + * This script: + * 1. Runs the generate_config.sh bash script to clone the schema repository + * 2. Uses json-schema-to-typescript to generate TypeScript types from the JSON schema + * 3. Post-processes the generated file by adding license headers and fixing types + */ + +const { compileFromFile } = require('json-schema-to-typescript'); +const fs = require('fs'); +const { execSync } = require('child_process'); +const path = require('path'); + +const SCRIPT_DIR = __dirname; +const ROOT_DIR = path.join(SCRIPT_DIR, '..', '..'); + +// Run the bash script to get the latest version of the schema +const scriptPath = path.join(SCRIPT_DIR, 'generate-config.sh'); +execSync(`bash "${scriptPath}"`, { stdio: 'inherit', cwd: SCRIPT_DIR }); + +function addLicenseHeader(content) { + const licenseHeader = `/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +`; + + return licenseHeader + content; +} + +const options = { + cwd: `${ROOT_DIR}/scripts/config/opentelemetry-configuration/schema`, + strictIndexSignatures: true, // adds undefined + unknownAny: false // too strict for simple and batch processor +} + +// compile from file +const outputPath = `${ROOT_DIR}/experimental/packages/opentelemetry-configuration/src/generated/opentelemetry-configuration.ts`; +compileFromFile(`${ROOT_DIR}/scripts/config/opentelemetry-configuration/schema/opentelemetry_configuration.json`, options) + .then(ts => { + fs.writeFileSync(outputPath, ts); + + // Post-process step to fix the HttpsOpentelemetryIoOtelconfigInstrumentationJson type + // See notes below for details on why this is needed + let content = fs.readFileSync(outputPath, 'utf8'); + + // Find and replace the index signature in HttpsOpentelemetryIoOtelconfigInstrumentationJson + // Pattern matches the interface and its index signature line + const pattern = /(export interface HttpsOpentelemetryIoOtelconfigInstrumentationJson\s*\{[\s\S]*?)(\s+\[k: string\]: ExperimentalLanguageSpecificInstrumentation;)/; + + content = content.replace(pattern, (match, interfaceStart, indexSignature) => { + // Replace the index signature with the corrected multi-type version + const replacement = ` [k: string]:\n | ExperimentalLanguageSpecificInstrumentation\n | ExperimentalGeneralInstrumentation\n | undefined;`; + return interfaceStart + replacement; + }); + + // Add license header if not present + if (!content.includes('Copyright The OpenTelemetry Authors')) { + content = addLicenseHeader(content); + } + + // Write back the processed content + fs.writeFileSync(outputPath, content); + + // format opentelemetry-configuration generated types + execSync(`npx prettier --write ${outputPath}`, { stdio: 'inherit' }); + + // compile opentelemetry-configuration package + execSync(`npm run compile`, { stdio: 'inherit', cwd: `${ROOT_DIR}/experimental/packages/opentelemetry-configuration` }); + }); + +/* notes +2 bugs in json-schema-to-typescript +Seems to miss adding | undefined to HttpsOpentelemetryIoOtelconfigInstrumentationJson +It also seems to miss the already-defined types in the generated code +https://github.com/bcherny/json-schema-to-typescript/issues/604 +https://github.com/bcherny/json-schema-to-typescript/issues/402 +related to ts issue https://github.com/microsoft/TypeScript/issues/17867 + +export interface HttpsOpentelemetryIoOtelconfigInstrumentationJson { + general?: ExperimentalGeneralInstrumentation; + cpp?: ExperimentalLanguageSpecificInstrumentation; +... + swift?: ExperimentalLanguageSpecificInstrumentation; + [k: string]: ExperimentalLanguageSpecificInstrumentation; +} + becomes + +export interface HttpsOpentelemetryIoOtelconfigInstrumentationJson { + general?: ExperimentalGeneralInstrumentation; + cpp?: ExperimentalLanguageSpecificInstrumentation; +... + swift?: ExperimentalLanguageSpecificInstrumentation; + [k: string]: + | ExperimentalLanguageSpecificInstrumentation + | ExperimentalGeneralInstrumentation + | undefined; +} +*/ diff --git a/scripts/config/generate-config.sh b/scripts/config/generate-config.sh new file mode 100755 index 00000000000..a9355ccfe15 --- /dev/null +++ b/scripts/config/generate-config.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +set -e + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +ROOT_DIR="${SCRIPT_DIR}/../../" + +# Get latest version by running `git tag -l --sort=version:refname | tail -1` +# ... in git@github.com:open-telemetry/opentelemetry-configuration.git +CONFIG_VERSION=v0.4.0 + +# When running on windows and you are getting references to ";C" (like Telemetry;C) +# then this is an issue with the bash shell, so first run the following in your shell: +# export MSYS_NO_PATHCONV=1 + +cd ${SCRIPT_DIR} + +rm -rf opentelemetry-configuration || true +mkdir opentelemetry-configuration +cd opentelemetry-configuration + +git init +# git remote add origin https://github.com/open-telemetry/opentelemetry-configuration.git +# this branch has the fix that removes patternProperties +git remote add origin https://github.com/dol/opentelemetry-configuration +git fetch origin fix/wildcard-pattern +git checkout fix/wildcard-pattern +# git fetch origin "${CONFIG_VERSION}" --depth=1 +git reset --hard FETCH_HEAD +cd ${SCRIPT_DIR} From f81e24672f2779f57889404e51d382632cb2ecbe Mon Sep 17 00:00:00 2001 From: JamieDanielson Date: Wed, 29 Oct 2025 16:52:05 -0400 Subject: [PATCH 2/7] update script to add type defs used claude to help with this. there's a good chance there's still extra fluff that needs sorting through. also still need to sort out the weird union behavior. we may need to maintain a fork with the fixes if they dont get merged upstream. --- .../generated/opentelemetry-configuration.ts | 729 +++++++++++++++++- scripts/config/generate-config.js | 299 ++++++- scripts/config/generate-config.sh | 2 +- 3 files changed, 986 insertions(+), 44 deletions(-) diff --git a/experimental/packages/opentelemetry-configuration/src/generated/opentelemetry-configuration.ts b/experimental/packages/opentelemetry-configuration/src/generated/opentelemetry-configuration.ts index 96321ab84e1..4fe6c62f83e 100644 --- a/experimental/packages/opentelemetry-configuration/src/generated/opentelemetry-configuration.ts +++ b/experimental/packages/opentelemetry-configuration/src/generated/opentelemetry-configuration.ts @@ -22,19 +22,35 @@ export type OtlpHttpExporter = { endpoint?: string | null; - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; + /** Configure TLS settings for the exporter. */ + tls?: HttpTls; + /** + * Configure headers. Entries have higher priority than entries from .headers_list. + * If an entry's .value is null, the entry is ignored. + */ headers?: NameStringValuePair[]; + /** + * 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?: string | null; + /** + * Configure compression. + * Values include: gzip, none. Implementations may support other compression algorithms. + * If omitted or null, none is used. + */ compression?: string | null; + /** + * 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?: number | null; encoding?: ('protobuf' | 'json') | null; } & ({ endpoint?: string | null; - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; + tls?: HttpTls; headers?: NameStringValuePair[]; headers_list?: string | null; compression?: string | null; @@ -42,71 +58,199 @@ export type OtlpHttpExporter = { encoding?: ('protobuf' | 'json') | null; } | null) & { endpoint?: string | null; - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; + /** Configure TLS settings for the exporter. */ + tls?: HttpTls; + /** + * Configure headers. Entries have higher priority than entries from .headers_list. + * If an entry's .value is null, the entry is ignored. + */ headers?: NameStringValuePair[]; + /** + * 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?: string | null; + /** + * Configure compression. + * Values include: gzip, none. Implementations may support other compression algorithms. + * If omitted or null, none is used. + */ compression?: string | null; + /** + * 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?: number | null; encoding?: ('protobuf' | 'json') | null; } & ({ endpoint?: string | null; - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; + tls?: HttpTls; headers?: NameStringValuePair[]; headers_list?: string | null; compression?: string | null; timeout?: number | null; encoding?: ('protobuf' | 'json') | null; } | null); -export type OtlpGrpcExporter = { - endpoint?: string | null; +export type HttpTls = { + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; +} & ({ certificate_file?: string | null; client_key_file?: string | null; client_certificate_file?: string | null; +} | null) & { + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + } & ({ + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + } | null) & { + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + } & ({ + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + } | null) & { + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + } & ({ + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + } | null); +export type OtlpGrpcExporter = { + endpoint?: string | null; + /** Configure TLS settings for the exporter. */ + tls?: GrpcTls; + /** + * Configure headers. Entries have higher priority than entries from .headers_list. + * If an entry's .value is null, the entry is ignored. + */ headers?: NameStringValuePair[]; + /** + * 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?: string | null; + /** + * Configure compression. + * Values include: gzip, none. Implementations may support other compression algorithms. + * If omitted or null, none is used. + */ compression?: string | null; + /** + * 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?: number | null; - insecure?: boolean | null; } & ({ endpoint?: string | null; - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; + tls?: GrpcTls; headers?: NameStringValuePair[]; headers_list?: string | null; compression?: string | null; timeout?: number | null; - insecure?: boolean | null; } | null) & { endpoint?: string | null; - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; + /** Configure TLS settings for the exporter. */ + tls?: GrpcTls; + /** + * Configure headers. Entries have higher priority than entries from .headers_list. + * If an entry's .value is null, the entry is ignored. + */ headers?: NameStringValuePair[]; + /** + * 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?: string | null; + /** + * Configure compression. + * Values include: gzip, none. Implementations may support other compression algorithms. + * If omitted or null, none is used. + */ compression?: string | null; + /** + * 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?: number | null; - insecure?: boolean | null; } & ({ endpoint?: string | null; - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; + tls?: GrpcTls; headers?: NameStringValuePair[]; headers_list?: string | null; compression?: string | null; timeout?: number | null; + } | null); +export type GrpcTls = { + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + insecure?: boolean | null; +} & ({ + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + insecure?: boolean | null; +} | null) & { + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + insecure?: boolean | null; + } & ({ + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + insecure?: boolean | null; + } | null) & { + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + insecure?: boolean | null; + } & ({ + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + insecure?: boolean | null; + } | null) & { + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; + insecure?: boolean | null; + } & ({ + certificate_file?: string | null; + client_key_file?: string | null; + client_certificate_file?: string | null; insecure?: boolean | null; } | null); export type ExperimentalOtlpFileExporter = { + /** + * 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?: string | null; } & ({ output_stream?: string | null; } | null) & { + /** + * 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?: string | null; } & ({ output_stream?: string | null; @@ -114,23 +258,49 @@ export type ExperimentalOtlpFileExporter = { export type ConsoleExporter = {} | null; export type OtlpHttpMetricExporter = { endpoint?: string | null; - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; + /** Configure TLS settings for the exporter. */ + tls?: HttpTls; + /** + * Configure headers. Entries have higher priority than entries from .headers_list. + * If an entry's .value is null, the entry is ignored. + */ headers?: NameStringValuePair[]; + /** + * 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?: string | null; + /** + * Configure compression. + * Values include: gzip, none. Implementations may support other compression algorithms. + * If omitted or null, none is used. + */ compression?: string | null; + /** + * 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?: number | null; encoding?: ('protobuf' | 'json') | null; + /** + * 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' | 'delta' | 'low_memory') | null; + /** + * 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' | 'base2_exponential_bucket_histogram') | null; } & ({ endpoint?: string | null; - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; + tls?: HttpTls; headers?: NameStringValuePair[]; headers_list?: string | null; compression?: string | null; @@ -143,34 +313,63 @@ export type OtlpHttpMetricExporter = { } | null); export type OtlpGrpcMetricExporter = { endpoint?: string | null; - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; + /** Configure TLS settings for the exporter. */ + tls?: GrpcTls; + /** + * Configure headers. Entries have higher priority than entries from .headers_list. + * If an entry's .value is null, the entry is ignored. + */ headers?: NameStringValuePair[]; + /** + * 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?: string | null; + /** + * Configure compression. + * Values include: gzip, none. Implementations may support other compression algorithms. + * If omitted or null, none is used. + */ compression?: string | null; + /** + * 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?: number | null; - insecure?: boolean | null; + /** + * 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' | 'delta' | 'low_memory') | null; + /** + * 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' | 'base2_exponential_bucket_histogram') | null; } & ({ endpoint?: string | null; - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; + tls?: GrpcTls; headers?: NameStringValuePair[]; headers_list?: string | null; compression?: string | null; timeout?: number | null; - insecure?: boolean | null; temporality_preference?: ('cumulative' | 'delta' | 'low_memory') | null; default_histogram_aggregation?: | ('explicit_bucket_histogram' | 'base2_exponential_bucket_histogram') | null; } | null); export type ExperimentalOtlpFileMetricExporter = { + /** + * 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?: string | null; temporality_preference?: ('cumulative' | 'delta' | 'low_memory') | null; default_histogram_aggregation?: @@ -185,10 +384,33 @@ export type ExperimentalOtlpFileMetricExporter = { } | null); export type OpenCensusMetricProducer = {} | null; export type ExperimentalPrometheusMetricExporter = { + /** + * Configure host. + * If omitted or null, localhost is used. + */ host?: string | null; + /** + * Configure port. + * If omitted or null, 9464 is used. + */ port?: number | null; + /** + * Configure Prometheus Exporter to produce metrics without a scope info metric. + * If omitted or null, false is used. + */ without_scope_info?: boolean | null; + /** Configure Prometheus Exporter to add resource attributes as metrics attributes. */ with_resource_constant_labels?: IncludeExclude; + /** + * 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' @@ -214,7 +436,15 @@ export type ExperimentalPrometheusMetricExporter = { export type DefaultAggregation = {} | null; export type DropAggregation = {} | null; export type ExplicitBucketHistogramAggregation = { + /** + * Configure bucket boundaries. + * If omitted, [0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000] is used. + */ boundaries?: number[]; + /** + * Configure record min and max. + * If omitted or null, true is used. + */ record_min_max?: boolean | null; } & ({ boundaries?: number[]; @@ -238,7 +468,16 @@ export type B3MultiPropagator = {} | null; export type JaegerPropagator = {} | null; export type OpenTracingPropagator = {} | null; export type ZipkinSpanExporter = { + /** + * Configure endpoint. + * If omitted or null, http://localhost:9411/api/v2/spans is used. + */ endpoint?: string | null; + /** + * 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?: number | null; } & ({ endpoint?: string | null; @@ -279,20 +518,68 @@ export type ExperimentalProcessResourceDetector = {} | null; export type ExperimentalServiceResourceDetector = {} | null; export interface OpenTelemetryConfiguration { + /** + * The file format version. + * The yaml format is documented at + * https://github.com/open-telemetry/opentelemetry-configuration/tree/main/schema + */ file_format: string; + /** + * Configure if the SDK is disabled or not. + * If omitted or null, false is used. + */ disabled?: boolean | null; + /** + * Configure the log level of the internal logger used by the SDK. + * If omitted, info is used. + */ log_level?: string | null; + /** Configure general attribute limits. See also tracer_provider.limits, logger_provider.limits. */ attribute_limits?: AttributeLimits; + /** + * Configure logger provider. + * If omitted, a noop logger provider is used. + */ logger_provider?: HttpsOpentelemetryIoOtelconfigLoggerProviderJson; + /** + * Configure meter provider. + * If omitted, a noop meter provider is used. + */ meter_provider?: HttpsOpentelemetryIoOtelconfigMeterProviderJson; + /** + * Configure text map context propagators. + * If omitted, a noop propagator is used. + */ propagator?: HttpsOpentelemetryIoOtelconfigPropagatorJson; + /** + * Configure tracer provider. + * If omitted, a noop tracer provider is used. + */ tracer_provider?: HttpsOpentelemetryIoOtelconfigTracerProviderJson; + /** + * Configure resource for all signals. + * If omitted, the default resource is used. + */ resource?: HttpsOpentelemetryIoOtelconfigResourceJson; + /** + * Configure instrumentation. + * This type is in development and subject to breaking changes in minor versions. + */ 'instrumentation/development'?: HttpsOpentelemetryIoOtelconfigInstrumentationJson; [k: string]: any | undefined; } export interface AttributeLimits { + /** + * Configure max attribute value size. + * Value must be non-negative. + * If omitted or null, there is no limit. + */ attribute_value_length_limit?: number | null; + /** + * Configure max attribute count. + * Value must be non-negative. + * If omitted or null, 128 is used. + */ attribute_count_limit?: number | null; [k: string]: any | undefined; } @@ -301,11 +588,18 @@ export interface HttpsOpentelemetryIoOtelconfigLoggerProviderJson { * @minItems 1 */ processors: [LogRecordProcessor, ...LogRecordProcessor[]]; + /** Configure log record limits. See also attribute_limits. */ limits?: LogRecordLimits; + /** + * Configure loggers. + * This type is in development and subject to breaking changes in minor versions. + */ 'logger_configurator/development'?: ExperimentalLoggerConfigurator; } export interface LogRecordProcessor { + /** Configure a batch log record processor. */ batch?: BatchLogRecordProcessor; + /** Configure a simple log record processor. */ simple?: SimpleLogRecordProcessor; [k: string]: | { @@ -314,16 +608,42 @@ export interface LogRecordProcessor { | undefined; } export interface BatchLogRecordProcessor { + /** + * Configure delay interval (in milliseconds) between two consecutive exports. + * Value must be non-negative. + * If omitted or null, 1000 is used. + */ schedule_delay?: number | null; + /** + * 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?: number | null; + /** + * Configure maximum queue size. Value must be positive. + * If omitted or null, 2048 is used. + */ max_queue_size?: number | null; + /** + * Configure maximum batch size. Value must be positive. + * If omitted or null, 512 is used. + */ max_export_batch_size?: number | null; + /** Configure exporter. */ exporter: LogRecordExporter; } export interface LogRecordExporter { + /** Configure exporter to be OTLP with HTTP transport. */ otlp_http?: OtlpHttpExporter; + /** Configure exporter to be OTLP with gRPC transport. */ otlp_grpc?: OtlpGrpcExporter; + /** + * Configure exporter to be OTLP with file transport. + * This type is in development and subject to breaking changes in minor versions. + */ 'otlp_file/development'?: ExperimentalOtlpFileExporter; + /** Configure exporter to be console. */ console?: ConsoleExporter; [k: string]: | ({ @@ -336,21 +656,42 @@ export interface NameStringValuePair { value: string | null; } export interface SimpleLogRecordProcessor { + /** Configure exporter. */ exporter: LogRecordExporter; } export interface LogRecordLimits { + /** + * 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?: number | null; + /** + * 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?: number | null; } export interface ExperimentalLoggerConfigurator { + /** Configure the default logger config used there is no matching entry in .logger_configurator/development.loggers. */ default_config?: ExperimentalLoggerConfig; + /** Configure loggers. */ loggers?: ExperimentalLoggerMatcherAndConfig[]; } export interface ExperimentalLoggerConfig { + /** Configure if the logger is enabled or not. */ disabled?: boolean; } export interface ExperimentalLoggerMatcherAndConfig { + /** + * 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?: string; + /** The logger config. */ config?: ExperimentalLoggerConfig; } export interface HttpsOpentelemetryIoOtelconfigMeterProviderJson { @@ -358,25 +699,60 @@ export interface HttpsOpentelemetryIoOtelconfigMeterProviderJson { * @minItems 1 */ readers: [MetricReader, ...MetricReader[]]; + /** + * Configure views. + * Each view has a selector which determines the instrument(s) it applies to, and a configuration for the resulting stream(s). + */ views?: View[]; + /** + * 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?: ('always_on' | 'always_off' | 'trace_based') | null; + /** + * Configure meters. + * This type is in development and subject to breaking changes in minor versions. + */ 'meter_configurator/development'?: ExperimentalMeterConfigurator; } export interface MetricReader { + /** Configure a periodic metric reader. */ periodic?: PeriodicMetricReader; + /** Configure a pull based metric reader. */ pull?: PullMetricReader; } export interface PeriodicMetricReader { + /** + * Configure delay interval (in milliseconds) between start of two consecutive exports. + * Value must be non-negative. + * If omitted or null, 60000 is used. + */ interval?: number | null; + /** + * 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?: number | null; + /** Configure exporter. */ exporter: PushMetricExporter; + /** Configure metric producers. */ producers?: MetricProducer[]; + /** Configure cardinality limits. */ cardinality_limits?: CardinalityLimits; } export interface PushMetricExporter { + /** Configure exporter to be OTLP with HTTP transport. */ otlp_http?: OtlpHttpMetricExporter; + /** Configure exporter to be OTLP with gRPC transport. */ otlp_grpc?: OtlpGrpcMetricExporter; + /** + * Configure exporter to be OTLP with file transport. + * This type is in development and subject to breaking changes in minor versions. + */ 'otlp_file/development'?: ExperimentalOtlpFileMetricExporter; + /** Configure exporter to be console. */ console?: ConsoleExporter; [k: string]: | ({ @@ -385,6 +761,7 @@ export interface PushMetricExporter { | undefined; } export interface MetricProducer { + /** Configure metric producer to be opencensus. */ opencensus?: OpenCensusMetricProducer; [k: string]: | ({ @@ -393,21 +770,61 @@ export interface MetricProducer { | undefined; } export interface CardinalityLimits { + /** + * Configure default cardinality limit for all instrument types. + * Instrument-specific cardinality limits take priority. + * If omitted or null, 2000 is used. + */ default?: number | null; + /** + * Configure default cardinality limit for counter instruments. + * If omitted or null, the value from .default is used. + */ counter?: number | null; + /** + * Configure default cardinality limit for gauge instruments. + * If omitted or null, the value from .default is used. + */ gauge?: number | null; + /** + * Configure default cardinality limit for histogram instruments. + * If omitted or null, the value from .default is used. + */ histogram?: number | null; + /** + * Configure default cardinality limit for observable_counter instruments. + * If omitted or null, the value from .default is used. + */ observable_counter?: number | null; + /** + * Configure default cardinality limit for observable_gauge instruments. + * If omitted or null, the value from .default is used. + */ observable_gauge?: number | null; + /** + * Configure default cardinality limit for observable_up_down_counter instruments. + * If omitted or null, the value from .default is used. + */ observable_up_down_counter?: number | null; + /** + * Configure default cardinality limit for up_down_counter instruments. + * If omitted or null, the value from .default is used. + */ up_down_counter?: number | null; } export interface PullMetricReader { + /** Configure exporter. */ exporter: PullMetricExporter; + /** Configure metric producers. */ producers?: MetricProducer[]; + /** Configure cardinality limits. */ cardinality_limits?: CardinalityLimits; } export interface PullMetricExporter { + /** + * Configure exporter to be prometheus. + * This type is in development and subject to breaking changes in minor versions. + */ 'prometheus/development'?: ExperimentalPrometheusMetricExporter; [k: string]: | ({ @@ -416,15 +833,43 @@ export interface PullMetricExporter { | undefined; } export interface IncludeExclude { + /** + * Configure list of attribute key patterns to include from resource detectors. + * Attribute keys from resource detectors are evaluated to match as follows: + * * If the value of the attribute key exactly matches. + * * If the value of the attribute key matches the wildcard pattern, where '?' matches any single character and '*' matches any number of characters including none. + * If omitted, all attributes are included. + */ included?: string[]; + /** + * Configure list of attribute key patterns to exclude from resource detectors. Applies after .resource.detectors.attributes.included (i.e. excluded has higher priority than included). + * Attribute keys from resource detectors are evaluated to match as follows: + * * If the value of the attribute key exactly matches. + * * If the value of the attribute key matches the wildcard pattern, where '?' matches any single character and '*' matches any number of characters including none. + * If omitted, .included attributes are included. + */ excluded?: string[]; } export interface View { + /** + * 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?: ViewSelector; + /** Configure view stream. */ stream?: ViewStream; } export interface ViewSelector { + /** + * Configure instrument name selection criteria. + * If omitted or null, all instrument names match. + */ instrument_name?: string | null; + /** + * 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?: | ( | 'counter' @@ -436,48 +881,110 @@ export interface ViewSelector { | 'up_down_counter' ) | null; + /** + * Configure the instrument unit selection criteria. + * If omitted or null, all instrument units match. + */ unit?: string | null; + /** + * Configure meter name selection criteria. + * If omitted or null, all meter names match. + */ meter_name?: string | null; + /** + * Configure meter version selection criteria. + * If omitted or null, all meter versions match. + */ meter_version?: string | null; + /** + * Configure meter schema url selection criteria. + * If omitted or null, all meter schema URLs match. + */ meter_schema_url?: string | null; } export interface ViewStream { + /** + * Configure metric name of the resulting stream(s). + * If omitted or null, the instrument's original name is used. + */ name?: string | null; + /** + * Configure metric description of the resulting stream(s). + * If omitted or null, the instrument's origin description is used. + */ description?: string | null; + /** + * 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?: Aggregation; + /** + * Configure the aggregation cardinality limit. + * If omitted or null, the metric reader's default cardinality limit is used. + */ aggregation_cardinality_limit?: number | null; + /** Configure attribute keys retained in the resulting stream(s). */ attribute_keys?: IncludeExclude; } export interface Aggregation { default?: DefaultAggregation; drop?: DropAggregation; + /** Configure aggregation to be explicit_bucket_histogram. */ explicit_bucket_histogram?: ExplicitBucketHistogramAggregation; base2_exponential_bucket_histogram?: Base2ExponentialBucketHistogramAggregation; last_value?: LastValueAggregation; sum?: SumAggregation; } export interface ExperimentalMeterConfigurator { + /** Configure the default meter config used there is no matching entry in .meter_configurator/development.meters. */ default_config?: ExperimentalMeterConfig; + /** Configure meters. */ meters?: ExperimentalMeterMatcherAndConfig[]; } export interface ExperimentalMeterConfig { + /** Configure if the meter is enabled or not. */ disabled?: boolean; } export interface ExperimentalMeterMatcherAndConfig { + /** + * 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?: string; + /** The meter config. */ config?: ExperimentalMeterConfig; } export interface HttpsOpentelemetryIoOtelconfigPropagatorJson { + /** + * 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?: TextMapPropagator[]; + /** + * 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?: string | null; [k: string]: any | undefined; } export interface TextMapPropagator { + /** Include the w3c trace context propagator. */ tracecontext?: TraceContextPropagator; + /** Include the w3c baggage propagator. */ baggage?: BaggagePropagator; + /** Include the zipkin b3 propagator. */ b3?: B3Propagator; + /** Include the zipkin b3 multi propagator. */ b3multi?: B3MultiPropagator; + /** Include the jaeger propagator. */ jaeger?: JaegerPropagator; + /** Include the opentracing propagator. */ ottrace?: OpenTracingPropagator; [k: string]: | ({ @@ -490,12 +997,23 @@ export interface HttpsOpentelemetryIoOtelconfigTracerProviderJson { * @minItems 1 */ processors: [SpanProcessor, ...SpanProcessor[]]; + /** Configure span limits. See also attribute_limits. */ limits?: SpanLimits; + /** + * Configure the sampler. + * If omitted, parent based sampler with a root of always_on is used. + */ sampler?: Sampler; + /** + * Configure tracers. + * This type is in development and subject to breaking changes in minor versions. + */ 'tracer_configurator/development'?: ExperimentalTracerConfigurator; } export interface SpanProcessor { + /** Configure a batch span processor. */ batch?: BatchSpanProcessor; + /** Configure a simple span processor. */ simple?: SimpleSpanProcessor; [k: string]: | ({ @@ -504,17 +1022,44 @@ export interface SpanProcessor { | undefined; } export interface BatchSpanProcessor { + /** + * Configure delay interval (in milliseconds) between two consecutive exports. + * Value must be non-negative. + * If omitted or null, 5000 is used. + */ schedule_delay?: number | null; + /** + * 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?: number | null; + /** + * Configure maximum queue size. Value must be positive. + * If omitted or null, 2048 is used. + */ max_queue_size?: number | null; + /** + * Configure maximum batch size. Value must be positive. + * If omitted or null, 512 is used. + */ max_export_batch_size?: number | null; + /** Configure exporter. */ exporter: SpanExporter; } export interface SpanExporter { + /** Configure exporter to be OTLP with HTTP transport. */ otlp_http?: OtlpHttpExporter; + /** Configure exporter to be OTLP with gRPC transport. */ otlp_grpc?: OtlpGrpcExporter; + /** + * Configure exporter to be OTLP with file transport. + * This type is in development and subject to breaking changes in minor versions. + */ 'otlp_file/development'?: ExperimentalOtlpFileExporter; + /** Configure exporter to be console. */ console?: ConsoleExporter; + /** Configure exporter to be zipkin. */ zipkin?: ZipkinSpanExporter; [k: string]: | ({ @@ -523,21 +1068,56 @@ export interface SpanExporter { | undefined; } export interface SimpleSpanProcessor { + /** Configure exporter. */ exporter: SpanExporter; } export interface SpanLimits { + /** + * 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?: number | null; + /** + * 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?: number | null; + /** + * Configure max span event count. + * Value must be non-negative. + * If omitted or null, 128 is used. + */ event_count_limit?: number | null; + /** + * Configure max span link count. + * Value must be non-negative. + * If omitted or null, 128 is used. + */ link_count_limit?: number | null; + /** + * Configure max attributes per span event. + * Value must be non-negative. + * If omitted or null, 128 is used. + */ event_attribute_count_limit?: number | null; + /** + * Configure max attributes per span link. + * Value must be non-negative. + * If omitted or null, 128 is used. + */ link_attribute_count_limit?: number | null; } export interface Sampler { + /** Configure sampler to be always_off. */ always_off?: AlwaysOffSampler; + /** Configure sampler to be always_on. */ always_on?: AlwaysOnSampler; jaeger_remote?: JaegerRemoteSampler; + /** Configure sampler to be parent_based. */ parent_based?: ParentBasedSampler; + /** Configure sampler to be trace_id_ratio_based. */ trace_id_ratio_based?: TraceIdRatioBasedSampler; [k: string]: | ({ @@ -546,20 +1126,49 @@ export interface Sampler { | undefined; } export interface ExperimentalTracerConfigurator { + /** Configure the default tracer config used there is no matching entry in .tracer_configurator/development.tracers. */ default_config?: ExperimentalTracerConfig; + /** Configure tracers. */ tracers?: ExperimentalTracerMatcherAndConfig[]; } export interface ExperimentalTracerConfig { + /** Configure if the tracer is enabled or not. */ disabled?: boolean; } export interface ExperimentalTracerMatcherAndConfig { + /** + * 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?: string; + /** The tracer config. */ config?: ExperimentalTracerConfig; } export interface HttpsOpentelemetryIoOtelconfigResourceJson { + /** + * Configure resource attributes. Entries have higher priority than entries from .resource.attributes_list. + * Entries must contain .name and .value, and may optionally include .type. If an entry's .type omitted or null, string is used. + * The .value's type must match the .type. Values for .type include: string, bool, int, double, string_array, bool_array, int_array, double_array. + */ attributes?: AttributeNameValue[]; + /** + * Configure resource detection. + * This type is in development and subject to breaking changes in minor versions. + * If omitted or null, resource detection is disabled. + */ 'detection/development'?: ExperimentalResourceDetection; + /** + * Configure resource schema URL. + * If omitted or null, no schema URL is used. + */ schema_url?: string | null; + /** + * 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?: string | null; } export interface AttributeNameValue { @@ -577,13 +1186,23 @@ export interface AttributeNameValue { | 'double_array'; } export interface ExperimentalResourceDetection { + /** Configure attributes provided by resource detectors. */ attributes?: IncludeExclude; + /** + * 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?: ExperimentalResourceDetector[]; } export interface ExperimentalResourceDetector { + /** Enable the container resource detector, which populates container.* attributes. */ container?: ExperimentalContainerResourceDetector; + /** Enable the host resource detector, which populates host.* and os.* attributes. */ host?: ExperimentalHostResourceDetector; + /** Enable the process resource detector, which populates process.* attributes. */ process?: ExperimentalProcessResourceDetector; + /** Enable the service detector, which populates service.name based on the OTEL_SERVICE_NAME environment variable and service.instance.id. */ service?: ExperimentalServiceResourceDetector; [k: string]: | ({ @@ -592,17 +1211,32 @@ export interface ExperimentalResourceDetector { | undefined; } export interface HttpsOpentelemetryIoOtelconfigInstrumentationJson { + /** + * 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?: ExperimentalGeneralInstrumentation; + /** Configure C++ language-specific instrumentation libraries. */ cpp?: ExperimentalLanguageSpecificInstrumentation; + /** Configure .NET language-specific instrumentation libraries. */ dotnet?: ExperimentalLanguageSpecificInstrumentation; + /** Configure Erlang language-specific instrumentation libraries. */ erlang?: ExperimentalLanguageSpecificInstrumentation; + /** Configure Go language-specific instrumentation libraries. */ go?: ExperimentalLanguageSpecificInstrumentation; + /** Configure Java language-specific instrumentation libraries. */ java?: ExperimentalLanguageSpecificInstrumentation; + /** Configure JavaScript language-specific instrumentation libraries. */ js?: ExperimentalLanguageSpecificInstrumentation; + /** Configure PHP language-specific instrumentation libraries. */ php?: ExperimentalLanguageSpecificInstrumentation; + /** Configure Python language-specific instrumentation libraries. */ python?: ExperimentalLanguageSpecificInstrumentation; + /** Configure Ruby language-specific instrumentation libraries. */ ruby?: ExperimentalLanguageSpecificInstrumentation; + /** Configure Rust language-specific instrumentation libraries. */ rust?: ExperimentalLanguageSpecificInstrumentation; + /** Configure Swift language-specific instrumentation libraries. */ swift?: ExperimentalLanguageSpecificInstrumentation; [k: string]: | ExperimentalLanguageSpecificInstrumentation @@ -610,20 +1244,35 @@ export interface HttpsOpentelemetryIoOtelconfigInstrumentationJson { | undefined; } export interface ExperimentalGeneralInstrumentation { + /** + * Configure instrumentations following the peer semantic conventions. + * See peer semantic conventions: https://opentelemetry.io/docs/specs/semconv/attributes-registry/peer/ + */ peer?: ExperimentalPeerInstrumentation; + /** + * Configure instrumentations following the http semantic conventions. + * See http semantic conventions: https://opentelemetry.io/docs/specs/semconv/http/ + */ http?: ExperimentalHttpInstrumentation; } export interface ExperimentalPeerInstrumentation { + /** + * Configure the service mapping for instrumentations following peer.service semantic conventions. + * Each entry is a key value pair where "peer" defines the IP address and "service" defines the corresponding logical name of the service. + * See peer.service semantic conventions: https://opentelemetry.io/docs/specs/semconv/general/attributes/#general-remote-service-attributes + */ service_mapping?: { peer: string; service: string; }[]; } export interface ExperimentalHttpInstrumentation { + /** Configure instrumentations following the http client semantic conventions. */ client?: { request_captured_headers?: string[]; response_captured_headers?: string[]; }; + /** Configure instrumentations following the http server semantic conventions. */ server?: { request_captured_headers?: string[]; response_captured_headers?: string[]; diff --git a/scripts/config/generate-config.js b/scripts/config/generate-config.js index 9e1667aae66..069e200a6cb 100644 --- a/scripts/config/generate-config.js +++ b/scripts/config/generate-config.js @@ -28,6 +28,8 @@ const { compileFromFile } = require('json-schema-to-typescript'); const fs = require('fs'); const { execSync } = require('child_process'); const path = require('path'); +const yaml = require('yaml'); +const ts = require('typescript'); const SCRIPT_DIR = __dirname; const ROOT_DIR = path.join(SCRIPT_DIR, '..', '..'); @@ -57,6 +59,292 @@ function addLicenseHeader(content) { return licenseHeader + content; } +/** + * Manual mapping table between YAML type names and TypeScript interface/type names + * This handles cases where json-schema-to-typescript generates different names + */ +const TYPE_NAME_MAPPING = { + 'OpenTelemetryConfiguration': 'OpenTelemetryConfiguration', + 'Resource': 'HttpsOpentelemetryIoOtelconfigResourceJson', + 'ResourceDetection': 'ExperimentalResourceDetection', + 'Detector': 'ExperimentalResourceDetector', + 'DetectorAttributes': 'IncludeExclude', + 'AttributeLimits': 'AttributeLimits', + 'Propagator': 'HttpsOpentelemetryIoOtelconfigPropagatorJson', + 'CompositePropagator': 'TextMapPropagator', + 'LoggerProvider': 'HttpsOpentelemetryIoOtelconfigLoggerProviderJson', + 'LogRecordProcessor': 'LogRecordProcessor', + 'BatchLogRecordProcessor': 'BatchLogRecordProcessor', + 'SimpleLogRecordProcessor': 'SimpleLogRecordProcessor', + 'LogRecordExporter': 'LogRecordExporter', + 'LogRecordLimits': 'LogRecordLimits', + 'LoggerConfigurator': 'ExperimentalLoggerConfigurator', + 'LoggerConfigAndMatcher': 'ExperimentalLoggerMatcherAndConfig', + 'LoggerConfig': 'ExperimentalLoggerConfig', + 'TracerProvider': 'HttpsOpentelemetryIoOtelconfigTracerProviderJson', + 'SpanProcessor': 'SpanProcessor', + 'BatchSpanProcessor': 'BatchSpanProcessor', + 'SimpleSpanProcessor': 'SimpleSpanProcessor', + 'SpanExporter': 'SpanExporter', + 'ZipkinSpanExporter': 'ZipkinSpanExporter', + 'SpanLimits': 'SpanLimits', + 'Sampler': 'Sampler', + 'TracerConfigurator': 'ExperimentalTracerConfigurator', + 'TracerConfigAndMatcher': 'ExperimentalTracerMatcherAndConfig', + 'TracerConfig': 'ExperimentalTracerConfig', + 'MeterProvider': 'HttpsOpentelemetryIoOtelconfigMeterProviderJson', + 'MetricReader': 'MetricReader', + 'PullMetricReader': 'PullMetricReader', + 'PeriodicMetricReader': 'PeriodicMetricReader', + 'MetricProducer': 'MetricProducer', + 'CardinalityLimits': 'CardinalityLimits', + 'MetricExporter': ['PushMetricExporter', 'PullMetricExporter'], // Handles both push and pull + 'PrometheusMetricExporter': 'ExperimentalPrometheusMetricExporter', + 'PrometheusIncludeExclude': 'IncludeExclude', + 'View': 'View', + 'Selector': 'ViewSelector', + 'Stream': 'ViewStream', + 'StreamIncludeExclude': 'IncludeExclude', + 'StreamAggregation': 'Aggregation', + 'StreamAggregationExplicitBucketHistogram': 'ExplicitBucketHistogramAggregation', + 'MeterConfigurator': 'ExperimentalMeterConfigurator', + 'MeterConfigAndMatcher': 'ExperimentalMeterMatcherAndConfig', + 'MeterConfig': 'ExperimentalMeterConfig', + 'OtlpExporterCommon': ['OtlpHttpExporter', 'OtlpGrpcExporter', 'OtlpHttpMetricExporter', 'OtlpGrpcMetricExporter'], + 'OtlpHttpExporter': ['OtlpHttpExporter', 'OtlpHttpSpanExporter', 'OtlpHttpLogRecordExporter'], + 'OtlpHttpSpanExporter': 'OtlpHttpExporter', + 'OtlpHttpMetricExporter': 'OtlpHttpMetricExporter', + 'OtlpHttpLogRecordExporter': 'OtlpHttpExporter', + 'OtlpGrpcExporter': 'OtlpGrpcExporter', + 'OtlpFileExporter': ['ExperimentalOtlpFileExporter', 'ExperimentalOtlpFileMetricExporter'], + 'Instrumentation': 'HttpsOpentelemetryIoOtelconfigInstrumentationJson', + 'GeneralInstrumentation': 'ExperimentalGeneralInstrumentation', + 'GeneralInstrumentationPeer': 'ExperimentalPeerInstrumentation', + 'GeneralInstrumentationHttp': 'ExperimentalHttpInstrumentation', + 'GeneralInstrumentationHttpClient': 'ExperimentalHttpInstrumentation', // client property + 'GeneralInstrumentationHttpServer': 'ExperimentalHttpInstrumentation', // server property + 'LanguageSpecificInstrumentation': 'ExperimentalLanguageSpecificInstrumentation', +}; + +/** + * Load type descriptions from YAML file + */ +function loadTypeDescriptions() { + const yamlPath = path.join(SCRIPT_DIR, 'opentelemetry-configuration/schema/type_descriptions.yaml'); + const yamlContent = fs.readFileSync(yamlPath, 'utf8'); + const parsed = yaml.parse(yamlContent); + + // Build a map from type name to property descriptions + const typeDescriptions = new Map(); + + for (const entry of parsed) { + if (entry.type && entry.property_descriptions) { + typeDescriptions.set(entry.type, entry.property_descriptions); + } + } + + return typeDescriptions; +} + +/** + * Create JSDoc comment from description text + */ +function createJSDocComment(description, indent = 0) { + const indentStr = ' '.repeat(indent); + const cleanDesc = description.replace(/\n\s*\n/g, '\n\n').trim(); + const lines = cleanDesc.split('\n'); + + if (lines.length === 1) { + return `${indentStr}/** ${lines[0]} */\n`; + } + + let comment = `${indentStr}/**\n`; + for (const line of lines) { + comment += `${indentStr} * ${line}\n`; + } + comment += `${indentStr} */\n`; + + return comment; +} + +/** + * Add descriptions to generated TypeScript file + */ +function addDescriptionsToTypes(content) { + const typeDescriptions = loadTypeDescriptions(); + const sourceFile = ts.createSourceFile( + 'temp.ts', + content, + ts.ScriptTarget.Latest, + true + ); + + const modifications = []; + + function visitNode(node) { + if (ts.isInterfaceDeclaration(node) && node.name) { + const interfaceName = node.name.text; + const yamlTypes = findYamlTypesForInterface(interfaceName); + + for (const yamlType of yamlTypes) { + const descriptions = typeDescriptions.get(yamlType); + if (descriptions) { + // Add descriptions for each property + for (const member of node.members) { + if (ts.isPropertySignature(member) && member.name) { + const propertyName = getPropertyName(member.name); + const description = descriptions[propertyName]; + + if (description && !hasExistingJSDoc(member, content)) { + const indent = getIndentation(member, content); + const jsDoc = createJSDocComment(description, indent); + modifications.push({ + pos: member.pos, + jsDoc: jsDoc + }); + } + } + } + break; // Found matching type, stop searching + } + } + } + + if (ts.isTypeAliasDeclaration(node) && node.name) { + const typeName = node.name.text; + const yamlTypes = findYamlTypesForInterface(typeName); + + // For type aliases that are object types, we need to extract properties + if (node.type && ts.isTypeLiteralNode(node.type)) { + for (const yamlType of yamlTypes) { + const descriptions = typeDescriptions.get(yamlType); + if (descriptions) { + for (const member of node.type.members) { + if (ts.isPropertySignature(member) && member.name) { + const propertyName = getPropertyName(member.name); + const description = descriptions[propertyName]; + + if (description && !hasExistingJSDoc(member, content)) { + const indent = getIndentation(member, content); + const jsDoc = createJSDocComment(description, indent); + modifications.push({ + pos: member.pos, + jsDoc: jsDoc + }); + } + } + } + break; + } + } + } + + if (node.type && ts.isIntersectionTypeNode(node.type)) { + for (const typeNode of node.type.types) { + if (ts.isTypeLiteralNode(typeNode)) { + for (const yamlType of yamlTypes) { + const descriptions = typeDescriptions.get(yamlType); + if (descriptions) { + for (const member of typeNode.members) { + if (ts.isPropertySignature(member) && member.name) { + const propertyName = getPropertyName(member.name); + const description = descriptions[propertyName]; + + if (description && !hasExistingJSDoc(member, content)) { + const indent = getIndentation(member, content); + const jsDoc = createJSDocComment(description, indent); + modifications.push({ + pos: member.pos, + jsDoc: jsDoc + }); + } + } + } + break; + } + } + } + } + } + } + + ts.forEachChild(node, visitNode); + } + + visitNode(sourceFile); + + // Apply modifications in reverse order (from end to start) to maintain positions + modifications.sort((a, b) => b.pos - a.pos); + + let modifiedContent = content; + for (const mod of modifications) { + // Insert JSDoc, but remove the first newline from the content after insertion point + // to avoid double spacing (JSDoc ends with \n, and property has leading \n) + const afterContent = modifiedContent.slice(mod.pos); + const trimmedAfter = afterContent.replace(/^\n/, ''); + modifiedContent = modifiedContent.slice(0, mod.pos) + '\n' + mod.jsDoc + trimmedAfter; + } + + return modifiedContent; +} + +/** + * Find YAML type names that correspond to a TypeScript interface name + */ +function findYamlTypesForInterface(interfaceName) { + const matches = []; + + for (const [yamlType, tsNames] of Object.entries(TYPE_NAME_MAPPING)) { + if (Array.isArray(tsNames)) { + if (tsNames.includes(interfaceName)) { + matches.push(yamlType); + } + } else if (tsNames === interfaceName) { + matches.push(yamlType); + } + } + + return matches; +} + +/** + * Get property name from PropertyName node + */ +function getPropertyName(name) { + if (ts.isIdentifier(name)) { + return name.text; + } else if (ts.isStringLiteral(name)) { + return name.text; + } + return ''; +} + +/** + * Check if a node already has JSDoc comments + */ +function hasExistingJSDoc(node, sourceText) { + const nodeStart = node.getStart(); + const textBefore = sourceText.slice(Math.max(0, node.pos), nodeStart); + return textBefore.includes('/**') || textBefore.includes('@minItems'); +} + +/** + * Get the indentation level for a node + */ +function getIndentation(node, sourceText) { + const nodeStart = node.getStart(); + const textBefore = sourceText.slice(0, nodeStart); + const lastNewline = textBefore.lastIndexOf('\n'); + + if (lastNewline === -1) { + return 0; + } + + const lineStart = lastNewline + 1; + const indent = nodeStart - lineStart; + return indent; +} + const options = { cwd: `${ROOT_DIR}/scripts/config/opentelemetry-configuration/schema`, strictIndexSignatures: true, // adds undefined @@ -69,15 +357,20 @@ compileFromFile(`${ROOT_DIR}/scripts/config/opentelemetry-configuration/schema/o .then(ts => { fs.writeFileSync(outputPath, ts); - // Post-process step to fix the HttpsOpentelemetryIoOtelconfigInstrumentationJson type - // See notes below for details on why this is needed + // Add JSDoc descriptions from type_descriptions.yaml let content = fs.readFileSync(outputPath, 'utf8'); + content = addDescriptionsToTypes(content); + fs.writeFileSync(outputPath, content); + + // Fix the HttpsOpentelemetryIoOtelconfigInstrumentationJson type + // See notes below for details on why this is needed + content = fs.readFileSync(outputPath, 'utf8'); // Find and replace the index signature in HttpsOpentelemetryIoOtelconfigInstrumentationJson // Pattern matches the interface and its index signature line const pattern = /(export interface HttpsOpentelemetryIoOtelconfigInstrumentationJson\s*\{[\s\S]*?)(\s+\[k: string\]: ExperimentalLanguageSpecificInstrumentation;)/; - content = content.replace(pattern, (match, interfaceStart, indexSignature) => { + content = content.replace(pattern, (_match, interfaceStart, _indexSignature) => { // Replace the index signature with the corrected multi-type version const replacement = ` [k: string]:\n | ExperimentalLanguageSpecificInstrumentation\n | ExperimentalGeneralInstrumentation\n | undefined;`; return interfaceStart + replacement; diff --git a/scripts/config/generate-config.sh b/scripts/config/generate-config.sh index a9355ccfe15..bbb2e515c14 100755 --- a/scripts/config/generate-config.sh +++ b/scripts/config/generate-config.sh @@ -21,7 +21,7 @@ cd opentelemetry-configuration git init # git remote add origin https://github.com/open-telemetry/opentelemetry-configuration.git -# this branch has the fix that removes patternProperties +# TEMP: this branch has the fix that removes patternProperties from the schema git remote add origin https://github.com/dol/opentelemetry-configuration git fetch origin fix/wildcard-pattern git checkout fix/wildcard-pattern From c875080851955587dce51a5091804e1c0c9a73d3 Mon Sep 17 00:00:00 2001 From: JamieDanielson Date: Wed, 29 Oct 2025 17:08:23 -0400 Subject: [PATCH 3/7] use spawnsync for better security --- scripts/config/generate-config.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/config/generate-config.js b/scripts/config/generate-config.js index 069e200a6cb..ff500332178 100644 --- a/scripts/config/generate-config.js +++ b/scripts/config/generate-config.js @@ -26,7 +26,7 @@ const { compileFromFile } = require('json-schema-to-typescript'); const fs = require('fs'); -const { execSync } = require('child_process'); +const { execSync, spawnSync } = require('child_process'); const path = require('path'); const yaml = require('yaml'); const ts = require('typescript'); @@ -385,10 +385,19 @@ compileFromFile(`${ROOT_DIR}/scripts/config/opentelemetry-configuration/schema/o fs.writeFileSync(outputPath, content); // format opentelemetry-configuration generated types - execSync(`npx prettier --write ${outputPath}`, { stdio: 'inherit' }); + const prettierResult = spawnSync('npx', ['prettier', '--write', outputPath], { stdio: 'inherit' }); + if (prettierResult.error) { + throw prettierResult.error; + } // compile opentelemetry-configuration package - execSync(`npm run compile`, { stdio: 'inherit', cwd: `${ROOT_DIR}/experimental/packages/opentelemetry-configuration` }); + const compileResult = spawnSync('npm', ['run', 'compile'], { + stdio: 'inherit', + cwd: `${ROOT_DIR}/experimental/packages/opentelemetry-configuration` + }); + if (compileResult.error) { + throw compileResult.error; + } }); /* notes From 993a59656ca4b7dc4c0c76b18152de31ed521401 Mon Sep 17 00:00:00 2001 From: JamieDanielson Date: Wed, 29 Oct 2025 17:27:34 -0400 Subject: [PATCH 4/7] incorporate pr feedback --- scripts/config/generate-config.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/scripts/config/generate-config.js b/scripts/config/generate-config.js index ff500332178..64ba261bf63 100644 --- a/scripts/config/generate-config.js +++ b/scripts/config/generate-config.js @@ -26,7 +26,7 @@ const { compileFromFile } = require('json-schema-to-typescript'); const fs = require('fs'); -const { execSync, spawnSync } = require('child_process'); +const { spawnSync } = require('child_process'); const path = require('path'); const yaml = require('yaml'); const ts = require('typescript'); @@ -35,8 +35,13 @@ const SCRIPT_DIR = __dirname; const ROOT_DIR = path.join(SCRIPT_DIR, '..', '..'); // Run the bash script to get the latest version of the schema -const scriptPath = path.join(SCRIPT_DIR, 'generate-config.sh'); -execSync(`bash "${scriptPath}"`, { stdio: 'inherit', cwd: SCRIPT_DIR }); +const bashResult = spawnSync('bash', ['generate-config.sh'], { + stdio: 'inherit', + cwd: SCRIPT_DIR +}); +if (bashResult.error) { + throw bashResult.error; +} function addLicenseHeader(content) { const licenseHeader = `/* @@ -355,23 +360,15 @@ const options = { const outputPath = `${ROOT_DIR}/experimental/packages/opentelemetry-configuration/src/generated/opentelemetry-configuration.ts`; compileFromFile(`${ROOT_DIR}/scripts/config/opentelemetry-configuration/schema/opentelemetry_configuration.json`, options) .then(ts => { - fs.writeFileSync(outputPath, ts); + let content = ts; // Add JSDoc descriptions from type_descriptions.yaml - let content = fs.readFileSync(outputPath, 'utf8'); content = addDescriptionsToTypes(content); - fs.writeFileSync(outputPath, content); // Fix the HttpsOpentelemetryIoOtelconfigInstrumentationJson type // See notes below for details on why this is needed - content = fs.readFileSync(outputPath, 'utf8'); - - // Find and replace the index signature in HttpsOpentelemetryIoOtelconfigInstrumentationJson - // Pattern matches the interface and its index signature line const pattern = /(export interface HttpsOpentelemetryIoOtelconfigInstrumentationJson\s*\{[\s\S]*?)(\s+\[k: string\]: ExperimentalLanguageSpecificInstrumentation;)/; - content = content.replace(pattern, (_match, interfaceStart, _indexSignature) => { - // Replace the index signature with the corrected multi-type version const replacement = ` [k: string]:\n | ExperimentalLanguageSpecificInstrumentation\n | ExperimentalGeneralInstrumentation\n | undefined;`; return interfaceStart + replacement; }); @@ -381,7 +378,6 @@ compileFromFile(`${ROOT_DIR}/scripts/config/opentelemetry-configuration/schema/o content = addLicenseHeader(content); } - // Write back the processed content fs.writeFileSync(outputPath, content); // format opentelemetry-configuration generated types From 3acc00bf14121ec04220f866fd99b832eec29167 Mon Sep 17 00:00:00 2001 From: JamieDanielson Date: Mon, 3 Nov 2025 17:37:17 -0500 Subject: [PATCH 5/7] use main branch instead of fork --- scripts/config/generate-config.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/config/generate-config.sh b/scripts/config/generate-config.sh index bbb2e515c14..3b5f0a6cb6f 100755 --- a/scripts/config/generate-config.sh +++ b/scripts/config/generate-config.sh @@ -20,11 +20,11 @@ mkdir opentelemetry-configuration cd opentelemetry-configuration git init -# git remote add origin https://github.com/open-telemetry/opentelemetry-configuration.git -# TEMP: this branch has the fix that removes patternProperties from the schema -git remote add origin https://github.com/dol/opentelemetry-configuration -git fetch origin fix/wildcard-pattern -git checkout fix/wildcard-pattern +git remote add origin https://github.com/open-telemetry/opentelemetry-configuration.git # git fetch origin "${CONFIG_VERSION}" --depth=1 +# TEMP: main branch has the fix that removes patternProperties from the schema +# Replace once a new tag is released +git fetch origin main +git checkout main git reset --hard FETCH_HEAD cd ${SCRIPT_DIR} From 0a3ee6c18b078847628e854deaeae2e206a5f0b6 Mon Sep 17 00:00:00 2001 From: JamieDanielson Date: Mon, 3 Nov 2025 17:39:22 -0500 Subject: [PATCH 6/7] update to use new file, remove redundancy * types are in a new file upstream. * still looking at how to reduce redundancy in intersection types generated by json2ts, for now fix in post-processing step. * temp todo for incorrect casing on otel type. --- .../generated/opentelemetry-configuration.ts | 513 +++++++----------- scripts/config/generate-config.js | 186 +++++-- 2 files changed, 324 insertions(+), 375 deletions(-) diff --git a/experimental/packages/opentelemetry-configuration/src/generated/opentelemetry-configuration.ts b/experimental/packages/opentelemetry-configuration/src/generated/opentelemetry-configuration.ts index 4fe6c62f83e..9a64d0ee133 100644 --- a/experimental/packages/opentelemetry-configuration/src/generated/opentelemetry-configuration.ts +++ b/experimental/packages/opentelemetry-configuration/src/generated/opentelemetry-configuration.ts @@ -21,6 +21,10 @@ */ export type OtlpHttpExporter = { + /** + * 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?: string | null; /** Configure TLS settings for the exporter. */ tls?: HttpTls; @@ -47,86 +51,38 @@ export type OtlpHttpExporter = { * If omitted or null, 10000 is used. */ timeout?: number | null; + /** + * Configure the encoding used for messages. + * Values include: protobuf, json. Implementations may not support json. + * If omitted or null, protobuf is used. + */ encoding?: ('protobuf' | 'json') | null; -} & ({ - endpoint?: string | null; - tls?: HttpTls; - headers?: NameStringValuePair[]; - headers_list?: string | null; - compression?: string | null; - timeout?: number | null; - encoding?: ('protobuf' | 'json') | null; -} | null) & { - endpoint?: string | null; - /** Configure TLS settings for the exporter. */ - tls?: HttpTls; - /** - * Configure headers. Entries have higher priority than entries from .headers_list. - * If an entry's .value is null, the entry is ignored. - */ - headers?: NameStringValuePair[]; - /** - * 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?: string | null; - /** - * Configure compression. - * Values include: gzip, none. Implementations may support other compression algorithms. - * If omitted or null, none is used. - */ - compression?: string | null; - /** - * 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?: number | null; - encoding?: ('protobuf' | 'json') | null; - } & ({ - endpoint?: string | null; - tls?: HttpTls; - headers?: NameStringValuePair[]; - headers_list?: string | null; - compression?: string | null; - timeout?: number | null; - encoding?: ('protobuf' | 'json') | null; - } | null); +}; export type HttpTls = { + /** + * 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?: string | null; + /** + * 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?: string | null; + /** + * 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?: string | null; -} & ({ - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; -} | null) & { - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; - } & ({ - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; - } | null) & { - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; - } & ({ - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; - } | null) & { - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; - } & ({ - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; - } | null); +}; export type OtlpGrpcExporter = { + /** + * Configure endpoint. + * If omitted or null, http://localhost:4317 is used. + */ endpoint?: string | null; /** Configure TLS settings for the exporter. */ tls?: GrpcTls; @@ -153,89 +109,33 @@ export type OtlpGrpcExporter = { * If omitted or null, 10000 is used. */ timeout?: number | null; -} & ({ - endpoint?: string | null; - tls?: GrpcTls; - headers?: NameStringValuePair[]; - headers_list?: string | null; - compression?: string | null; - timeout?: number | null; -} | null) & { - endpoint?: string | null; - /** Configure TLS settings for the exporter. */ - tls?: GrpcTls; - /** - * Configure headers. Entries have higher priority than entries from .headers_list. - * If an entry's .value is null, the entry is ignored. - */ - headers?: NameStringValuePair[]; - /** - * 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?: string | null; - /** - * Configure compression. - * Values include: gzip, none. Implementations may support other compression algorithms. - * If omitted or null, none is used. - */ - compression?: string | null; - /** - * 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?: number | null; - } & ({ - endpoint?: string | null; - tls?: GrpcTls; - headers?: NameStringValuePair[]; - headers_list?: string | null; - compression?: string | null; - timeout?: number | null; - } | null); +}; export type GrpcTls = { + /** + * 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?: string | null; + /** + * 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?: string | null; + /** + * 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?: string | null; + /** + * 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?: boolean | null; -} & ({ - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; - insecure?: boolean | null; -} | null) & { - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; - insecure?: boolean | null; - } & ({ - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; - insecure?: boolean | null; - } | null) & { - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; - insecure?: boolean | null; - } & ({ - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; - insecure?: boolean | null; - } | null) & { - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; - insecure?: boolean | null; - } & ({ - certificate_file?: string | null; - client_key_file?: string | null; - client_certificate_file?: string | null; - insecure?: boolean | null; - } | null); +}; export type ExperimentalOtlpFileExporter = { /** * Configure output stream. @@ -243,20 +143,13 @@ export type ExperimentalOtlpFileExporter = { * If omitted or null, stdout is used. */ output_stream?: string | null; -} & ({ - output_stream?: string | null; -} | null) & { - /** - * 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?: string | null; - } & ({ - output_stream?: string | null; - } | null); +}; export type ConsoleExporter = {} | null; export type OtlpHttpMetricExporter = { + /** + * Configure endpoint. + * If omitted or null, http://localhost:4317 is used. + */ endpoint?: string | null; /** Configure TLS settings for the exporter. */ tls?: HttpTls; @@ -283,6 +176,11 @@ export type OtlpHttpMetricExporter = { * If omitted or null, 10000 is used. */ timeout?: number | null; + /** + * Configure the encoding used for messages. + * Values include: protobuf, json. Implementations may not support json. + * If omitted or null, protobuf is used. + */ encoding?: ('protobuf' | 'json') | null; /** * Configure temporality preference. @@ -298,20 +196,12 @@ export type OtlpHttpMetricExporter = { default_histogram_aggregation?: | ('explicit_bucket_histogram' | 'base2_exponential_bucket_histogram') | null; -} & ({ - endpoint?: string | null; - tls?: HttpTls; - headers?: NameStringValuePair[]; - headers_list?: string | null; - compression?: string | null; - timeout?: number | null; - encoding?: ('protobuf' | 'json') | null; - temporality_preference?: ('cumulative' | 'delta' | 'low_memory') | null; - default_histogram_aggregation?: - | ('explicit_bucket_histogram' | 'base2_exponential_bucket_histogram') - | null; -} | null); +}; export type OtlpGrpcMetricExporter = { + /** + * Configure endpoint. + * If omitted or null, http://localhost:4317 is used. + */ endpoint?: string | null; /** Configure TLS settings for the exporter. */ tls?: GrpcTls; @@ -352,18 +242,7 @@ export type OtlpGrpcMetricExporter = { default_histogram_aggregation?: | ('explicit_bucket_histogram' | 'base2_exponential_bucket_histogram') | null; -} & ({ - endpoint?: string | null; - tls?: GrpcTls; - headers?: NameStringValuePair[]; - headers_list?: string | null; - compression?: string | null; - timeout?: number | null; - temporality_preference?: ('cumulative' | 'delta' | 'low_memory') | null; - default_histogram_aggregation?: - | ('explicit_bucket_histogram' | 'base2_exponential_bucket_histogram') - | null; -} | null); +}; export type ExperimentalOtlpFileMetricExporter = { /** * Configure output stream. @@ -371,17 +250,37 @@ export type ExperimentalOtlpFileMetricExporter = { * If omitted or null, stdout is used. */ output_stream?: string | null; + /** + * 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' | 'delta' | 'low_memory') | null; + /** + * 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' | 'base2_exponential_bucket_histogram') | null; -} & ({ - output_stream?: string | null; +}; +export type ConsoleMetricExporter = { + /** + * 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' | 'delta' | 'low_memory') | null; + /** + * 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' | 'base2_exponential_bucket_histogram') | null; -} | null); +}; export type OpenCensusMetricProducer = {} | null; export type ExperimentalPrometheusMetricExporter = { /** @@ -399,7 +298,7 @@ export type ExperimentalPrometheusMetricExporter = { * If omitted or null, false is used. */ without_scope_info?: boolean | null; - /** Configure Prometheus Exporter to add resource attributes as metrics attributes. */ + /** Configure Prometheus Exporter to add resource attributes as metrics attributes, where the resource attribute keys match the patterns. */ with_resource_constant_labels?: IncludeExclude; /** * Configure how Prometheus metrics are exposed. Values include: @@ -419,20 +318,7 @@ export type ExperimentalPrometheusMetricExporter = { | 'NoTranslation' ) | null; -} & ({ - host?: string | null; - port?: number | null; - without_scope_info?: boolean | null; - with_resource_constant_labels?: IncludeExclude; - translation_strategy?: - | ( - | 'UnderscoreEscapingWithSuffixes' - | 'UnderscoreEscapingWithoutSuffixes' - | 'NoUTF8EscapingWithSuffixes' - | 'NoTranslation' - ) - | null; -} | null); +}; export type DefaultAggregation = {} | null; export type DropAggregation = {} | null; export type ExplicitBucketHistogramAggregation = { @@ -446,19 +332,15 @@ export type ExplicitBucketHistogramAggregation = { * If omitted or null, true is used. */ record_min_max?: boolean | null; -} & ({ - boundaries?: number[]; - record_min_max?: boolean | null; -} | null); +}; export type Base2ExponentialBucketHistogramAggregation = { + /** TODO */ max_scale?: number | null; + /** TODO */ max_size?: number | null; + /** TODO */ record_min_max?: boolean | null; -} & ({ - max_scale?: number | null; - max_size?: number | null; - record_min_max?: boolean | null; -} | null); +}; export type LastValueAggregation = {} | null; export type SumAggregation = {} | null; export type TraceContextPropagator = {} | null; @@ -479,45 +361,64 @@ export type ZipkinSpanExporter = { * If omitted or null, 10000 is used. */ timeout?: number | null; -} & ({ - endpoint?: string | null; - timeout?: number | null; -} | null); +}; export type AlwaysOffSampler = {} | null; export type AlwaysOnSampler = {} | null; export type JaegerRemoteSampler = { + /** TODO */ endpoint?: string | null; + /** TODO */ interval?: number | null; + /** TODO */ initial_sampler?: Sampler; -} & ({ - endpoint?: string | null; - interval?: number | null; - initial_sampler?: Sampler; -} | null); +}; export type ParentBasedSampler = { + /** + * Configure root sampler. + * If omitted or null, always_on is used. + */ root?: Sampler; + /** + * Configure remote_parent_sampled sampler. + * If omitted or null, always_on is used. + */ remote_parent_sampled?: Sampler; + /** + * Configure remote_parent_not_sampled sampler. + * If omitted or null, always_off is used. + */ remote_parent_not_sampled?: Sampler; + /** + * Configure local_parent_sampled sampler. + * If omitted or null, always_on is used. + */ local_parent_sampled?: Sampler; + /** + * Configure local_parent_not_sampled sampler. + * If omitted or null, always_off is used. + */ local_parent_not_sampled?: Sampler; -} & ({ - root?: Sampler; - remote_parent_sampled?: Sampler; - remote_parent_not_sampled?: Sampler; - local_parent_sampled?: Sampler; - local_parent_not_sampled?: Sampler; -} | null); -export type TraceIdRatioBasedSampler = { +}; +export type ExperimentalProbabilitySampler = { + /** + * Configure ratio. + * If omitted or null, 1.0 is used. + */ ratio?: number | null; -} & ({ +}; +export type TraceIdRatioBasedSampler = { + /** + * Configure trace_id_ratio. + * If omitted or null, 1.0 is used. + */ ratio?: number | null; -} | null); +}; export type ExperimentalContainerResourceDetector = {} | null; export type ExperimentalHostResourceDetector = {} | null; export type ExperimentalProcessResourceDetector = {} | null; export type ExperimentalServiceResourceDetector = {} | null; -export interface OpenTelemetryConfiguration { +export interface OpentelemetryConfiguration { /** * The file format version. * The yaml format is documented at @@ -561,10 +462,7 @@ export interface OpenTelemetryConfiguration { * If omitted, the default resource is used. */ resource?: HttpsOpentelemetryIoOtelconfigResourceJson; - /** - * Configure instrumentation. - * This type is in development and subject to breaking changes in minor versions. - */ + /** Configure instrumentation. */ 'instrumentation/development'?: HttpsOpentelemetryIoOtelconfigInstrumentationJson; [k: string]: any | undefined; } @@ -590,10 +488,7 @@ export interface HttpsOpentelemetryIoOtelconfigLoggerProviderJson { processors: [LogRecordProcessor, ...LogRecordProcessor[]]; /** Configure log record limits. See also attribute_limits. */ limits?: LogRecordLimits; - /** - * Configure loggers. - * This type is in development and subject to breaking changes in minor versions. - */ + /** Configure loggers. */ 'logger_configurator/development'?: ExperimentalLoggerConfigurator; } export interface LogRecordProcessor { @@ -638,10 +533,7 @@ export interface LogRecordExporter { otlp_http?: OtlpHttpExporter; /** Configure exporter to be OTLP with gRPC transport. */ otlp_grpc?: OtlpGrpcExporter; - /** - * Configure exporter to be OTLP with file transport. - * This type is in development and subject to breaking changes in minor versions. - */ + /** Configure exporter to be OTLP with file transport. */ 'otlp_file/development'?: ExperimentalOtlpFileExporter; /** Configure exporter to be console. */ console?: ConsoleExporter; @@ -652,7 +544,9 @@ export interface LogRecordExporter { | undefined; } export interface NameStringValuePair { + /** The name of the pair. */ name: string; + /** The value of the pair. */ value: string | null; } export interface SimpleLogRecordProcessor { @@ -710,10 +604,7 @@ export interface HttpsOpentelemetryIoOtelconfigMeterProviderJson { * If omitted or null, trace_based is used. */ exemplar_filter?: ('always_on' | 'always_off' | 'trace_based') | null; - /** - * Configure meters. - * This type is in development and subject to breaking changes in minor versions. - */ + /** Configure meters. */ 'meter_configurator/development'?: ExperimentalMeterConfigurator; } export interface MetricReader { @@ -747,13 +638,10 @@ export interface PushMetricExporter { otlp_http?: OtlpHttpMetricExporter; /** Configure exporter to be OTLP with gRPC transport. */ otlp_grpc?: OtlpGrpcMetricExporter; - /** - * Configure exporter to be OTLP with file transport. - * This type is in development and subject to breaking changes in minor versions. - */ + /** Configure exporter to be OTLP with file transport. */ 'otlp_file/development'?: ExperimentalOtlpFileMetricExporter; /** Configure exporter to be console. */ - console?: ConsoleExporter; + console?: ConsoleMetricExporter; [k: string]: | ({ [k: string]: any | undefined; @@ -821,10 +709,7 @@ export interface PullMetricReader { cardinality_limits?: CardinalityLimits; } export interface PullMetricExporter { - /** - * Configure exporter to be prometheus. - * This type is in development and subject to breaking changes in minor versions. - */ + /** Configure exporter to be prometheus. */ 'prometheus/development'?: ExperimentalPrometheusMetricExporter; [k: string]: | ({ @@ -834,18 +719,18 @@ export interface PullMetricExporter { } export interface IncludeExclude { /** - * Configure list of attribute key patterns to include from resource detectors. - * Attribute keys from resource detectors are evaluated to match as follows: - * * If the value of the attribute key exactly matches. - * * If the value of the attribute key matches the wildcard pattern, where '?' matches any single character and '*' matches any number of characters including none. - * If omitted, all attributes are included. + * 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?: string[]; /** - * Configure list of attribute key patterns to exclude from resource detectors. Applies after .resource.detectors.attributes.included (i.e. excluded has higher priority than included). - * Attribute keys from resource detectors are evaluated to match as follows: - * * If the value of the attribute key exactly matches. - * * If the value of the attribute key matches the wildcard pattern, where '?' matches any single character and '*' matches any number of characters including none. + * 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?: string[]; @@ -928,12 +813,17 @@ export interface ViewStream { attribute_keys?: IncludeExclude; } export interface Aggregation { + /** TODO */ default?: DefaultAggregation; + /** TODO */ drop?: DropAggregation; /** Configure aggregation to be explicit_bucket_histogram. */ explicit_bucket_histogram?: ExplicitBucketHistogramAggregation; + /** TODO */ base2_exponential_bucket_histogram?: Base2ExponentialBucketHistogramAggregation; + /** TODO */ last_value?: LastValueAggregation; + /** TODO */ sum?: SumAggregation; } export interface ExperimentalMeterConfigurator { @@ -1004,10 +894,7 @@ export interface HttpsOpentelemetryIoOtelconfigTracerProviderJson { * If omitted, parent based sampler with a root of always_on is used. */ sampler?: Sampler; - /** - * Configure tracers. - * This type is in development and subject to breaking changes in minor versions. - */ + /** Configure tracers. */ 'tracer_configurator/development'?: ExperimentalTracerConfigurator; } export interface SpanProcessor { @@ -1052,10 +939,7 @@ export interface SpanExporter { otlp_http?: OtlpHttpExporter; /** Configure exporter to be OTLP with gRPC transport. */ otlp_grpc?: OtlpGrpcExporter; - /** - * Configure exporter to be OTLP with file transport. - * This type is in development and subject to breaking changes in minor versions. - */ + /** Configure exporter to be OTLP with file transport. */ 'otlp_file/development'?: ExperimentalOtlpFileExporter; /** Configure exporter to be console. */ console?: ConsoleExporter; @@ -1114,9 +998,12 @@ export interface Sampler { always_off?: AlwaysOffSampler; /** Configure sampler to be always_on. */ always_on?: AlwaysOnSampler; + /** TODO */ jaeger_remote?: JaegerRemoteSampler; /** Configure sampler to be parent_based. */ parent_based?: ParentBasedSampler; + /** Configure sampler to be probability. */ + 'probability/development'?: ExperimentalProbabilitySampler; /** Configure sampler to be trace_id_ratio_based. */ trace_id_ratio_based?: TraceIdRatioBasedSampler; [k: string]: @@ -1147,15 +1034,10 @@ export interface ExperimentalTracerMatcherAndConfig { config?: ExperimentalTracerConfig; } export interface HttpsOpentelemetryIoOtelconfigResourceJson { - /** - * Configure resource attributes. Entries have higher priority than entries from .resource.attributes_list. - * Entries must contain .name and .value, and may optionally include .type. If an entry's .type omitted or null, string is used. - * The .value's type must match the .type. Values for .type include: string, bool, int, double, string_array, bool_array, int_array, double_array. - */ + /** Configure resource attributes. Entries have higher priority than entries from .resource.attributes_list. */ attributes?: AttributeNameValue[]; /** * Configure resource detection. - * This type is in development and subject to breaking changes in minor versions. * If omitted or null, resource detection is disabled. */ 'detection/development'?: ExperimentalResourceDetection; @@ -1172,8 +1054,18 @@ export interface HttpsOpentelemetryIoOtelconfigResourceJson { attributes_list?: string | null; } export interface AttributeNameValue { + /** The attribute name. */ name: string; + /** + * The attribute value. + * The type of value must match .type. + */ value: string | number | boolean | null | string[] | boolean[] | number[]; + /** + * 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?: | null | 'string' @@ -1211,37 +1103,18 @@ export interface ExperimentalResourceDetector { | undefined; } export interface HttpsOpentelemetryIoOtelconfigInstrumentationJson { - /** - * 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?: ExperimentalGeneralInstrumentation; - /** Configure C++ language-specific instrumentation libraries. */ cpp?: ExperimentalLanguageSpecificInstrumentation; - /** Configure .NET language-specific instrumentation libraries. */ dotnet?: ExperimentalLanguageSpecificInstrumentation; - /** Configure Erlang language-specific instrumentation libraries. */ erlang?: ExperimentalLanguageSpecificInstrumentation; - /** Configure Go language-specific instrumentation libraries. */ go?: ExperimentalLanguageSpecificInstrumentation; - /** Configure Java language-specific instrumentation libraries. */ java?: ExperimentalLanguageSpecificInstrumentation; - /** Configure JavaScript language-specific instrumentation libraries. */ js?: ExperimentalLanguageSpecificInstrumentation; - /** Configure PHP language-specific instrumentation libraries. */ php?: ExperimentalLanguageSpecificInstrumentation; - /** Configure Python language-specific instrumentation libraries. */ python?: ExperimentalLanguageSpecificInstrumentation; - /** Configure Ruby language-specific instrumentation libraries. */ ruby?: ExperimentalLanguageSpecificInstrumentation; - /** Configure Rust language-specific instrumentation libraries. */ rust?: ExperimentalLanguageSpecificInstrumentation; - /** Configure Swift language-specific instrumentation libraries. */ swift?: ExperimentalLanguageSpecificInstrumentation; - [k: string]: - | ExperimentalLanguageSpecificInstrumentation - | ExperimentalGeneralInstrumentation - | undefined; } export interface ExperimentalGeneralInstrumentation { /** @@ -1258,25 +1131,33 @@ export interface ExperimentalGeneralInstrumentation { export interface ExperimentalPeerInstrumentation { /** * Configure the service mapping for instrumentations following peer.service semantic conventions. - * Each entry is a key value pair where "peer" defines the IP address and "service" defines the corresponding logical name of the service. * See peer.service semantic conventions: https://opentelemetry.io/docs/specs/semconv/general/attributes/#general-remote-service-attributes */ - service_mapping?: { - peer: string; - service: string; - }[]; + service_mapping?: ExperimentalPeerServiceMapping[]; +} +export interface ExperimentalPeerServiceMapping { + /** The IP address to map. */ + peer: string; + /** The logical name corresponding to the IP address of .peer. */ + service: string; } export interface ExperimentalHttpInstrumentation { /** Configure instrumentations following the http client semantic conventions. */ - client?: { - request_captured_headers?: string[]; - response_captured_headers?: string[]; - }; + client?: ExperimentalHttpClientInstrumentation; /** Configure instrumentations following the http server semantic conventions. */ - server?: { - request_captured_headers?: string[]; - response_captured_headers?: string[]; - }; + server?: ExperimentalHttpServerInstrumentation; +} +export interface ExperimentalHttpClientInstrumentation { + /** Configure headers to capture for outbound http requests. */ + request_captured_headers?: string[]; + /** Configure headers to capture for inbound http responses. */ + response_captured_headers?: string[]; +} +export interface ExperimentalHttpServerInstrumentation { + /** Configure headers to capture for inbound http requests. */ + request_captured_headers?: string[]; + /** Configure headers to capture for outbound http responses. */ + response_captured_headers?: string[]; } export interface ExperimentalLanguageSpecificInstrumentation { [k: string]: diff --git a/scripts/config/generate-config.js b/scripts/config/generate-config.js index 64ba261bf63..1df146cda3c 100644 --- a/scripts/config/generate-config.js +++ b/scripts/config/generate-config.js @@ -69,73 +69,19 @@ function addLicenseHeader(content) { * This handles cases where json-schema-to-typescript generates different names */ const TYPE_NAME_MAPPING = { - 'OpenTelemetryConfiguration': 'OpenTelemetryConfiguration', 'Resource': 'HttpsOpentelemetryIoOtelconfigResourceJson', - 'ResourceDetection': 'ExperimentalResourceDetection', - 'Detector': 'ExperimentalResourceDetector', - 'DetectorAttributes': 'IncludeExclude', - 'AttributeLimits': 'AttributeLimits', 'Propagator': 'HttpsOpentelemetryIoOtelconfigPropagatorJson', - 'CompositePropagator': 'TextMapPropagator', 'LoggerProvider': 'HttpsOpentelemetryIoOtelconfigLoggerProviderJson', - 'LogRecordProcessor': 'LogRecordProcessor', - 'BatchLogRecordProcessor': 'BatchLogRecordProcessor', - 'SimpleLogRecordProcessor': 'SimpleLogRecordProcessor', - 'LogRecordExporter': 'LogRecordExporter', - 'LogRecordLimits': 'LogRecordLimits', - 'LoggerConfigurator': 'ExperimentalLoggerConfigurator', - 'LoggerConfigAndMatcher': 'ExperimentalLoggerMatcherAndConfig', - 'LoggerConfig': 'ExperimentalLoggerConfig', 'TracerProvider': 'HttpsOpentelemetryIoOtelconfigTracerProviderJson', - 'SpanProcessor': 'SpanProcessor', - 'BatchSpanProcessor': 'BatchSpanProcessor', - 'SimpleSpanProcessor': 'SimpleSpanProcessor', - 'SpanExporter': 'SpanExporter', - 'ZipkinSpanExporter': 'ZipkinSpanExporter', - 'SpanLimits': 'SpanLimits', - 'Sampler': 'Sampler', - 'TracerConfigurator': 'ExperimentalTracerConfigurator', - 'TracerConfigAndMatcher': 'ExperimentalTracerMatcherAndConfig', - 'TracerConfig': 'ExperimentalTracerConfig', 'MeterProvider': 'HttpsOpentelemetryIoOtelconfigMeterProviderJson', - 'MetricReader': 'MetricReader', - 'PullMetricReader': 'PullMetricReader', - 'PeriodicMetricReader': 'PeriodicMetricReader', - 'MetricProducer': 'MetricProducer', - 'CardinalityLimits': 'CardinalityLimits', - 'MetricExporter': ['PushMetricExporter', 'PullMetricExporter'], // Handles both push and pull - 'PrometheusMetricExporter': 'ExperimentalPrometheusMetricExporter', - 'PrometheusIncludeExclude': 'IncludeExclude', - 'View': 'View', - 'Selector': 'ViewSelector', - 'Stream': 'ViewStream', - 'StreamIncludeExclude': 'IncludeExclude', - 'StreamAggregation': 'Aggregation', - 'StreamAggregationExplicitBucketHistogram': 'ExplicitBucketHistogramAggregation', - 'MeterConfigurator': 'ExperimentalMeterConfigurator', - 'MeterConfigAndMatcher': 'ExperimentalMeterMatcherAndConfig', - 'MeterConfig': 'ExperimentalMeterConfig', - 'OtlpExporterCommon': ['OtlpHttpExporter', 'OtlpGrpcExporter', 'OtlpHttpMetricExporter', 'OtlpGrpcMetricExporter'], - 'OtlpHttpExporter': ['OtlpHttpExporter', 'OtlpHttpSpanExporter', 'OtlpHttpLogRecordExporter'], - 'OtlpHttpSpanExporter': 'OtlpHttpExporter', - 'OtlpHttpMetricExporter': 'OtlpHttpMetricExporter', - 'OtlpHttpLogRecordExporter': 'OtlpHttpExporter', - 'OtlpGrpcExporter': 'OtlpGrpcExporter', - 'OtlpFileExporter': ['ExperimentalOtlpFileExporter', 'ExperimentalOtlpFileMetricExporter'], 'Instrumentation': 'HttpsOpentelemetryIoOtelconfigInstrumentationJson', - 'GeneralInstrumentation': 'ExperimentalGeneralInstrumentation', - 'GeneralInstrumentationPeer': 'ExperimentalPeerInstrumentation', - 'GeneralInstrumentationHttp': 'ExperimentalHttpInstrumentation', - 'GeneralInstrumentationHttpClient': 'ExperimentalHttpInstrumentation', // client property - 'GeneralInstrumentationHttpServer': 'ExperimentalHttpInstrumentation', // server property - 'LanguageSpecificInstrumentation': 'ExperimentalLanguageSpecificInstrumentation', }; /** * Load type descriptions from YAML file */ function loadTypeDescriptions() { - const yamlPath = path.join(SCRIPT_DIR, 'opentelemetry-configuration/schema/type_descriptions.yaml'); + const yamlPath = path.join(SCRIPT_DIR, 'opentelemetry-configuration/schema/meta_schema_types.yaml'); const yamlContent = fs.readFileSync(yamlPath, 'utf8'); const parsed = yaml.parse(yamlContent); @@ -143,8 +89,15 @@ function loadTypeDescriptions() { const typeDescriptions = new Map(); for (const entry of parsed) { - if (entry.type && entry.property_descriptions) { - typeDescriptions.set(entry.type, entry.property_descriptions); + if (entry.type && entry.properties) { + // Convert array of {property, description} objects to a map + const propertyMap = {}; + for (const prop of entry.properties) { + if (prop.property && prop.description) { + propertyMap[prop.property] = prop.description; + } + } + typeDescriptions.set(entry.type, propertyMap); } } @@ -309,6 +262,11 @@ function findYamlTypesForInterface(interfaceName) { } } + // If no mapping found, try direct name match as fallback + if (matches.length === 0) { + matches.push(interfaceName); + } + return matches; } @@ -350,6 +308,108 @@ function getIndentation(node, sourceText) { return indent; } +/** + * Simplify redundant intersection types + * Converts patterns like: T & (T | null) & T & (T | null) -> T | null + */ +function simplifyRedundantIntersections(content) { + const sourceFile = ts.createSourceFile( + 'temp.ts', + content, + ts.ScriptTarget.Latest, + true + ); + + const modifications = []; + + function visitNode(node) { + // Look for type alias declarations with intersection types + if (ts.isTypeAliasDeclaration(node) && node.type && ts.isIntersectionTypeNode(node.type)) { + const intersectionTypes = node.type.types; + + // Collect type literals and check if there are nullable unions + const typeLiterals = []; + let hasNull = false; + + for (const type of intersectionTypes) { + if (ts.isTypeLiteralNode(type)) { + typeLiterals.push(type); + } else if (ts.isUnionTypeNode(type)) { + // Check if this is a union with null + for (const unionMember of type.types) { + if (unionMember.kind === ts.SyntaxKind.NullKeyword) { + hasNull = true; + } else if (ts.isTypeLiteralNode(unionMember)) { + typeLiterals.push(unionMember); + } + } + } else if (ts.isParenthesizedTypeNode(type) && ts.isUnionTypeNode(type.type)) { + // Handle parenthesized unions: (T | null) + for (const unionMember of type.type.types) { + if (unionMember.kind === ts.SyntaxKind.NullKeyword) { + hasNull = true; + } else if (ts.isTypeLiteralNode(unionMember)) { + typeLiterals.push(unionMember); + } + } + } + } + + // If we have multiple type literals that appear to be duplicates, simplify + if (typeLiterals.length > 1) { + // Check if they have the same structure (same property names) + const firstLiteral = typeLiterals[0]; + const firstProps = firstLiteral.members.map(m => + ts.isPropertySignature(m) && m.name ? getPropertyName(m.name) : '' + ).filter(Boolean).sort().join(','); + + const allSame = typeLiterals.every(literal => { + const props = literal.members.map(m => + ts.isPropertySignature(m) && m.name ? getPropertyName(m.name) : '' + ).filter(Boolean).sort().join(','); + return props === firstProps; + }); + + if (allSame) { + // Replace the entire type with simplified version + const typeStart = node.type.pos; + const typeEnd = node.type.end; + + // Extract just the first type literal text + const firstLiteralStart = firstLiteral.pos; + const firstLiteralEnd = firstLiteral.end; + let simplifiedType = content.substring(firstLiteralStart, firstLiteralEnd).trim(); + + // Add | null if any branch had it + if (hasNull) { + simplifiedType = simplifiedType + ' | null'; + } + + modifications.push({ + start: typeStart, + end: typeEnd, + replacement: ' ' + simplifiedType + }); + } + } + } + + ts.forEachChild(node, visitNode); + } + + visitNode(sourceFile); + + // Apply modifications in reverse order to maintain positions + modifications.sort((a, b) => b.start - a.start); + + let modifiedContent = content; + for (const mod of modifications) { + modifiedContent = modifiedContent.slice(0, mod.start) + mod.replacement + modifiedContent.slice(mod.end); + } + + return modifiedContent; +} + const options = { cwd: `${ROOT_DIR}/scripts/config/opentelemetry-configuration/schema`, strictIndexSignatures: true, // adds undefined @@ -362,8 +422,8 @@ compileFromFile(`${ROOT_DIR}/scripts/config/opentelemetry-configuration/schema/o .then(ts => { let content = ts; - // Add JSDoc descriptions from type_descriptions.yaml - content = addDescriptionsToTypes(content); + // Simplify redundant intersection types + content = simplifyRedundantIntersections(content); // Fix the HttpsOpentelemetryIoOtelconfigInstrumentationJson type // See notes below for details on why this is needed @@ -373,6 +433,14 @@ compileFromFile(`${ROOT_DIR}/scripts/config/opentelemetry-configuration/schema/o return interfaceStart + replacement; }); + // Fix the OpenTelemetryConfiguration type to be OpentelemetryConfiguration + // TODO: this is temporary, see https://github.com/open-telemetry/opentelemetry-configuration/issues/371 + const openTelemetryConfigurationPattern = "export interface OpenTelemetryConfiguration"; + content = content.replace(openTelemetryConfigurationPattern, "export interface OpentelemetryConfiguration"); + + // Add JSDoc descriptions from type_descriptions.yaml + content = addDescriptionsToTypes(content); + // Add license header if not present if (!content.includes('Copyright The OpenTelemetry Authors')) { content = addLicenseHeader(content); From d8336e10a8211fd1398b427a88678379231e4c7c Mon Sep 17 00:00:00 2001 From: JamieDanielson Date: Thu, 6 Nov 2025 16:52:30 -0500 Subject: [PATCH 7/7] update changelog --- experimental/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/experimental/CHANGELOG.md b/experimental/CHANGELOG.md index e4a23729f79..78ce09d805a 100644 --- a/experimental/CHANGELOG.md +++ b/experimental/CHANGELOG.md @@ -10,6 +10,8 @@ For notes on migrating to 2.x / 0.200.x see [the upgrade guide](doc/upgrade-to-2 ### :rocket: Features +* feat(config): generate types from config json schema [#6053](https://github.com/open-telemetry/opentelemetry-js/pull/6053) @JamieDanielson + ### :bug: Bug Fixes ### :books: Documentation