Skip to content

Conversation

@witoszekdev
Copy link
Member

@witoszekdev witoszekdev commented Dec 8, 2025

Added new utility to trace effects (e.g. external requests). It wraps it with OTEL span and adds logs when we exceed our treshold.

It doesn't cancel request itself, it's used only for observability for now, but can be extended later.

It adds two separate methods:

  • raw wrapper in shared OTEL -> for adding observability spans, wrapping actions
  • wrapper in shared logger -> re-uses wrapper from OTEL, but adds logging via callbacks

Copilot AI review requested due to automatic review settings December 8, 2025 13:17
@witoszekdev witoszekdev requested a review from a team as a code owner December 8, 2025 13:17
@changeset-bot
Copy link

changeset-bot bot commented Dec 8, 2025

🦋 Changeset detected

Latest commit: f11b79b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@saleor/apps-otel Minor
@saleor/apps-logger Minor
saleor-app-search Patch
saleor-app-avatax Patch
saleor-app-cms Patch
saleor-app-klaviyo Patch
saleor-app-payment-np-atobarai Patch
saleor-app-products-feed Patch
saleor-app-segment Patch
saleor-app-smtp Patch
saleor-app-payment-stripe Patch
@saleor/dynamo-config-repository Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Dec 8, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
saleor-app-avatax Ready Ready Preview Comment Dec 10, 2025 3:48pm
saleor-app-cms Ready Ready Preview Comment Dec 10, 2025 3:48pm
saleor-app-klaviyo Ready Ready Preview Comment Dec 10, 2025 3:48pm
saleor-app-payment-np-atobarai Ready Ready Preview Comment Dec 10, 2025 3:48pm
saleor-app-payment-stripe Ready Ready Preview Comment Dec 10, 2025 3:48pm
saleor-app-products-feed Ready Ready Preview Comment Dec 10, 2025 3:48pm
saleor-app-search Ready Ready Preview Comment Dec 10, 2025 3:48pm
saleor-app-segment Ready Ready Preview Comment Dec 10, 2025 3:48pm
saleor-app-smtp Ready Ready Preview Comment Dec 10, 2025 3:48pm

@codecov
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

❌ Patch coverage is 9.00000% with 182 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.03%. Comparing base (b556fdb) to head (f11b79b).

Files with missing lines Patch % Lines
...ps/search/src/lib/algolia/algoliaSearchProvider.ts 3.03% 64 Missing ⚠️
...earch/src/domain/WebhookActivityToggler.service.ts 2.32% 42 Missing ⚠️
.../src/modules/configuration/configuration.router.ts 0.00% 23 Missing and 1 partial ⚠️
packages/logger/src/trace-effect.ts 0.00% 15 Missing and 1 partial ⚠️
...rch/src/modules/trpc/protected-client-procedure.ts 0.00% 9 Missing ⚠️
apps/search/src/pages/api/setup-indices.ts 0.00% 9 Missing ⚠️
...ch/src/lib/algolia/algolia-credentials-verifier.ts 46.15% 7 Missing ⚠️
apps/search/src/webhooks/webhook-context.ts 0.00% 6 Missing ⚠️
.../search/src/lib/algolia/getAlgoliaConfiguration.ts 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2154      +/-   ##
==========================================
- Coverage   36.07%   36.03%   -0.05%     
==========================================
  Files         938      940       +2     
  Lines       60362    60458      +96     
  Branches     2968     2972       +4     
==========================================
+ Hits        21778    21784       +6     
- Misses      38224    38313      +89     
- Partials      360      361       +1     
Flag Coverage Δ
avatax 56.98% <ø> (ø)
cms 15.76% <ø> (ø)
domain 100.00% <ø> (ø)
dynamo-config-repository 79.29% <ø> (ø)
errors 91.66% <ø> (ø)
logger 27.33% <0.00%> (-1.49%) ⬇️
np-atobarai 71.99% <ø> (ø)
products-feed 5.23% <ø> (ø)
search 27.20% <9.78%> (-0.56%) ⬇️
segment 30.20% <ø> (ø)
shared 35.88% <ø> (ø)
smtp 34.96% <ø> (ø)
stripe 70.58% <ø> (ø)
webhook-utils 11.02% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive logging and tracing for external API calls to help diagnose slow API requests and timeouts. The implementation introduces a reusable traceExternalCall utility that wraps async operations with timing instrumentation and conditional warning logs when calls exceed configured thresholds.

