https://discord.cloudflare.com logo
Join Discord
Powered by
# workers-discussions
  • c

    Cyb3r-Jok3

    05/27/2023, 8:24 PM
    You probably have two workers with different names and both using the production environment
  • j

    James

    05/27/2023, 8:24 PM
    The terminology around environments is weird. I summarised a while back: https://community.cloudflare.com/t/environments-vs-deployments/451036/2?u=cherryjimbo
  • a

    AA

    05/27/2023, 8:25 PM
    @James Oh you're CherryJimbo! that explains so much 😄 also this explains lots too. just ignore the dashboard one 😄
  • j

    James

    05/27/2023, 8:26 PM
    Yep that's me 😄 yeah, you're best just to ignore the
    production
    stuff on the dashboard entirely right now
  • j

    James

    05/27/2023, 8:26 PM
    This'll get better with Pages+Workers convergence long-term, but that's probably a ways off
  • a

    AA

    05/27/2023, 8:26 PM
    https://developers.cloudflare.com/workers/platform/environments/#introducing-environments <-- i'm setting up my workers like this, is this reasonable?
  • a

    AA

    05/27/2023, 8:26 PM
    change the 'name' per environment
  • j

    James

    05/27/2023, 8:27 PM
    yep, that's basically the only way to do it right now
  • a

    AA

    05/27/2023, 8:27 PM
    i see ok
  • a

    AA

    05/27/2023, 8:28 PM
    now to figure out postgres through cloudflareD without exposing it to the internets
  • a

    AA

    05/27/2023, 8:36 PM
    maybe not possible..
  • v

    vyber

    05/27/2023, 8:41 PM
    yo
  • i

    ItsWendell

    05/27/2023, 9:45 PM
    Does anyone here has a comfortable setup with Toucan.js (Sentry) and SourceMaps?
  • w

    Walshy | Pages

    05/27/2023, 9:49 PM
    yep but not one I can easily share, the repo has a good example setup though
  • w

    Walshy | Pages

    05/27/2023, 9:49 PM
  • s

    sirupsen

    05/28/2023, 1:03 AM
    How can I pass on the unbound plan's cost onto my customers if I can't get full request time (only IO) from within the worker? https://community.cloudflare.com/t/cloudflare-workers-how-do-i-measure-execution-time-of-my-method/69672/5
  • s

    sirupsen

    05/28/2023, 1:08 AM
    The only way I can think of is logging something at the end of the request in a
    waitUntil
    , pushing the logs to R2, and then writing a billing script that does the timestamp delta. Not exactly elegant...
  • k

    kian

    05/28/2023, 1:23 AM
    The only thing that I know of which has accurate duration on a per-request basis is the HTTP Requests dataset on Logpush - which is an Enterprise feature
  • k

    kian

    05/28/2023, 1:23 AM
    Workers for Platforms will probably have better metrics, as customer Workers is one of the main use-cases for it, but that's also currently Enterprise but is likely to come to pay-as-you-go plans eventually.
  • k

    kian

    05/28/2023, 1:23 AM
    Timing in Workers is always difficult as every timer you have accurate to (including the timestamps in the live logs) implements Spectre mitigations.
  • k

    kian

    05/28/2023, 1:24 AM
    It only advances on I/O - so it's never representative of wall-clock anyways.
  • s

    SoulHarsh007

    05/28/2023, 2:08 AM
    🤔is there a way I can get execution region from my worker?
  • w

    Walshy | Pages

    05/28/2023, 2:09 AM
    request.cf.colo
  • w

    Walshy | Pages

    05/28/2023, 2:10 AM
    or
    request.cf.region
    for more region like info
  • w

    Walshy | Pages

    05/28/2023, 2:10 AM
    for details on all the available properties:
  • w

    Walshy | Pages

    05/28/2023, 2:12 AM
    there are no "regions" in CF though so yeah
  • s

    SoulHarsh007

    05/28/2023, 2:20 AM
    And this works in a cron job too?
  • s

    SoulHarsh007

    05/28/2023, 2:22 AM
    I mostly want it for my cron jobs, since I want to know which region executed the cron. I was also wondering if it might be possible to run the same cron job, from multiple regions at the same time?
  • w

    Walshy | Pages

    05/28/2023, 2:28 AM
    err no in cron we don't expose that easily but you can hit /cdn-cgi/trace to grab it
    Copy code
    js
    const res = await fetch('https://cloudflare.com/cdn-cgi/trace');
    const text = await res.text();
    const colo = text.substring(text.indexOf('colo=') + 5, text.indexOf('\n', text.indexOf('colo=')));
  • s

    SoulHarsh007

    05/28/2023, 2:33 AM
    Thanks
1...25052506250725082509Latest