forked from Colisweb/sbt-datadog
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [155] Update to zio-config v4.+ * Use Config.Error
- Loading branch information
Showing
2 changed files
with
9 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
...ing-provider/src/main/scala/com/guizmaii/datadog/zio/tracing/provider/TracingConfig.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
package com.guizmaii.datadog.zio.tracing.provider | ||
|
||
import zio.ZLayer | ||
import zio.config.ConfigDescriptor.boolean | ||
import zio.config.{ConfigDescriptor, ReadError, ZConfig} | ||
import zio.{ZLayer, Config, ConfigProvider} | ||
import zio.Config._ | ||
|
||
sealed trait TracingConfig extends Product with Serializable | ||
object TracingConfig { | ||
case object Opentelemetry extends TracingConfig | ||
case object Disabled extends TracingConfig | ||
|
||
def config: ConfigDescriptor[TracingConfig] = | ||
val config: Config[TracingConfig] = | ||
boolean("ZIO_OPENTELEMETRY_DATADOG_ENABLED") | ||
.default(false) | ||
.transformOrFailLeft(enabled => if (enabled) Right(Opentelemetry) else Right(Disabled))(_ => false) | ||
.withDefault(false) | ||
.map(enabled => if (enabled) Opentelemetry else Disabled) | ||
|
||
/** | ||
* Provides a way to enable or disable the OpenTelemetry Tracing via the `ZIO_OPENTELEMETRY_DATADOG_ENABLED` environment variable. | ||
*/ | ||
def fromSystemEnv: ZLayer[Any, ReadError[String], TracingConfig] = ZConfig.fromSystemEnv(config) | ||
def fromSystemEnv: ZLayer[Any, Config.Error, TracingConfig] = | ||
ZLayer.fromZIO(ConfigProvider.envProvider.load(config)) | ||
} |