Skip to content

fix: Adjust the Sentry release property format according to the docs #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions sentry/src/main/scala/com/avast/sst/sentry/SentryModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,20 @@ object SentryModule {
}

/** Makes [[io.sentry.SentryClient]] initialized with the given config and overrides the `release` property
* with `Implementation-Version` from the `MANIFEST.MF` file inside the same JAR (package) as the `Main` class.
* with `Implementation-Title`@`Implementation-Version` from the `MANIFEST.MF` file inside the same JAR (package) as the `Main` class.
*
* This format is recommended by Sentry ([[https://docs.sentry.io/workflow/releases]])
* because releases are global and must be differentiated.
*/
def makeWithReleaseFromPackage[F[_]: Sync, Main: ClassTag](config: SentryConfig): Resource[F, SentryClient] = {
for {
customizedConfig <- Resource.liftF {
Sync[F].delay {
for {
pkg <- Option(implicitly[ClassTag[Main]].runtimeClass.getPackage)
v <- Option(pkg.getImplementationVersion)
} yield config.copy(release = Some(v))
title <- Option(pkg.getImplementationTitle)
version <- Option(pkg.getImplementationVersion)
} yield config.copy(release = Some(s"$title@$version"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this correctly, release will not be set if ImplementationTitle or ImplementationVersion is missing, right?

I have never set Implementation-Title - maybe it's my fault. I would consider to fallback to pkg.getName.

}
}
sentryClient <- make[F](customizedConfig.getOrElse(config))
Expand Down