Key changes:

  • New traceExternalCall utility function that logs start/finish times and warns on slow operations
  • Systematic wrapping of all Saleor GraphQL, Algolia, and metadata operations with tracing
  • Fixed a missing await bug in setFieldsMappingConfig mutation (line 113 in configuration.router.ts)

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
apps/search/src/lib/trace-external-calls.ts New utility providing timing instrumentation with configurable thresholds (Algolia: 10s, Saleor: 5s, DynamoDB: 1s)
apps/search/src/webhooks/webhook-context.ts Wrapped channel fetching GraphQL query with tracing
apps/search/src/pages/api/webhooks-status.ts Added tracing to webhook fetching API endpoint
apps/search/src/pages/api/setup-indices.ts Wrapped metadata and channel queries with tracing in parallel Promise.all
apps/search/src/modules/configuration/configuration.router.ts Added tracing to all config get/set operations and fixed missing await on line 113
apps/search/src/lib/algolia/getAlgoliaConfiguration.ts Wrapped metadata retrieval with tracing
apps/search/src/lib/algolia/algoliaSearchProvider.ts Added tracing to all Algolia operations (saveObjects, deleteObjects, setSettings, deleteBy) and improved variable naming (objects → objectIds)
apps/search/src/lib/algolia/algolia-credentials-verifier.ts Wrapped API key verification with tracing
apps/search/src/domain/WebhookActivityToggler.service.ts Added tracing to all webhook management operations (fetch, enable, disable, create, remove)
.changeset/spotty-mirrors-sort.md Documented the new tracing feature with threshold values for each service type

@witoszekdev witoszekdev marked this pull request as draft December 8, 2025 13:36
Copilot AI review requested due to automatic review settings December 9, 2025 11:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.

@witoszekdev witoszekdev marked this pull request as ready for review December 9, 2025 16:24
Copy link
Member

@lkostrowski lkostrowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In generale LGTM, but I suggest to invest a little to make it even better

  1. Rename it to traceEffect or something like this, because it doesn't really have to be external. It is universal utility and you can wrap also loading file from disk or or long computation
  2. ...Which makes it our own custom wrapper on trace with extra sugar in the future(we can add extra params, eg "errorOnTimeout: true" which can set attribute etc)
  3. we can already put it to shared package because we definitely should wrap other apps with it

and I think signature will be better with more factory-like:

const traceEffect = createTraceEffect({...});

traceEffect(() => apiCall(...))

because you can reuse them

Copilot AI review requested due to automatic review settings December 10, 2025 13:36
@github-actions
Copy link
Contributor

Differences Found

✅ No packages or licenses were added.

Summary

Expand
License Name Package Count Packages
0BSD 1
Packages
  • tslib
CC BY-SA 4.0 1
Packages
  • @cspell/dict-en-common-misspellings
CC-BY-3.0 1
Packages
  • spdx-exceptions
