For discussing the development and usage of Checkout UI extensions, post-purchase extensions, web pixels, Customer Accounts UI extensions, and POS UI extensions
I’m currently working with a Shopify product discount function, and in the logs, I’ve noticed something called fuelConsumed. The value for my function is 1,254,557. I’m trying to understand what this number means:
What exactly is "Fuel"? – Is it measured in terms of bytes, kilobytes, or something else entirely? How is it calculated?
Is this number considered high? – Given that my function logic is fairly straightforward, I’m wondering if I should be concerned about this level of fuel consumption, or if this is normal for a function of this type.
Are there limits on fuel usage? – I can imagine more complex logic being implemented, so I’m curious if there are specific fuel limits that developers should be aware of, and if so, what happens if you exceed those limits?
Here is a sample log from one of my function runs:
{ "shopId": 1234567890, "apiClientId": 987654321, "payload": { "export": "run", "input": { "cart": { "lines": [ { "merchandise": { "typename": "ProductVariant", "id": "gid://shopify/ProductVariant/12345678901234", "product": { "handle": "example-product-one", "inCollections": [ { "collectionId": "gid://shopify/Collection/1234567890", "isMember": false } ] } } }, { "merchandise": { "typename": "ProductVariant", "id": "gid://shopify/ProductVariant/12345678956789", "product": { "handle": "example-product-two", "inCollections": [ { "collectionId": "gid://shopify/Collection/1234567890", "isMember": true } ] } } } ], "buyerIdentity": { "customer": { "hasTags": [ { "tag": "Pro", "hasTag": true }, { "tag": "VIP", "hasTag": false } ] } } }, "shop": { "metafield": { "value": "{\"Pro\":{\"collections\":[{\"id\":\"1234567890\",\"discountValue\":\"99\",\"discountType\":\"%\"}]},\"VIP\":{\"collections\":[{\"id\":\"1234567890\",\"discountValue\":\"90\",\"discountType\":\"%\"}]}}" } } }, "inputBytes": 1368, "output": { "discountApplicationStrategy": "ALL", "discounts": [ { "message": "PRO DISCOUNT", "targets": [ { "productVariant": { "id": "gid://shopify/ProductVariant/12345678956789" } } ], "value": { "percentage": { "value": 99 } } } ] }, "outputBytes": 345, "logs": [ "Starting discount function...", "Current metafield value: [object Object]", "Parsed shop configuration: [object Object]", "Customer tags: Pro", "Configuration for customer tag (Pro): [object Object]", "$selectedCollectionIds: gid://shopify/Collection/1234567890", "Processing product variant: gid://shopify/ProductVariant/12345678901234, product: example-product-one", "Product is not a member of collection: gid://shopify/Collection/1234567890, skipping...", "Processing product variant: gid://shopify/ProductVariant/12345678956789, product: example-product-two", "Checking collection: 1234567890", "Applying discount for collection: 1234567890" ], "functionId": "function-id-example", "fuelConsumed": 1254557 }, "logType": "function_run", "status": "success", "source": "product-discount", "sourceNamespace": "extensions", "logTimestamp": "2024-09-20T20:03:09.647783Z", "localTime": "2024-09-20 13:03:09" }