instana-haskell-trace-sdk 0.3.0.0 → 0.4.0.0
raw patch · 22 files changed
+29/−117 lines, 22 files
Files
- CONTRIBUTING.md +7/−3
- ChangeLog.md +3/−0
- README.md +9/−4
- instana-haskell-trace-sdk.cabal +1/−1
- src/Instana/SDK/Config.hs +0/−7
- src/Instana/SDK/Internal/AgentConnection/AgentHostLookup.hs +3/−3
- src/Instana/SDK/Internal/Config.hs +0/−21
- src/Instana/SDK/Internal/Id.hs +0/−1
- src/Instana/SDK/Internal/Logging.hs +0/−1
- src/Instana/SDK/Internal/Retry.hs +0/−1
- src/Instana/SDK/Internal/Worker.hs +0/−1
- src/Instana/SDK/SDK.hs +1/−3
- src/Instana/SDK/Span/Span.hs +0/−1
- test/agent-stub/Instana/SDK/AgentStub/Config.hs +0/−3
- test/agent-stub/Instana/SDK/AgentStub/Server.hs +4/−6
- test/integration/Instana/SDK/IntegrationTest/Connection.hs +0/−13
- test/integration/Instana/SDK/IntegrationTest/Metrics.hs +1/−1
- test/integration/Instana/SDK/IntegrationTest/Runner.hs +0/−2
- test/integration/Instana/SDK/IntegrationTest/Suite.hs +0/−8
- test/integration/Instana/SDK/IntegrationTest/TestHelper.hs +0/−1
- test/integration/Instana/SDK/IntegrationTest/TestSuites.hs +0/−13
- test/unit/Instana/SDK/Internal/ConfigTest.hs +0/−23
CONTRIBUTING.md view
@@ -52,7 +52,6 @@ * `HOST` (default: `127.0.0.1`): The bind address of the agent stub. `127.0.0.1` is usually fine, but you can also use for example `*4` to bind to any IPv4 or IPv6 hostname, IPv4 preferred. See <https://hackage.haskell.org/package/warp-3.2.9/docs/Network-Wai-Handler-Warp.html#t:HostPreference>. * `PORT` (default: `1302`): The port to bind to.-* `AGENT_NAME` (default: `Instana Agent`): Will be included in the response to `GET /` as the `Server` header. * `STARTUP_DELAY` (default: `0`): An artificial startup delay in milliseconds, used for integration testing. * `SIMULATE_CONNECTION_LOSS` (default: `false`): Used for integration testing. * `SIMULATE_PID_TRANSLATION` (default: `false`): Used for integration testing.@@ -66,6 +65,11 @@ * `instana-haskell-trace-sdk.cabal` * `package.yaml` * `test/integration/Instana/SDK/IntegrationTest/Metrics.hs` (assertion for `sensorVersion`)-* Commit this change with a commit comment like `chore: version a.b.c.d`-* Build the package with stack and upload it to Hackage.+* Commit and push this change with a commit comment like `chore: version a.b.c.d`+* Build the package with stack and upload it to Hackage:+ * `stack haddock && stack sdist && stack upload --no-signature .` +Actually, the Hackage server should build the haddock docs after the package has been uploaded and add it to the package version. You can check if this has worked - if the individual modules on <http://hackage.haskell.org/package/instana-haskell-trace-sdk> are links to the documentation, it worked. Legend has it that this takes a few minutes - you could theoretically wait to see if the docs show up. Most of the times this does not actually work for reasons unknown. In these cases you can build the docs manually in the format Hackage expects and upload them for an already published package version by running+```+bin/build-and-upload-docs.sh+```
ChangeLog.md view
@@ -1,5 +1,8 @@ # Changelog for instana-haskell-trace-sdk +## 0.4.0.0+- Accomodate for breaking changes in `network-3.0.0.0`.+ ## 0.3.0.0 - Honor the environment variable `INSTANA_SERVICE_NAME` to override the default service name in Instana. - Add a configuration option for overriding the default service name in Instana.
README.md view
@@ -1,4 +1,4 @@-# Instana Haskell Trace SDK [](https://travis-ci.org/instana/haskell-trace-sdk)+# Instana Haskell Trace SDK [](https://travis-ci.org/instana/haskell-trace-sdk) Monitor your Haskell application with [Instana](https://www.instana.com/)! 🎉 @@ -19,9 +19,15 @@ ``` extra-deps:-- instana-haskell-trace-sdk-0.3.0.0+- instana-haskell-trace-sdk-0.4.0.0 ``` +Depending on the stack resolver you use, you might also need to add `aeson-extra` to your extra-deps:++```+- aeson-extra-0.4.1.3@sha256:8ad8e4d28e46280ea98af2e94dcaaf524c396c9d91b1eba867961efc6e7f923f,2997+```+ Usage ----- @@ -163,7 +169,6 @@ * `INSTANA_AGENT_HOST`: The IP or the host of the Instana agent to connect to. Default: 127.0.0.1. * `INSTANA_AGENT_PORT`: The port of the Instana agent to connect to. Default: 42699.-* `INSTANA_AGENT_NAME`: When establishing a connection to the Instana agent, the SDK validates the Instana agent's `Server` HTTP response header. Should you have changed the Server name on the agent side, you can use this environment variable to provide the name to match that header against. * `INSTANA_SERVICE_NAME`: Override the default service name in Instana. * `INSTANA_FORCE_TRANSMISSION_STARTING_AFTER`: Spans are usually buffered before being transmitted to the agent. This setting forces the transmission of all buffered spans after the given amount of milliseconds. Default: 1000. * `INSTANA_FORCE_TRANSMISSION_STARTING_AT`: This setting forces the transmission of all buffered spans when the given number of spans has been buffered.@@ -221,5 +226,5 @@ Contributing ------------ -See [CONTRIBUTING.md](https://github.com/instana/haskell-trace-sdk/blob/master/CONTRIBUTING.md).+See [CONTRIBUTING.md](https://github.com/instana/haskell-trace-sdk/blob/main/CONTRIBUTING.md).
instana-haskell-trace-sdk.cabal view
@@ -1,5 +1,5 @@ name: instana-haskell-trace-sdk-version: 0.3.0.0+version: 0.4.0.0 synopsis: SDK for adding custom Instana tracing support to Haskell applications. description: Please also see the README on Github at <https://github.com/instana/haskell-trace-sdk#readme> homepage: https://www.instana.com/
src/Instana/SDK/Config.hs view
@@ -8,7 +8,6 @@ ( Config , agentHost , agentPort- , agentName , defaultConfig , forceTransmissionAfter , forceTransmissionStartingAt@@ -29,11 +28,6 @@ agentHost :: Maybe String -- | Port of the Instana agent , agentPort :: Maybe Int- -- | When establishing a connection to the Instana agent, the SDK validates- -- the Instana agent's `Server` HTTP response header. Should you have- -- changed the Server name on the agent side, you can use parameter to- -- provide the name to match that header against.- , agentName :: Maybe String -- | Overrides the default service name that is used in Instana. , serviceName :: Maybe String -- | Spans are usually buffered before being transmitted to the agent. This@@ -60,7 +54,6 @@ Config { agentHost = Nothing , agentPort = Nothing- , agentName = Nothing , serviceName = Nothing , forceTransmissionAfter = Nothing , forceTransmissionStartingAt = Nothing
src/Instana/SDK/Internal/AgentConnection/AgentHostLookup.hs view
@@ -114,8 +114,7 @@ -> IO (Either String SuccessfullHost) tryHost context host port = do let- config = InternalContext.config context- expectedServerHeader = InternalConfig.agentName config+ expectedServerHeader = "Instana Agent" manager = InternalContext.httpManager context agentRootUrl = URL.mkHttp host port "" debugM instanaLogger $ "Trying to reach agent at " ++ show agentRootUrl@@ -135,7 +134,8 @@ else do return $ Left $ "Host at " ++ show agentRootUrl ++ " did not respond with " ++- "expected agent header but with: " ++ show serverHeaderValue+ "expected Server header (" ++ expectedServerHeader +++ ") but with: " ++ show serverHeaderValue ) (\e -> do let
src/Instana/SDK/Internal/Config.hs view
@@ -36,11 +36,6 @@ agentPortKey = "INSTANA_AGENT_PORT" --- |Environment variable for the agent name (server header)-agentNameKey :: String-agentNameKey = "INSTANA_AGENT_NAME"-- -- |Environment variable for the service name override. serviceNameKey :: String serviceNameKey = "INSTANA_SERVICE_NAME"@@ -71,11 +66,6 @@ defaultAgentPort = 42699 --- |Default agent name-defaultAgentName :: String-defaultAgentName = "Instana Agent"-- -- |Default force-transmission-after setting defaultForceTransmissionAfter :: Int defaultForceTransmissionAfter = 1000@@ -96,7 +86,6 @@ data FinalConfig = FinalConfig { agentHost :: String , agentPort :: Int- , agentName :: String , serviceName :: Maybe String , forceTransmissionAfter :: Int , forceTransmissionStartingAt :: Int@@ -108,7 +97,6 @@ mkFinalConfig :: String -> Int- -> String -> Maybe String -> Int -> Int@@ -117,7 +105,6 @@ mkFinalConfig agentHost_ agentPort_- agentName_ serviceName_ forceTransmissionAfter_ forceTransmissionStartingAt_@@ -125,7 +112,6 @@ FinalConfig { agentHost = agentHost_ , agentPort = agentPort_- , agentName = agentName_ , serviceName = serviceName_ , forceTransmissionAfter = forceTransmissionAfter_ , forceTransmissionStartingAt = forceTransmissionStartingAt_@@ -138,7 +124,6 @@ readConfigFromEnvironment = do agentHostEnv <- lookupEnv agentHostKey agentPortEnv <- lookupEnv agentPortKey- agentNameEnv <- lookupEnv agentNameKey serviceNameEnv <- lookupEnv serviceNameKey forceTransmissionAfterEnv <- lookupEnv forceTransmissionAfterKey forceTransmissionStartingAtEnv <- lookupEnv forceTransmissionStartingAtKey@@ -156,7 +141,6 @@ Config.defaultConfig { Config.agentHost = agentHostEnv , Config.agentPort = agentPortParsed- , Config.agentName = agentNameEnv , Config.serviceName = serviceNameEnv , Config.forceTransmissionAfter = forceTransmissionAfterParsed , Config.forceTransmissionStartingAt = forceTransmissionStartingAtParsed@@ -180,8 +164,6 @@ fromMaybe defaultAgentHost (Config.agentHost config) , agentPort = fromMaybe defaultAgentPort (Config.agentPort config)- , agentName =- fromMaybe defaultAgentName (Config.agentName config) , serviceName = Config.serviceName config , forceTransmissionAfter = fromMaybe@@ -209,9 +191,6 @@ , Config.agentPort = (Config.agentPort userConfig) <|> (Config.agentPort configFromEnv)- , Config.agentName =- (Config.agentName userConfig) <|>- (Config.agentName configFromEnv) , Config.serviceName = (Config.serviceName userConfig) <|> (Config.serviceName configFromEnv)
src/Instana/SDK/Internal/Id.hs view
@@ -22,7 +22,6 @@ import qualified Data.Aeson as Aeson import Data.Aeson.Types (Parser) import qualified Data.ByteString.Char8 as BSC8-import Data.List (foldl) import Data.Text (Text) import qualified Data.Text as T import GHC.Generics
src/Instana/SDK/Internal/Logging.hs view
@@ -16,7 +16,6 @@ import Control.Monad (when) import Data.Maybe (catMaybes, isJust)-import Data.Traversable (sequence) import System.Directory (getTemporaryDirectory) import System.Environment (lookupEnv) import System.IO (Handle, stdout)
src/Instana/SDK/Internal/Retry.hs view
@@ -16,7 +16,6 @@ import Control.Monad.Catch (Handler) import qualified Control.Retry as Retry import Data.ByteString.Lazy (ByteString)-import Data.Semigroup ((<>)) import qualified Network.HTTP.Client as HTTP
src/Instana/SDK/Internal/Worker.hs view
@@ -19,7 +19,6 @@ when) import qualified Data.Aeson as Aeson import Data.Foldable (toList)-import Data.List (map) import Data.Sequence ((|>)) import qualified Data.Sequence as Seq import qualified Data.Text as T
src/Instana/SDK/SDK.hs view
@@ -18,7 +18,6 @@ , addTagAt , addToErrorCount , agentHost- , agentName , agentPort , completeEntry , completeExit@@ -186,8 +185,7 @@ , HTTP.managerRawConnection = HTTP.rawConnectionModifySocket (\socket -> do- let- fileDescriptorFromSocket = Socket.fdSocket socket+ fileDescriptorFromSocket <- Socket.unsafeFdSocket socket STM.atomically $ STM.writeTVar fileDescriptor (Just fileDescriptorFromSocket) )
src/Instana/SDK/Span/Span.hs view
@@ -29,7 +29,6 @@ import qualified Data.Aeson as Aeson import qualified Data.List as List import Data.Text as T-import Data.Text (Text) import GHC.Generics import Instana.SDK.Internal.Id (Id)
test/agent-stub/Instana/SDK/AgentStub/Config.hs view
@@ -17,7 +17,6 @@ data AgentStubConfig = AgentStubConfig { bindHost :: Warp.HostPreference , bindPort :: Int- , agentName :: String , startupDelay :: Int , simulateConnectionLoss :: Bool , simulatPidTranslation :: Bool@@ -33,7 +32,6 @@ -- incoming connections every time the app is recompiled and restarted. hostString <- lookupEnvWithDefault "HOST" "127.0.0.1" port <- lookupEnvIntWithDefault "PORT" 1302- name <- lookupEnvWithDefault "AGENT_NAME" "Instana Agent" delay <- lookupEnvIntWithDefault "STARTUP_DELAY" 0 connectionLoss <- lookupFlag "SIMULATE_CONNECTION_LOSS" pidTranslation <- lookupFlag "SIMULATE_PID_TRANSLATION"@@ -44,7 +42,6 @@ AgentStubConfig { bindHost = hostPreference , bindPort = port- , agentName = name , startupDelay = delay , simulateConnectionLoss = connectionLoss , simulatPidTranslation = pidTranslation
test/agent-stub/Instana/SDK/AgentStub/Server.hs view
@@ -42,7 +42,7 @@ -> Recorders -> Servant.Server API mainServer config startupTime recorders =- getRoot config+ getRoot :<|> putDiscovery config startupTime recorders :<|> headAgentReady config startupTime recorders :<|> postEntityData config startupTime recorders@@ -50,11 +50,9 @@ :<|> StubServer.stubServer recorders -getRoot ::- AgentStubConfig- -> Servant.Handler (Headers '[Header "Server" String] NoContent)-getRoot config =- return $ Servant.addHeader (Config.agentName config) NoContent+getRoot :: Servant.Handler (Headers '[Header "Server" String] NoContent)+getRoot =+ return $ Servant.addHeader "Instana Agent" NoContent putDiscovery ::
test/integration/Instana/SDK/IntegrationTest/Connection.hs view
@@ -4,7 +4,6 @@ , shouldReestablishLostConnection , shouldReconnectAfterAgentRestart , shouldUseTranslatedPid- , shouldUseCustomAgentName ) where @@ -197,15 +196,3 @@ assertAllIO $ [ assertEqual "entry from" from $ TraceRequest.f entrySpan ]---shouldUseCustomAgentName :: String -> IO Test-shouldUseCustomAgentName _ =- return $- TestLabel "shouldUseCustomAgentName" $- TestCase $- -- no actuall assertions needed, the fact that this function is executed- -- is already proof that the connection to the agent stub has been- -- established in spite of the custom agent name parameter.- return ()-
test/integration/Instana/SDK/IntegrationTest/Metrics.hs view
@@ -51,7 +51,7 @@ (EntityDataRequest.arguments entityData) , assertLabelIs "sensorVersion"- "0.3.0.0"+ "0.4.0.0" (EntityDataRequest.sensorVersion entityData) , assertCounterSatisfies "startTime"
test/integration/Instana/SDK/IntegrationTest/Runner.hs view
@@ -94,7 +94,6 @@ buildCommand [ ("SIMULATE_PID_TRANSLATION", booleanEnv $ Suite.usePidTranslation options)- , ("AGENT_NAME", Suite.customAgentName options) , ("STARTUP_DELAY", (if Suite.startupDelay options then Just "2500" else Nothing)) , ("SIMULATE_CONNECTION_LOSS",@@ -105,7 +104,6 @@ appCommand = buildCommand [ ("APP_LOG_LEVEL", Just logLevel)- , ("INSTANA_AGENT_NAME", Suite.customAgentName options) , ("INSTANA_SERVICE_NAME", Suite.customServiceName options) , ("INSTANA_LOG_LEVEL", Just logLevel) ]
test/integration/Instana/SDK/IntegrationTest/Suite.hs view
@@ -5,7 +5,6 @@ , defaultOptions , isExclusive , withConnectionLoss- , withCustomAgentName , withCustomServiceName , withPidTranslation , withStartupDelay@@ -28,7 +27,6 @@ data SuiteOptions = SuiteOptions { usePidTranslation :: Bool- , customAgentName :: Maybe String , startupDelay :: Bool , simulateConnectionLoss :: Bool , appUnderTest :: String@@ -40,7 +38,6 @@ defaultOptions = SuiteOptions { usePidTranslation = False- , customAgentName = Nothing , startupDelay = False , simulateConnectionLoss = False , appUnderTest = "instana-haskell-test-wai-server"@@ -51,11 +48,6 @@ withPidTranslation :: SuiteOptions withPidTranslation = defaultOptions { usePidTranslation = True }---withCustomAgentName :: String -> SuiteOptions-withCustomAgentName agentName =- defaultOptions { customAgentName = Just agentName } withStartupDelay :: SuiteOptions
test/integration/Instana/SDK/IntegrationTest/TestHelper.hs view
@@ -23,7 +23,6 @@ import Control.Exception (catch) import qualified Data.ByteString.Lazy as LBS-import Data.Either (Either) import qualified Data.List as List import qualified Data.Maybe as Maybe import Data.Text (Text)
test/integration/Instana/SDK/IntegrationTest/TestSuites.hs view
@@ -21,7 +21,6 @@ , testConnectionLoss , testAgentRestart , testPidTranslation- , testCustomAgentName , testServiceName , testHttpTracing , testWaiMiddleware@@ -115,18 +114,6 @@ [ ServiceName.shouldUseServiceNameEnvVar pid ]) , Suite.options = Suite.withCustomServiceName "Custom Service Name"- }---testCustomAgentName :: ConditionalSuite-testCustomAgentName =- Run $- Suite- { Suite.label = "Custom Agent Name"- , Suite.tests = (\pid -> [- Connection.shouldUseCustomAgentName pid- ])- , Suite.options = Suite.withCustomAgentName "Devil in Disguise" }
test/unit/Instana/SDK/Internal/ConfigTest.hs view
@@ -41,11 +41,6 @@ "agent host" "127.0.0.1" (InternalConfig.agentHost merged) , TestCase $ assertEqual "agent port" 42699 (InternalConfig.agentPort merged)- , TestCase $- assertEqual- "agent name"- "Instana Agent"- (InternalConfig.agentName merged) ] @@ -56,13 +51,11 @@ Config.defaultConfig { Config.agentHost = Just "horst" , Config.agentPort = Just 12345- , Config.agentName = Just "Hans" } second = Config.defaultConfig { Config.agentHost = Just "wurst" , Config.agentPort = Just 98765- , Config.agentName = Just "Franz" } merged = InternalConfig.mergeConfigs first second in@@ -72,11 +65,6 @@ "agent host" "horst" (InternalConfig.agentHost merged) , TestCase $ assertEqual "agent port" 12345 (InternalConfig.agentPort merged)- , TestCase $- assertEqual- "agent name"- "Hans"- (InternalConfig.agentName merged) ] @@ -87,7 +75,6 @@ conf <- InternalConfig.readConfigFromEnvironment assertBool "agent host" (isNothing $ Config.agentHost conf) assertBool "agent port" (isNothing $ Config.agentPort conf)- assertBool "agent name" (isNothing $ Config.agentName conf) shouldReadExistingEnvironmentVariables :: Test@@ -96,17 +83,11 @@ do setEnv "INSTANA_AGENT_HOST" "agenthost.com" setEnv "INSTANA_AGENT_PORT" "12345"- setEnv "INSTANA_AGENT_NAME" "Say my name, say my name" conf <- InternalConfig.readConfigFromEnvironment assertEqual "agent host" (Just "agenthost.com") (Config.agentHost conf) assertEqual "agent port" (Just 12345) (Config.agentPort conf)- assertEqual- "agent name"- (Just "Say my name, say my name")- (Config.agentName conf) unsetEnv "INSTANA_AGENT_HOST" unsetEnv "INSTANA_AGENT_PORT"- unsetEnv "INSTANA_AGENT_NAME" shouldReadNonNumericPortAsNothing :: Test@@ -126,10 +107,6 @@ conf <- InternalConfig.readConfigFromEnvironmentAndApplyDefaults assertEqual "agent host" "127.0.0.1" (InternalConfig.agentHost conf) assertEqual "agent port" 42699 (InternalConfig.agentPort conf)- assertEqual- "agent name"- "Instana Agent"- (InternalConfig.agentName conf) emptyConfig :: Config