Skip to content

Commit

Permalink
fix: unix -> unix-compat, minus getpwuid ref
Browse files Browse the repository at this point in the history
Works around compilation failure on Windows caused by the
lack of getpwuid function in there.

#109
  • Loading branch information
develop7 committed Mar 11, 2024
1 parent 02653bb commit deb41df
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 19 deletions.
4 changes: 3 additions & 1 deletion sdk/hs-opentelemetry-sdk.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 1.22

-- This file has been generated from package.yaml by hpack version 0.35.2.
-- This file has been generated from package.yaml by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack

Expand Down Expand Up @@ -85,6 +85,7 @@ library
, transformers
, unagi-chan
, unix
, unix-compat >=0.7.1
, unordered-containers
, vector
, vector-builder
Expand Down Expand Up @@ -121,6 +122,7 @@ test-suite hs-opentelemetry-sdk-test
, transformers
, unagi-chan
, unix
, unix-compat >=0.7.1
, unordered-containers
, vector
, vector-builder
Expand Down
2 changes: 1 addition & 1 deletion sdk/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies:
- vector-builder
- http-types
- network-bsd
- unix
- unix-compat >= 0.7.1 # for getProcessID
- transformers
- random >= 1.2.0

Expand Down
19 changes: 2 additions & 17 deletions sdk/src/OpenTelemetry/Resource/Process/Detector.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module OpenTelemetry.Resource.Process.Detector where

import Control.Exception (throwIO, try)
import qualified Data.Text as T
import Data.Version
import OpenTelemetry.Resource.Process
Expand All @@ -9,10 +8,8 @@ import System.Environment (
getExecutablePath,
getProgName,
)
import System.IO.Error
import System.Info
import System.Posix.Process (getProcessID)
import System.Posix.User (getEffectiveUserName)
import System.PosixCompat.Process (getProcessID)


{- | Create a 'Process' 'Resource' based off of the current process' knowledge
Expand All @@ -29,19 +26,7 @@ detectProcess = do
<*> pure Nothing
<*> pure Nothing
<*> (Just . map T.pack <$> getArgs)
<*> tryGetUser


tryGetUser :: IO (Maybe T.Text)
tryGetUser = do
eResult <- try getEffectiveUserName
case eResult of
Left err ->
if isDoesNotExistError err
then pure Nothing
else throwIO err
Right ok -> pure $ Just $ T.pack ok

<*> pure Nothing -- TODO: fix current user name detection on Windows

{- | A 'ProcessRuntime' 'Resource' populated with the current process' knoweldge
of itself.
Expand Down
1 change: 1 addition & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ packages:
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
#
extra-deps:
- unix-compat-0.7.1@sha256:bd5bb4e04b2ed707f3e3466470a452354310389506cf0a7a73bf10e4d533f6d1,3619
- thread-utils-context-0.3.0.4
- thread-utils-finalizers-0.1.1.0
- proto-lens-0.7.1.1
Expand Down

0 comments on commit deb41df

Please sign in to comment.