Skip to content

Commit b4f4b5a

Browse files
committed
Tweak Sentry SDK setup
Make two changes to what we report to Sentry for crashes: 1. Set 'environment' to SENTRY_REGION / SENTRY_ENVIRONMENT so rather than being 'production' or 'development' it's 'us', 'de', etc. 2. Set 'release' to the git sha we are building at.
1 parent a2c012a commit b4f4b5a

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,8 @@ USER app
109109
# Expose ports
110110
EXPOSE 2218
111111

112+
ARG LAUNCHPAD_VERSION_SHA
113+
ENV LAUNCHPAD_VERSION_SHA=$LAUNCHPAD_VERSION_SHA
114+
112115
# Default command
113116
CMD ["launchpad", "serve", "--verbose"]

cloudbuild.ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ steps:
1515
set -euxo pipefail
1616
docker buildx build \
1717
--platform linux/amd64,linux/arm64 \
18+
--build-arg LAUNCHPAD_VERSION_SHA=$COMMIT_SHA \
1819
-t $LOCATION-docker.pkg.dev/$PROJECT_ID/$REPO_NAME/image:$COMMIT_SHA \
1920
--label org.opencontainers.image.revision=$COMMIT_SHA \
2021
--label org.opencontainers.image.version=$COMMIT_SHA \

cloudbuild.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ steps:
2525
docker buildx build \
2626
--push \
2727
--platform linux/amd64 \
28+
--build-arg LAUNCHPAD_VERSION_SHA=$COMMIT_SHA \
2829
-t $LOCATION-docker.pkg.dev/$PROJECT_ID/$REPO_NAME/image:$COMMIT_SHA \
2930
-t $LOCATION-docker.pkg.dev/$PROJECT_ID/$REPO_NAME/image:$SHORT_SHA \
3031
-t $LOCATION-docker.pkg.dev/$PROJECT_ID/$REPO_NAME/image:nightly \

src/launchpad/sentry_sdk_init.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,13 @@ def initialize_sentry_sdk() -> None:
4646
dsn=config.dsn,
4747
integrations=integrations,
4848
send_default_pii=True,
49+
# Release is the git sha
4950
release=config.release,
50-
environment=config.environment,
51+
# Convention is to set the Sentry environment to the region (us, de, etc).
52+
environment=config.region,
5153
)
5254

53-
if config.region:
54-
sentry_sdk.set_tag("sentry_region", config.region)
55-
56-
logger.info(f"Sentry SDK initialized for environment: {config.environment}")
55+
logger.info(f"Sentry SDK initialized for environment: {config.region}")
5756

5857

5958
@dataclass
@@ -75,6 +74,6 @@ def get_sentry_config() -> SentryConfig:
7574
return SentryConfig(
7675
dsn=os.getenv("SENTRY_DSN"),
7776
environment=environment.lower(),
78-
release=os.getenv("LAUNCHPAD_VERSION_SHA", "unknown"), # TODO: auto fetch latest git commit hash
79-
region=os.getenv("SENTRY_REGION"),
77+
release=os.getenv("LAUNCHPAD_VERSION_SHA", "unknown"),
78+
region=os.getenv("SENTRY_REGION", "unknown"),
8079
)

0 commit comments

Comments
 (0)