From 670901762dd5cce1eecee423b8660e69f71ef4be Mon Sep 17 00:00:00 2001 From: Brett McBride Date: Tue, 18 Jun 2024 02:07:52 +1000 Subject: [PATCH] adding instrumentation configuration (#91) * adding instrumentation configuration * organise general instrumentation config by semconv * update peer service mapping example * Apply suggestions from code review Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com> * adding comments, sections for all languages * expand logback example config, comments * Add all surface area, docs to kitchen-sink.yaml, use consistent case for property keys, remove db semconv options. * Fix typo --------- Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com> Co-authored-by: Jack Berg --- CHANGELOG.md | 2 + examples/kitchen-sink.yaml | 104 ++++++++++++++++++ schema/instrumentation.json | 134 ++++++++++++++++++++++++ schema/opentelemetry_configuration.json | 3 + 4 files changed, 243 insertions(+) create mode 100644 schema/instrumentation.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 71726fa..96ba1ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +* Adding initial instrumentation configuration schema + ## [v0.2.0] - 2024-05-08 * Document time value units in kitchen-sink example. [#51](https://github.com/open-telemetry/opentelemetry-configuration/pull/51) diff --git a/examples/kitchen-sink.yaml b/examples/kitchen-sink.yaml index 1e759ed..b7f1f99 100644 --- a/examples/kitchen-sink.yaml +++ b/examples/kitchen-sink.yaml @@ -434,3 +434,107 @@ resource: - process.command_args # Configure the resource schema URL. schema_url: https://opentelemetry.io/schemas/1.16.0 + +# Configure instrumentation. +instrumentation: + # Configure general SemConv options that may apply to multiple languages and instrumentations. + # + # Instrumenation may merge general config options with the language specific configuration at .instrumentation.. + general: + # Configure instrumentations following the peer semantic conventions. + # + # See peer semantic conventions: https://opentelemetry.io/docs/specs/semconv/attributes-registry/peer/ + peer: + # Configure the service mapping for instrumentations following peer.service semantic conventions. + # + # 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: 1.2.3.4 + service: FooService + - peer: 2.3.4.5 + service: BarService + # Configure instrumentations following the http semantic conventions. + # + # See http semantic conventions: https://opentelemetry.io/docs/specs/semconv/http/ + http: + # Configure instrumentations following the http client semantic conventions. + client: + # Configure headers to capture for outbound http requests. + request_captured_headers: + - Content-Type + - Accept + # Configure headers to capture for outbound http responses. + response_captured_headers: + - Content-Type + - Content-Encoding + # Configure instrumentations following the http server semantic conventions. + server: + # Configure headers to capture for inbound http requests. + request_captured_headers: + - Content-Type + - Accept + # Configure headers to capture for outbound http responses. + response_captured_headers: + - Content-Type + - Content-Encoding + # Configure language-specific instrumentation libraries. + # + # Keys may refer to instrumentation libraries or collections of related configuration. Because there is no central schema defining the keys or their contents, instrumentation must carefully document their schema and avoid key collisions with other instrumentations. + # + # Configure C++ language-specific instrumentation libraries. + cpp: + # Configure the instrumentation corresponding to key "example". + example: + property: "value" + # Configure .NET language-specific instrumentation libraries. + dotnet: + # Configure the instrumentation corresponding to key "example". + example: + property: "value" + # Configure Erlang language-specific instrumentation libraries. + erlang: + # Configure the instrumentation corresponding to key "example". + example: + property: "value" + # Configure Go language-specific instrumentation libraries. + go: + # Configure the instrumentation corresponding to key "example". + example: + property: "value" + # Configure Java language-specific instrumentation libraries. + java: + # Configure the instrumentation corresponding to key "example". + example: + property: "value" + # Configure JavaScript language-specific instrumentation libraries. + js: + # Configure the instrumentation corresponding to key "example". + example: + property: "value" + # Configure PHP language-specific instrumentation libraries. + php: + # Configure the instrumentation corresponding to key "example". + example: + property: "value" + # Configure Python language-specific instrumentation libraries. + python: + # Configure the instrumentation corresponding to key "example". + example: + property: "value" + # Configure Ruby language-specific instrumentation libraries. + ruby: + # Configure the instrumentation corresponding to key "example". + example: + property: "value" + # Configure Rust language-specific instrumentation libraries. + rust: + # Configure the instrumentation corresponding to key "example". + example: + property: "value" + # Configure Swift language-specific instrumentation libraries. + swift: + # Configure the instrumentation corresponding to key "example". + example: + property: "value" diff --git a/schema/instrumentation.json b/schema/instrumentation.json new file mode 100644 index 0000000..cf93ef6 --- /dev/null +++ b/schema/instrumentation.json @@ -0,0 +1,134 @@ +{ + "$id": "https://opentelemetry.io/otelconfig/instrumentation.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Instrumentation", + "type": "object", + "additionalProperties": false, + "properties": { + "general": { + "$ref": "#/$defs/GeneralInstrumentation" + }, + "cpp": { + "$ref": "#/$defs/LanguageSpecificInstrumentation" + }, + "dotnet": { + "$ref": "#/$defs/LanguageSpecificInstrumentation" + }, + "erlang": { + "$ref": "#/$defs/LanguageSpecificInstrumentation" + }, + "go": { + "$ref": "#/$defs/LanguageSpecificInstrumentation" + }, + "java": { + "$ref": "#/$defs/LanguageSpecificInstrumentation" + }, + "js": { + "$ref": "#/$defs/LanguageSpecificInstrumentation" + }, + "php": { + "$ref": "#/$defs/LanguageSpecificInstrumentation" + }, + "python": { + "$ref": "#/$defs/LanguageSpecificInstrumentation" + }, + "ruby": { + "$ref": "#/$defs/LanguageSpecificInstrumentation" + }, + "rust": { + "$ref": "#/$defs/LanguageSpecificInstrumentation" + }, + "swift": { + "$ref": "#/$defs/LanguageSpecificInstrumentation" + } + }, + "patternProperties": { + ".*": { + "$ref": "#/$defs/LanguageSpecificInstrumentation" + } + }, + "$defs": { + "GeneralInstrumentation": { + "type": "object", + "additionalProperties": false, + "properties": { + "peer": { + "type": "object", + "additionalProperties": false, + "properties": { + "service_mapping": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "peer": { + "type": "string" + }, + "service": { + "type": "string" + } + }, + "required": [ + "peer", + "service" + ] + } + } + } + }, + "http": { + "type": "object", + "additionalProperties": false, + "properties": { + "client": { + "type": "object", + "additionalProperties": false, + "properties": { + "request_captured_headers": { + "type": "array", + "items": { + "type": "string" + } + }, + "response_captured_headers": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "server": { + "type": "object", + "additionalProperties": false, + "properties": { + "request_captured_headers": { + "type": "array", + "items": { + "type": "string" + } + }, + "response_captured_headers": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + }, + "LanguageSpecificInstrumentation": { + "type": "object", + "additionalProperties": true, + "patternProperties": { + ".*": { + "type": "object" + } + } + } + } +} \ No newline at end of file diff --git a/schema/opentelemetry_configuration.json b/schema/opentelemetry_configuration.json index d606299..5062ae0 100644 --- a/schema/opentelemetry_configuration.json +++ b/schema/opentelemetry_configuration.json @@ -28,6 +28,9 @@ }, "resource": { "$ref": "resource.json" + }, + "instrumentation": { + "$ref": "instrumentation.json" } }, "required": [