Skip to content

Commit

Permalink
Micro optimization: build Hash w/ {} (#665)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbourassa authored Sep 17, 2023
1 parent d77b700 commit 352812e
Showing 1 changed file with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ def execute_field(field:, query:, ast_node:, arguments:, object:, &block)
platform_key = _otel_execute_field_key(field: field)
return super unless platform_key

attributes = {}
attributes['graphql.field.parent'] = field.owner&.graphql_name
attributes['graphql.field.name'] = field.graphql_name
attributes['graphql.lazy'] = false
attributes = {
'graphql.field.parent' => field.owner&.graphql_name,
'graphql.field.name' => field.graphql_name,
'graphql.lazy' => false
}

tracer.in_span(platform_key, attributes: attributes, &block)
end
Expand All @@ -87,10 +88,11 @@ def execute_field_lazy(field:, query:, ast_node:, arguments:, object:, &block)
platform_key = _otel_execute_field_key(field: field)
return super unless platform_key

attributes = {}
attributes['graphql.field.parent'] = field.owner&.graphql_name
attributes['graphql.field.name'] = field.graphql_name
attributes['graphql.lazy'] = true
attributes = {
'graphql.field.parent' => field.owner&.graphql_name,
'graphql.field.name' => field.graphql_name,
'graphql.lazy' => true
}

tracer.in_span(platform_key, attributes: attributes, &block)
end
Expand All @@ -99,9 +101,10 @@ def authorized(query:, type:, object:, &block)
platform_key = @_otel_authorized_key_cache[type]
return super unless platform_key

attributes = {}
attributes['graphql.type.name'] = type.graphql_name
attributes['graphql.lazy'] = false
attributes = {
'graphql.type.name' => type.graphql_name,
'graphql.lazy' => false
}

tracer.in_span(platform_key, attributes: attributes, &block)
end
Expand All @@ -110,29 +113,32 @@ def authorized_lazy(query:, type:, object:, &block)
platform_key = @_otel_authorized_key_cache[type]
return super unless platform_key

attributes = {}
attributes['graphql.type.name'] = type.graphql_name
attributes['graphql.lazy'] = true
attributes = {
'graphql.type.name' => type.graphql_name,
'graphql.lazy' => true
}

tracer.in_span(platform_key, attributes: attributes, &block)
end

def resolve_type(query:, type:, object:, &block)
platform_key = @_otel_resolve_type_key_cache[type]

attributes = {}
attributes['graphql.type.name'] = type.graphql_name
attributes['graphql.lazy'] = false
attributes = {
'graphql.type.name' => type.graphql_name,
'graphql.lazy' => false
}

tracer.in_span(platform_key, attributes: attributes, &block)
end

def resolve_type_lazy(query:, type:, object:, &block)
platform_key = @_otel_resolve_type_key_cache[type]

attributes = {}
attributes['graphql.type.name'] = type.graphql_name
attributes['graphql.lazy'] = true
attributes = {
'graphql.type.name' => type.graphql_name,
'graphql.lazy' => true
}

tracer.in_span(platform_key, attributes: attributes, &block)
end
Expand Down

0 comments on commit 352812e

Please sign in to comment.