Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Setting Release Automatically #755

Open
smeubank opened this issue Nov 8, 2022 · 3 comments · May be fixed by #800
Open

Setting Release Automatically #755

smeubank opened this issue Nov 8, 2022 · 3 comments · May be fixed by #800
Assignees

Comments

@smeubank
Copy link
Member

smeubank commented Nov 8, 2022

Problem Statement

Releases are not being consistently set across all SDKs. There are varying attempts to detect release variables and set them, but it is not consistent.

Leading to first and subsequent releases not being set.

Methods per SDK

SDK - Platfrom Approach Approach
Content Cell Content Cell Content Cell
Python - release parameter SENTRY_RELEASE env variable - Output of git rev-parse HEAD see
Rust SDK falls back to SENTRY_RELEASE env if nothing was explicitly sent. & example snippets include release: sentry::release_name!()
Node SDK 1. release parameter 2. SENTRY_RELEASE env var 3. SENTRY_RELEASE.id global var 4. variety of `env variables Content Cell

Solution Brainstorm

Referencing different SDKs strategies we should collect and apply them all where it makes sense, with prioritized order for setting the release when a customer is not doing it manually.

Ruby SDKAttempts->
getsentry/sentry-ruby#873 (comment)

https://docs.sentry.io/platforms/ruby/guides/rails/configuration/releases/
Comment explanation should be in docs

Node SDK Attempts->
Something similar to Ruby witch checking for sentry variable, and different platforms like vercel. But this is not doc'd

https://github.com/getsentry/sentry-javascript/blob/351be067ac7ff280155c128011f79dac9caf6475/packages/node/src/sdk.ts#L232-L262

Go SDK Attempts->
if it is a git repo then it will always use the SHA if it is a GH repo

No mention in docs
https://docs.sentry.io/platforms/go/performance/

@smeubank smeubank changed the title Setting Release Setting Release Automatically Nov 8, 2022
@smeubank smeubank transferred this issue from getsentry/sentry-javascript Nov 10, 2022
@antonpirker
Copy link
Member

Python SDK tries the following things:

  • release parameter
  • SENTRY_RELEASE env variable
  • Output of git rev-parse HEAD

see: https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/utils.py#L59-L95

@Swatinem
Copy link
Member

Rust falls back to SENTRY_RELEASE env if nothing was explicitly sent.
All example snippets include release: sentry::release_name!() which is the way a release is set in Rust.
Unfortunately it needs to be explicitly copy/pasted, as the code needs to be part of the user code.

@AbhiPrasad
Copy link
Member

AbhiPrasad commented Nov 10, 2022

Node SDK tries:

  1. the release parameter: https://github.com/getsentry/sentry-javascript/blob/411b0fa069e7faf8cc4d782cd21a118f909aefdf/packages/node/src/sdk.ts#L133
  2. the SENTRY_RELEASE env var: https://github.com/getsentry/sentry-javascript/blob/411b0fa069e7faf8cc4d782cd21a118f909aefdf/packages/node/src/sdk.ts#L238
  3. the SENTRY_RELEASE.id global var: https://github.com/getsentry/sentry-javascript/blob/411b0fa069e7faf8cc4d782cd21a118f909aefdf/packages/node/src/sdk.ts#L243
    // GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
    process.env.GITHUB_SHA ||
    // Netlify - https://docs.netlify.com/configure-builds/environment-variables/#build-metadata
    process.env.COMMIT_REF ||
    // Vercel - https://vercel.com/docs/v2/build-step#system-environment-variables
    process.env.VERCEL_GIT_COMMIT_SHA ||
    process.env.VERCEL_GITHUB_COMMIT_SHA ||
    process.env.VERCEL_GITLAB_COMMIT_SHA ||
    process.env.VERCEL_BITBUCKET_COMMIT_SHA ||
    // Zeit (now known as Vercel)
    process.env.ZEIT_GITHUB_COMMIT_SHA ||
    process.env.ZEIT_GITLAB_COMMIT_SHA ||
    process.env.ZEIT_BITBUCKET_COMMIT_SHA ||
  1. and then falls back to undefined

Browser SDK tries:

  1. the SENTRY_RELEASE global var injected by bundlers (like webpack plugin): https://github.com/getsentry/sentry-javascript/blob/411b0fa069e7faf8cc4d782cd21a118f909aefdf/packages/browser/src/sdk.ts#L98
  2. and then falls back to undefined

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants