Skip to content

Commit

Permalink
Attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
elenatanasoiu committed Feb 15, 2024
1 parent bc049be commit 5f42c1b
Showing 1 changed file with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,44 +89,44 @@ def attributes_for(key, data)
case key
when 'execute_field'
field_attr_cache = data[:query].context.namespace(:otel_attrs)[:execute_field_attrs] ||= attr_cache do |field|
{
'graphql.field.parent' => field.owner.graphql_name || "", # nil values are not permitted
'graphql.field.name' => (field.graphql_name if field.graphql_name),
'graphql.lazy' => false
}.freeze
attrs = {}
attrs['graphql.field.parent'] = field.owner.graphql_name if field.owner.graphql_name
attrs['graphql.field.name'] = field.graphql_name if field.graphql_name
attrs['graphql.lazy'] = false
attrs.freeze
end
field_attr_cache[data[:field]]
when 'execute_field_lazy'
lazy_field_attr_cache = data[:query].context.namespace(:otel_attrs)[:execute_field_lazy_attrs] ||= attr_cache do |field|
{
'graphql.field.parent' => (field.owner.graphql_name if field.owner.graphql_name),
'graphql.field.name' => (field.graphql_name if field.graphql_name),
'graphql.lazy' => true
}.freeze
attrs = {}
attrs['graphql.field.parent'] = field.owner.graphql_name if field.owner.graphql_name
attrs['graphql.field.name'] = field.graphql_name if field.graphql_name
attrs['graphql.lazy'] = true
attrs.freeze
end
lazy_field_attr_cache[data[:field]]
when 'authorized', 'resolve_type'
type_attrs_cache = data[:context].namespace(:otel_attrs)[:type_attrs] ||= attr_cache do |type|
{
'graphql.type.name' => (type.graphql_name if type.graphql_name),
'graphql.lazy' => false
}.freeze
attrs = {}
attrs['graphql.type.name'] = type.graphql_name if type.graphql_name
attrs['graphql.lazy'] = false
attrs.freeze
end
type_attrs_cache[data[:type]]
when 'authorized_lazy', 'resolve_type_lazy'
type_lazy_attrs_cache = data[:context].namespace(:otel_attrs)[:type_lazy_attrs] ||= attr_cache do |type|
{
'graphql.type.name' => (type.graphql_name if type.graphql_name),
'graphql.lazy' => true
}.freeze
attrs = {}
attrs['graphql.type.name'] = type.graphql_name if type.graphql_name
attrs['graphql.lazy'] = true
attrs.freeze
end
type_lazy_attrs_cache[data[:type]]
when 'execute_query'
{
'graphql.document' => (data[:query].query_string if data[:query].query_string),
'graphql.operation.type' => (data[:query].selected_operation.operation_type if data[:query].selected_operation && data[:query].selected_operation.operation_type),
'graphql.operation.name' => data[:query].selected_operation_name || "", # nil values are not permitted
}.freeze
attrs = {}
attrs['graphql.document'] = data[:query].query_string if data[:query].query_string
attrs['graphql.operation.type'] = data[:query].selected_operation.operation_type if data[:query].selected_operation && data[:query].selected_operation.operation_type
attrs['graphql.operation.name'] = data[:query].selected_operation_name || "anonymous"
attrs.freeze
else
{}
end
Expand Down

0 comments on commit 5f42c1b

Please sign in to comment.