github.com/zchee/zap-cloudlogging@v0.0.0-20220819025602-19b026d3900e/pkg/detector/appengine.go (about) 1 // Copyright 2022 The zap-cloudlogging Authors 2 // SPDX-License-Identifier: BSD-3-Clause 3 4 package detector 5 6 // List of App Engine Standard env vars: 7 // 8 // https://cloud.google.com/appengine/docs/standard/go/runtime#environment_variables 9 const ( 10 // EnvAppEngineEnv is the App Engine environment. Set to "standard". 11 EnvAppEngineEnv = "GAE_ENV" 12 ) 13 14 func (d *Detector) isAppEngineStandard() bool { 15 env := d.attrs.EnvVar(EnvAppEngineEnv) 16 17 return env == "standard" 18 } 19 20 // List of App Engine Flex env vars: 21 // 22 // https://cloud.google.com/appengine/docs/flexible/python/runtime#environment_variables 23 const ( 24 // EnvAppEngineFlexService is the service name specified in your application's app.yaml file, or if no service name is specified, it is set to default. 25 EnvAppEngineFlexService = "GAE_SERVICE" 26 27 // EnvAppEngineFlexVersion is the version label of the current application. 28 EnvAppEngineFlexVersion = "GAE_VERSION" 29 30 // EnvAppEngineFlexInstance is the name of the current instance. 31 EnvAppEngineFlexInstance = "GAE_INSTANCE" 32 ) 33 34 func (d *Detector) isAppEngineFlex() bool { 35 service := d.attrs.EnvVar(EnvAppEngineFlexService) 36 version := d.attrs.EnvVar(EnvAppEngineFlexVersion) 37 instance := d.attrs.EnvVar(EnvAppEngineFlexInstance) 38 39 return instance != "" && service != "" && version != "" 40 }