Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Don't trace async resolvers (#9107)

Patryk Zawadzki7132fc55b9dd
diff --git a/saleor/graphql/product/types/channels.py b/saleor/graphql/product/types/channels.py
index accf24e1e6..aa957cbb9e 100644
--- a/saleor/graphql/product/types/channels.py
+++ b/saleor/graphql/product/types/channels.py
@@ -156,7 +156,6 @@ class ProductChannelListing(ModelObjectType):
return root.is_available_for_purchase()
@staticmethod
- @traced_resolver
def resolve_pricing(root: models.ProductChannelListing, info, address=None):
context = info.context
diff --git a/saleor/graphql/product/types/products.py b/saleor/graphql/product/types/products.py
index af37e72a44..f084608460 100644
--- a/saleor/graphql/product/types/products.py
+++ b/saleor/graphql/product/types/products.py
@@ -468,7 +468,6 @@ class ProductVariant(ChannelContextTypeWithMetadata, ModelObjectType):
return getattr(root.node, "digital_content", None)
@staticmethod
- @traced_resolver
def resolve_attributes(
root: ChannelContext[models.ProductVariant],
info,
@@ -511,7 +510,6 @@ class ProductVariant(ChannelContextTypeWithMetadata, ModelObjectType):
return VariantChannelListingByVariantIdLoader(info.context).load(root.node.id)
@staticmethod
- @traced_resolver
def resolve_pricing(
root: ChannelContext[models.ProductVariant], info, address=None
):
@@ -887,7 +885,6 @@ class Product(ChannelContextTypeWithMetadata, ModelObjectType):
return ""
@staticmethod
- @traced_resolver
def resolve_pricing(root: ChannelContext[models.Product], info, address=None):
if not root.channel_slug:
return None
diff --git a/saleor/product/utils/availability.py b/saleor/product/utils/availability.py
index 4924a2df02..a9f6266ace 100644
--- a/saleor/product/utils/availability.py
+++ b/saleor/product/utils/availability.py
@@ -150,82 +150,81 @@ def get_product_availability(
country: Country,
local_currency: Optional[str] = None,
) -> ProductAvailability:
- with opentracing.global_tracer().start_active_span("get_product_availability"):
- channel_slug = channel.slug
+ channel_slug = channel.slug
- discounted = None
- discounted_net_range = get_product_price_range(
- product=product,
- variants=variants,
- variants_channel_listing=variants_channel_listing,
- collections=collections,
- discounts=discounts,
- channel=channel,
- )
- if discounted_net_range is not None:
- discounted = TaxedMoneyRange(
- start=manager.apply_taxes_to_product(
- product,
- discounted_net_range.start,
- country,
- channel_slug=channel_slug,
- ),
- stop=manager.apply_taxes_to_product(
- product,
- discounted_net_range.stop,
- country,
- channel_slug=channel_slug,
- ),
- )
-
- undiscounted = None
- undiscounted_net_range = get_product_price_range(
- product=product,
- variants=variants,
- variants_channel_listing=variants_channel_listing,
- collections=collections,
- discounts=[],
- channel=channel,
+ discounted = None
+ discounted_net_range = get_product_price_range(
+ product=product,
+ variants=variants,
+ variants_channel_listing=variants_channel_listing,
+ collections=collections,
+ discounts=discounts,
+ channel=channel,
+ )
+ if discounted_net_range is not None:
+ discounted = TaxedMoneyRange(
+ start=manager.apply_taxes_to_product(
+ product,
+ discounted_net_range.start,
+ country,
+ channel_slug=channel_slug,
+ ),
+ stop=manager.apply_taxes_to_product(
+ product,
+ discounted_net_range.stop,
+ country,
+ channel_slug=channel_slug,
+ ),
)
- if undiscounted_net_range is not None:
- undiscounted = TaxedMoneyRange(
- start=manager.apply_taxes_to_product(
- product,
- undiscounted_net_range.start,
- country,
- channel_slug=channel_slug,
- ),
- stop=manager.apply_taxes_to_product(
- product,
- undiscounted_net_range.stop,
- country,
- channel_slug=channel_slug,
- ),
- )
-
- discount = None
- price_range_local = None
- discount_local_currency = None
- if undiscounted_net_range is not None and discounted_net_range is not None:
- discount = _get_total_discount_from_range(undiscounted, discounted)
- price_range_local, discount_local_currency = _get_product_price_range(
- discounted, undiscounted, local_currency
- )
- is_visible = (
- product_channel_listing is not None and product_channel_listing.is_visible
+ undiscounted = None
+ undiscounted_net_range = get_product_price_range(
+ product=product,
+ variants=variants,
+ variants_channel_listing=variants_channel_listing,
+ collections=collections,
+ discounts=[],
+ channel=channel,
+ )
+ if undiscounted_net_range is not None:
+ undiscounted = TaxedMoneyRange(
+ start=manager.apply_taxes_to_product(
+ product,
+ undiscounted_net_range.start,
+ country,
+ channel_slug=channel_slug,
+ ),
+ stop=manager.apply_taxes_to_product(
+ product,
+ undiscounted_net_range.stop,
+ country,
+ channel_slug=channel_slug,
+ ),
)
- is_on_sale = is_visible and discount is not None
- return ProductAvailability(
- on_sale=is_on_sale,
- price_range=discounted,
- price_range_undiscounted=undiscounted,
- discount=discount,
- price_range_local_currency=price_range_local,
- discount_local_currency=discount_local_currency,
+ discount = None
+ price_range_local = None
+ discount_local_currency = None
+ if undiscounted_net_range is not None and discounted_net_range is not None:
+ discount = _get_total_discount_from_range(undiscounted, discounted)
+ price_range_local, discount_local_currency = _get_product_price_range(
+ discounted, undiscounted, local_currency
)
+ is_visible = (
+ product_channel_listing is not None and product_channel_listing.is_visible
+ )
+ is_on_sale = is_visible and discount is not None
+
+ return ProductAvailability(
+ on_sale=is_on_sale,
+ price_range=discounted,
+ price_range_undiscounted=undiscounted,
+ discount=discount,
+ price_range_local_currency=price_range_local,
+ discount_local_currency=discount_local_currency,
+ )
+
def get_variant_availability(
variant: ProductVariant,