Giter VIP home page Giter VIP logo

Comments (5)

daschaa avatar daschaa commented on August 18, 2024 3

I would like to take this issue :)

from powertools-lambda-typescript.

boring-cyborg avatar boring-cyborg commented on August 18, 2024

Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #typescript channel on our Powertools for AWS Lambda Discord: Invite link

from powertools-lambda-typescript.

dreamorosi avatar dreamorosi commented on August 18, 2024

Hi @ralbertazzi - thank you for opening this issue.

I confirm that I am able to reproduce the issue:
image

I agree also with the fix proposed, if the value is :/etc/localtime we should default to :UTC. The fix should be applied in this function, which should be modified to do something like this:

public formatTimestamp(now: Date): string {
  const defaultTimezone = 'UTC';

  /**
   * If a specific timezone is configured and it's not the default `UTC`,
   * format the timestamp with the appropriate timezone offset.
   **/
- const configuredTimezone = this.envVarsService?.getTimezone();
+ const envVartimezone = this.envVarsService?.getTimezone();
+ const configuredTimezone =
+   envVartimezone === ':/etc/localtime' ? defaultTimezone : envVartimezone;
  if (configuredTimezone && !configuredTimezone.includes(defaultTimezone))
    return this.#generateISOTimestampWithOffset(now, configuredTimezone);

  return now.toISOString();
}

Additionally, we should also add a test case at the bottom of this block here to test for this case, similar to:

it('uses the default UTC timezone when the TZ env variable is set to `:/etc/localtime`', () => {
  // Prepare
  process.env.TZ = ':/etc/localtime';
  const formatter = new PowertoolsLogFormatter({
    envVarsService: new EnvironmentVariablesService(),
  });

  // Act
  const timestamp = formatter.formatTimestamp(new Date());

  // Assess
  expect(timestamp).toEqual('2016-06-20T12:08:10.000Z');
});

I'll mark the issue as help-wanted and good-first-issue to signify that contributions are very welcome.

If nobody picks it up, we'll work on it and include the fix in the next release (~next Wednesday).

In the meantime, as a stopgap solution you can set the TZ environment variable to :UTC to continue using this version of Logger.

In parallel, I'll also consult the AWS Lambda team to see if the container image should align its behavior with the managed runtime & set the value to :UTC.

from powertools-lambda-typescript.

github-actions avatar github-actions commented on August 18, 2024

⚠️ COMMENT VISIBILITY WARNING ⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

from powertools-lambda-typescript.

github-actions avatar github-actions commented on August 18, 2024

This is now released under v2.7.0 version!

from powertools-lambda-typescript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.