Skip to content

Commit

Permalink
Split off parsing logic from getSemConvStabilityOptIn to parseSemConv…
Browse files Browse the repository at this point in the history
…StabilityOptIn
  • Loading branch information
evanlauer1 committed May 22, 2024
1 parent d8771ed commit 76f062e
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions api/src/OpenTelemetry/SemConvStabilityOptIn.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ import System.Environment (lookupEnv)
data SemConvStabilityOptIn = Stable | Both | Old deriving (Show, Eq)


parseSemConvStabilityOptIn :: Maybe String -> SemConvStabilityOptIn
parseSemConvStabilityOptIn Nothing = Old
parseSemConvStabilityOptIn (Just env)
| "http/dup" `elem` envs = Both
| "http" `elem` envs = Stable
| otherwise = Old
where
envs = fmap T.strip . T.splitOn "," . T.pack $ env


getSemConvStabilityOptIn :: IO SemConvStabilityOptIn
getSemConvStabilityOptIn = do
menv <- lookupEnv "OTEL_SEMCONV_STABILITY_OPT_IN"
let menvs = fmap T.strip . T.splitOn "," . T.pack <$> menv
pure $ case menvs of
Nothing -> Old
Just envs ->
if "http/dup" `elem` envs
then Both
else
if "http" `elem` envs
then Stable
else Old
getSemConvStabilityOptIn = parseSemConvStabilityOptIn <$> lookupEnv "OTEL_SEMCONV_STABILITY_OPT_IN"

0 comments on commit 76f062e

Please sign in to comment.