MIT (http://mootools.net/license.txt) 1
Packages
  • slick
MIT/X11 1
Packages
  • nub
Public Domain 1
Packages
  • jsonify
Python-2.0 1
Packages
  • argparse
SEE LICENSE IN LICENSE 1
Packages
  • spawndamnit
SEE LICENSE IN LICENSE.md 1
Packages
  • lightcookie
Unlicense 1
Packages
  • @sinonjs/text-encoding
WTFPL 1
Packages
  • opener
CC0-1.0 2
Packages
  • spdx-license-ids
  • type-fest
BlueOak-1.0.0 3
Packages
  • jackspeak
  • package-json-from-dist
  • path-scurry
CC-BY-4.0 3
Packages
  • @saleor/macaw-ui
  • caniuse-lite
  • saleor-apps
LGPL-3.0-or-later 11
Packages
  • @img/sharp-libvips-darwin-arm64
  • @img/sharp-libvips-darwin-x64
  • @img/sharp-libvips-linux-arm
  • @img/sharp-libvips-linux-arm64
  • @img/sharp-libvips-linux-s390x
  • @img/sharp-libvips-linux-x64
  • @img/sharp-libvips-linuxmusl-arm64
  • @img/sharp-libvips-linuxmusl-x64
  • @img/sharp-wasm32
  • @img/sharp-win32-ia32
  • @img/sharp-win32-x64
BSD-2-Clause 23
Packages
  • cheerio-select
  • css-select
  • css-what
  • domelementtype
  • domhandler
  • domutils
  • dotenv
  • entities
  • escodegen
  • eslint-scope
  • espree
  • esprima
  • esrecurse
  • estraverse
  • esutils
  • glob-to-regexp
  • normalize-package-data
  • nth-check
  • shimmer
  • terser
  • And 3 more...
<<missing>> 25
Packages
  • @saleor/apps-domain
  • @saleor/apps-logger
  • @saleor/apps-otel
  • @saleor/apps-shared
  • @saleor/apps-trpc
  • @saleor/apps-ui
  • @saleor/dynamo-config-repository
  • @saleor/errors
  • @saleor/eslint-config-apps
  • @saleor/react-hook-form-macaw
  • @saleor/sentry-utils
  • @saleor/typescript-config-apps
  • @saleor/webhook-utils
  • busboy
  • json-query
  • saleor-app-avatax
  • saleor-app-cms
  • saleor-app-klaviyo
  • saleor-app-payment-np-atobarai
  • saleor-app-payment-stripe
  • And 5 more...
BSD-3-Clause 48
Packages
  • @protobufjs/aspromise
  • @protobufjs/base64
  • @protobufjs/codegen
  • @protobufjs/eventemitter
  • @protobufjs/fetch
  • @protobufjs/float
  • @protobufjs/inquire
  • @protobufjs/path
  • @protobufjs/pool
  • @protobufjs/utf8
  • @saleor/app-sdk
  • @saleor/eslint-plugin-saleor-app
  • @sentry/cli
  • @sentry/cli-darwin
  • @sentry/cli-linux-arm
  • @sentry/cli-linux-arm64
  • @sentry/cli-linux-i686
  • @sentry/cli-linux-x64
  • @sentry/cli-win32-i686
  • @sentry/cli-win32-x64
  • And 28 more...
ISC 56
Packages
  • @bundled-es-modules/cookie
  • @bundled-es-modules/statuses
  • @bundled-es-modules/tough-cookie
  • @isaacs/cliui
  • abbrev
  • anymatch
  • boolbase
  • cli-width
  • cliui
  • concat-with-sourcemaps
  • electron-to-chromium
  • fastq
  • flatted
  • foreground-child
  • form-data-lite
  • fs.realpath
  • get-caller-file
  • glob
  • glob-parent
  • graceful-fs
  • And 36 more...
Apache-2.0 235
Packages
  • @ampproject/remapping
  • @aws-crypto/crc32
  • @aws-crypto/crc32c
  • @aws-crypto/ie11-detection
  • @aws-crypto/sha1-browser
  • @aws-crypto/sha256-browser
  • @aws-crypto/sha256-js
  • @aws-crypto/supports-web-crypto
  • @aws-crypto/util
  • @aws-sdk/abort-controller
  • @aws-sdk/chunked-blob-reader
  • @aws-sdk/client-dynamodb
  • @aws-sdk/client-s3
  • @aws-sdk/client-sso
  • @aws-sdk/client-sso-oidc
  • @aws-sdk/client-sts
  • @aws-sdk/config-resolver
  • @aws-sdk/core
  • @aws-sdk/credential-provider-env
  • @aws-sdk/credential-provider-http
  • And 215 more...
MIT 1436
Packages
  • @0no-co/graphql.web
  • @adobe/css-tools
  • @algolia/cache-browser-local-storage
  • @algolia/cache-common
  • @algolia/cache-in-memory
  • @algolia/client-account
  • @algolia/client-analytics
  • @algolia/client-common
  • @algolia/client-personalization
  • @algolia/client-search
  • @algolia/logger-common
  • @algolia/logger-console
  • @algolia/recommend
  • @algolia/requester-browser-xhr
  • @algolia/requester-common
  • @algolia/requester-node-http
  • @algolia/transporter
  • @apidevtools/json-schema-ref-parser
  • @ardatan/relay-compiler
  • @ardatan/sync-fetch
  • And 1416 more...

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment on lines +89 to +90
return this.traceCreateWebhook(() =>
this.client.mutation(CreateWebhookDocument, { input }).toPromise(),
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The createWebhook trace call doesn't pass any attributes, while other methods in this class pass relevant IDs for observability (e.g., webhookId, appId). Consider adding non-sensitive attributes like the webhook's target URL or event type from the input to improve log correlation and debugging capabilities.

Suggested change
return this.traceCreateWebhook(() =>
this.client.mutation(CreateWebhookDocument, { input }).toPromise(),
return this.traceCreateWebhook(
() => this.client.mutation(CreateWebhookDocument, { input }).toPromise(),
{
targetUrl: input.targetUrl,
eventType: Array.isArray(input.asyncEvents) && input.asyncEvents.length > 0
? input.asyncEvents.join(",")
: Array.isArray(input.syncEvents) && input.syncEvents.length > 0
? input.syncEvents.join(",")
: undefined,
},

Copilot uses AI. Check for mistakes.
"version": "2.3.1",
"type": "module",
"exports": {
"./trace-effect": "./src/trace-effect.ts",
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Inconsistent export path pattern: The new trace-effect export uses "./trace-effect": "./src/trace-effect.ts" while all existing exports use the pattern "./src/...": "./src/....ts". For consistency, consider either:

  1. Changing this to "./src/trace-effect": "./src/trace-effect.ts" to match existing exports, or
  2. Creating a cleaner export like "./trace-effect" is fine, but then update imports in consuming code to use the same pattern as other imports (e.g., they currently use @saleor/apps-otel/src/with-span-attributes).
Suggested change
"./trace-effect": "./src/trace-effect.ts",
"./src/trace-effect": "./src/trace-effect.ts",

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings December 10, 2025 15:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants