dackdive's blog

新米webエンジニアによる技術ブログ。JavaScript(React), Salesforce, Python など

[Google App Engine]AppStatsのタイムゾーンを変更する

Request History に表示されている時刻のこと。

f:id:dackdive:20150320134443p:plain

そもそもどのタイムゾーンで表示しているの?とかどうやって変更するの?とか気になったので調べてみたら、公式ドキュメントに記載があった。

Appstats for Python 2  |  App Engine standard environment for Python 2  |  Google Cloud

You can configure the behavior of Appstats by adding content to the appengine_config.py file in your application's root directory. For a complete example of configuration options, see the file google/appengine/ext/appstats/sample_appengine_config.py in the SDK.

詳しくは SDK 内の sample_appengine_config.py を見れば分かるとのこと。
見てみる。

sample_appengine_config.py(抜粋)

# Timezone offset.  This is used to convert recorded times (which are
# all in UTC) to local time.  The default is US/Pacific winter time.

appstats_TZOFFSET = 8*3600

というわけで、appstats_TZOFFSETappengine_config.py に記載すれば良い。
また、デフォルトでは PST(Pacific Standard Time)のようですね。

指定している時の注意点としては、

  • "分" で指定しているようなので、3600 を掛ける
  • オフセットは UTC - appstats_TZOFFSET つまりマイナスで入る

ので、日本時間(JST: UTC+09:00)にしたい場合は

appstats_TZOFFSET = -9*3600

とするのかな。