|
| 1 | +# [Config] metadata.yaml Format and Declarative Name Conversion |
| 2 | + |
| 3 | +## Quick Reference |
| 4 | + |
| 5 | +- Use when: reviewing or creating `metadata.yaml` files, converting config names |
| 6 | +- Review focus: declarative_name format, examples guidelines, special mappings, config validation |
| 7 | + |
| 8 | +## Entry Structure |
| 9 | + |
| 10 | +Each configuration entry includes: |
| 11 | + |
| 12 | +- `name`: Flat system property (e.g., `otel.instrumentation.grpc.emit-message-events`) |
| 13 | +- `declarative_name`: YAML key path (e.g., `java.grpc.emit_message_events`) |
| 14 | +- `type`: `boolean`, `string`, `list`, `integer` |
| 15 | +- `description`: Human-readable explanation |
| 16 | +- `default`: Default value |
| 17 | +- `examples` (optional): Only for module-specific configs with non-obvious format |
| 18 | + |
| 19 | +## Special Mappings |
| 20 | + |
| 21 | +Non-standard mappings (see `ConfigPropertiesBackedDeclarativeConfigProperties.java` for latest): |
| 22 | + |
| 23 | +| Flat Property | Declarative YAML Key | |
| 24 | +|---------------------------------------------------------------------------------|-------------------------------------------------------------------| |
| 25 | +| `otel.instrumentation.http.client.capture-request-headers` | `general.http.client.request_captured_headers` | |
| 26 | +| `otel.instrumentation.http.client.capture-response-headers` | `general.http.client.response_captured_headers` | |
| 27 | +| `otel.instrumentation.http.server.capture-request-headers` | `general.http.server.request_captured_headers` | |
| 28 | +| `otel.instrumentation.http.server.capture-response-headers` | `general.http.server.response_captured_headers` | |
| 29 | +| `otel.instrumentation.sanitization.url.experimental.sensitive-query-parameters` | `general.sanitization.url.sensitive_query_parameters/development` | |
| 30 | +| `otel.semconv-stability.opt-in` | `general.semconv_stability.opt_in` | |
| 31 | +| `otel.instrumentation.http.known-methods` | `java.common.http.known_methods` | |
| 32 | +| `otel.instrumentation.http.client.experimental.redact-query-parameters` | `java.common.http.client.redact_query_parameters/development` | |
| 33 | +| `otel.instrumentation.http.client.emit-experimental-telemetry` | `java.common.http.client.emit_experimental_telemetry/development` | |
| 34 | +| `otel.instrumentation.http.server.emit-experimental-telemetry` | `java.common.http.server.emit_experimental_telemetry/development` | |
| 35 | +| `otel.instrumentation.messaging.experimental.receive-telemetry.enabled` | `java.common.messaging.receive_telemetry/development.enabled` | |
| 36 | +| `otel.instrumentation.messaging.experimental.capture-headers` | `java.common.messaging.capture_headers/development` | |
| 37 | +| `otel.instrumentation.genai.capture-message-content` | `java.common.gen_ai.capture_message_content` | |
| 38 | +| `otel.instrumentation.experimental.span-suppression-strategy` | `java.common.span_suppression_strategy/development` | |
| 39 | +| `otel.instrumentation.opentelemetry-annotations.exclude-methods` | `java.opentelemetry_extension_annotations.exclude_methods` | |
| 40 | +| `otel.experimental.javascript-snippet` | `java.servlet.javascript_snippet/development` | |
| 41 | +| `otel.jmx.enabled` | `java.jmx.enabled` | |
| 42 | +| `otel.jmx.config` | `java.jmx.config` | |
| 43 | +| `otel.jmx.target.system` | `java.jmx.target.system` | |
| 44 | + |
| 45 | +## Standard Conversion |
| 46 | + |
| 47 | +For `otel.instrumentation.*` properties not in SPECIAL_MAPPINGS: |
| 48 | + |
| 49 | +1. Strip `otel.instrumentation.` prefix |
| 50 | +2. Replace `-` with `_` (kebab-case → snake_case) |
| 51 | +3. Handle `experimental`: |
| 52 | + - `experimental.` path segment → remove, add `/development` to next segment |
| 53 | + - `experimental-` in name → add `/development` to that segment |
| 54 | +4. Prepend `java.` |
| 55 | + |
| 56 | +Examples: |
| 57 | + |
| 58 | +| Flat Property | Declarative YAML Key | |
| 59 | +|------------------------------------------------------------------------------|-------------------------------------------------------------| |
| 60 | +| `otel.instrumentation.grpc.emit-message-events` | `java.grpc.emit_message_events` | |
| 61 | +| `otel.instrumentation.grpc.experimental-span-attributes` | `java.grpc.experimental_span_attributes/development` | |
| 62 | +| `otel.instrumentation.logback-appender.experimental.capture-code-attributes` | `java.logback_appender.capture_code_attributes/development` | |
| 63 | +| `otel.instrumentation.common.experimental.controller-telemetry.enabled` | `java.common.controller_telemetry/development.enabled` | |
| 64 | + |
| 65 | +## Examples Guidelines |
| 66 | + |
| 67 | +Add `examples` only for module-specific configs with non-obvious format (lists, patterns, enums). |
| 68 | + |
| 69 | +**Never add for**: `general.*`, `java.common.*`, or boolean configs. |
| 70 | + |
| 71 | +```yaml |
| 72 | +- name: otel.instrumentation.grpc.capture-metadata.client.request |
| 73 | + declarative_name: java.grpc.capture_metadata.client.request |
| 74 | + type: list |
| 75 | + examples: |
| 76 | + - "custom-request-header" |
| 77 | + - "header1,header2,header3" |
| 78 | +``` |
| 79 | +
|
| 80 | +## Validation Procedure |
| 81 | +
|
| 82 | +### 1. Validate experimental markers match |
| 83 | +
|
| 84 | +- `/development` in declarative_name ↔ `experimental` in flat name (MUST match both ways) |
| 85 | +- WRONG: `otel.instrumentation.servlet.capture-request-parameters` + `java.servlet.capture_request_parameters/development` |
| 86 | +- RIGHT: `otel.instrumentation.servlet.experimental.capture-request-parameters` + `java.servlet.capture_request_parameters/development` |
| 87 | + |
| 88 | +### 2. Verify config is used |
| 89 | + |
| 90 | +Search module source for `DeclarativeConfigUtil.getInstrumentationConfig()`, `config.getBoolean()`, etc. |
| 91 | + |
| 92 | +If a module has a dependency on other modules (for example, a "-common" module, check those as well since they may read the config. |
| 93 | + |
| 94 | +### 3. Verify type and default |
| 95 | + |
| 96 | +Match type and default value with actual code usage. |
| 97 | + |
| 98 | +## Automated Test (MANDATORY) |
| 99 | + |
| 100 | +**Run after any metadata.yaml changes:** |
| 101 | + |
| 102 | +```bash |
| 103 | +./gradlew :instrumentation-docs:test --tests DeclarativeConfigValidationTest |
| 104 | +``` |
| 105 | + |
| 106 | +This validates round-trip conversion (flat property → bridge → declarative path) and catches: |
| 107 | + |
| 108 | +- Wrong flat property names (e.g., missing `experimental.`) |
| 109 | +- Wrong declarative paths |
| 110 | +- Type mismatches |
| 111 | + |
| 112 | +Example failure when flat name is wrong: |
| 113 | + |
| 114 | +``` |
| 115 | +FAIL in ../instrumentation/liberty/liberty-20.0/metadata.yaml: |
| 116 | + flat property: otel.instrumentation.servlet.capture-request-parameters |
| 117 | + expected: [item1, item2, item3] |
| 118 | + got: null |
| 119 | +``` |
| 120 | + |
| 121 | +**Test must pass before completion.** |
| 122 | + |
| 123 | +## Validation Outcomes |
| 124 | + |
| 125 | +| Issue | Action | |
| 126 | +|------------------------------|-----------------------------------------| |
| 127 | +| Config not used | Flag for removal | |
| 128 | +| Default/type mismatch | Update metadata.yaml to match code | |
| 129 | +| Missing config (in code) | Add to metadata.yaml | |
| 130 | +| Experimental marker mismatch | Fix flat and declarative names to agree | |
| 131 | + |
| 132 | +## Output Format |
| 133 | + |
| 134 | +```yaml |
| 135 | +- name: otel.instrumentation.grpc.emit-message-events |
| 136 | + declarative_name: java.grpc.emit_message_events |
| 137 | + type: boolean |
| 138 | + description: Determines whether to emit a span event for each message. |
| 139 | + default: true |
| 140 | +- name: otel.instrumentation.grpc.experimental-span-attributes |
| 141 | + declarative_name: java.grpc.experimental_span_attributes/development |
| 142 | + type: boolean |
| 143 | + description: Enable capture of experimental span attributes. |
| 144 | + default: false |
| 145 | +``` |
| 146 | + |
| 147 | +## Edge Cases |
| 148 | + |
| 149 | +- Properties without `otel.instrumentation.` prefix → check SPECIAL_MAPPINGS |
| 150 | +- Already has declarative_name → skip conversion |
0 commit comments