-
Couldn't load subscription status.
- Fork 53
Closed as not planned
Description
weaver/crates/weaver_forge/src/extensions/otel.rs
Lines 308 to 330 in 04f911e
| /// Returns the instantiated type of the input type. | |
| pub(crate) fn instantiated_type(attr_type: &Value) -> Result<String, minijinja::Error> { | |
| if is_simple_type(attr_type) { | |
| return Ok(attr_type | |
| .as_str() | |
| .expect("should never happen, already tested in is_template_type") | |
| .to_owned()); | |
| } | |
| if is_template_type(attr_type) { | |
| let attr_type = attr_type | |
| .as_str() | |
| .expect("should never happen, already tested in is_template_type"); | |
| let end = attr_type.len() - TEMPLATE_SUFFIX.len(); | |
| return Ok(attr_type[TEMPLATE_PREFIX.len()..end].to_owned()); | |
| } | |
| if is_enum_type(attr_type) { | |
| return enum_type(attr_type); | |
| } | |
| Err(minijinja::Error::custom(format!( | |
| "Expected simple type, template type, or enum type, found {}", | |
| attr_type | |
| ))) | |
| } |
The most recent release of semconv includes an update for an attribute to have any type. Running the Go generation tooling now fails with this:
Diagnostic report:
× Template evaluation error -> cannot deserialize: Expected simple type,
│ template type, or enum type, found any (in helpers.j2:119)
│
Which refers to this code:
{%- macro generate_funcs(group, pkg="") -%}
{%- for attribute in group.attributes if not attribute is enum %}
{#- TODO: Handle template attributes. #}
{%- if not attribute.type is template_type %}
{{ [to_go_name(attribute.name, pkg) ~ " returns an attribute KeyValue conforming to the \"" ~ attribute.name ~ "\" semantic conventions. " ~ it_reps(attribute.brief) ] | comment(format="go") }}
func {{to_go_name(attribute.name, pkg)}}(val {{attribute.type | instantiated_type | map_text("attribute_type_value")}}) attribute.KeyValue {
return {{to_go_name(attribute.name, pkg)}}Key.{{attribute.type | instantiated_type | map_text("attribute_type_method")}}(val)
}
{%- endif %}
{%- endfor %}
{%- endmacro -%}Specifically {{attribute.type | instantiated_type ... }}.
Is there a way to handle this attribute type case?
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done