Background
SdkBuilder::SetResource currently does not support building configured resource detectors and filtering attributes. This issue is to track completion of that feature.
The yaml schema defines the resource: detection/development field in schema/resource.yaml#L12.
The SDK configuration component implements this model with ResourceConfiguration which has four fields:
detection (a list of named detectors plus an IncludeExclude attribute filter)
attributes_list (a key=value,... string)
attributes (a typed key-value map)
schema_url
Parsing of the model from YAML is complete and the Registry has slots for the four named detector
builders (container, host, process, service) and extension detectors. The remaining work is to implement the detector creation, attribute filtering, and resource merge.
Required behavior
Detector dispatch
The YAML path is resource.detection/development.detectors. Each entry names a detector:
resource:
detection/development:
attributes:
included: ["process.*"]
excluded: ["process.command_args"]
detectors:
- process:
- container:
- service:
- host:
- my_custom_detector:
The four built-in names are container, host, process, and service. Any other name is an
extension detector looked up by name in the registry. If a builder is not registered for the named detector then the SdkBuilder should fail with an error log (currently handled by throwing an exception).
See ResourceDetectorConfigurationVisitor use the same pattern as SpanExporterBuilder in sdk_builder.cc.
Attribute filter
After running all configured detectors, the merged detected resource must be filtered using
detection.attributes before being incorporated into the final resource:
- If
included is absent, all attribute keys pass.
excluded is applied after included; a key matched by excluded is dropped even if it also matched included.
- Patterns use
* (any sequence) and ? (any single character) wildcards and the implementation should leverage sdk::common::WildcardMatch.
The filter applies only to detected attributes. attributes_list and attributes are never filtered.
Merge priority order
Per the resource SDK merge spec,
the updating resource's value wins on key conflict. The four sources, lowest-priority first:
Resource::GetDefault() provides a Resource with the telemetry.sdk.* attributes only
- Detected resource from the registered detectors after the
detection.attributes filter
attributes_list from the model (comma-separated key=value string)
attributes from the model (typed map + schema_url)
Note: Resource::Create internally runs GetDefault() and OTELResourceDetector, which pulls attributes from the environment variable. It cannot be used in SdkBuilder.
Background
SdkBuilder::SetResourcecurrently does not support building configured resource detectors and filtering attributes. This issue is to track completion of that feature.The yaml schema defines the
resource: detection/developmentfield in schema/resource.yaml#L12.The SDK configuration component implements this model with
ResourceConfigurationwhich has four fields:detection(a list of named detectors plus anIncludeExcludeattribute filter)attributes_list(akey=value,...string)attributes(a typed key-value map)schema_urlParsing of the model from YAML is complete and the
Registryhas slots for the four named detectorbuilders (
container,host,process,service) and extension detectors. The remaining work is to implement the detector creation, attribute filtering, and resource merge.Required behavior
Detector dispatch
The YAML path is
resource.detection/development.detectors. Each entry names a detector:The four built-in names are
container,host,process, andservice. Any other name is anextension detector looked up by name in the registry. If a builder is not registered for the named detector then the SdkBuilder should fail with an error log (currently handled by throwing an exception).
See
ResourceDetectorConfigurationVisitoruse the same pattern asSpanExporterBuilderinsdk_builder.cc.Attribute filter
After running all configured detectors, the merged detected resource must be filtered using
detection.attributesbefore being incorporated into the final resource:includedis absent, all attribute keys pass.excludedis applied afterincluded; a key matched byexcludedis dropped even if it also matchedincluded.*(any sequence) and?(any single character) wildcards and the implementation should leveragesdk::common::WildcardMatch.The filter applies only to detected attributes.
attributes_listandattributesare never filtered.Merge priority order
Per the resource SDK merge spec,
the updating resource's value wins on key conflict. The four sources, lowest-priority first:
Resource::GetDefault()provides a Resource with thetelemetry.sdk.*attributes onlydetection.attributesfilterattributes_listfrom the model (comma-separatedkey=valuestring)attributesfrom the model (typed map +schema_url)Note:
Resource::Createinternally runsGetDefault()andOTELResourceDetector, which pulls attributes from the environment variable. It cannot be used in SdkBuilder.