instana-haskell-trace-sdk 0.7.0.0 → 0.7.1.0
raw patch · 7 files changed
+165/−19 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−1
- CONTRIBUTING.md +1/−1
- README.md +1/−6
- instana-haskell-trace-sdk.cabal +1/−1
- src/Instana/SDK/Internal/W3CTraceContext.hs +26/−9
- test/integration/Instana/SDK/IntegrationTest/Metrics.hs +1/−1
- test/unit/Instana/SDK/Internal/W3CTraceContextTest.hs +131/−0
CHANGELOG.md view
@@ -1,6 +1,9 @@ # Changelog for instana-haskell-trace-sdk -## 0.7.00+## 0.7.1.0+- Fix: Limit the number of list-members (key-value pairs) to 32 in the W3C trace context `tracestate` header.++## 0.7.0.0 - Add support for W3C trace context. - Fix: Interprete log levels provided via `INSTANA_LOG_LEVEL` and `INSTANA_LOG_LEVEL_STDOUT` case insensitive.
CONTRIBUTING.md view
@@ -70,7 +70,7 @@ * Wait for the CI build for branch main. * Build the package with stack and upload it to Hackage: * `stack haddock && stack sdist && stack upload .`- * Checkt that the package version is available on <http://hackage.haskell.org/package/instana-haskell-trace-sdk>.+ * Check that the package version is available on <http://hackage.haskell.org/package/instana-haskell-trace-sdk>. * Run `bin/build-and-upload-docs.sh` to upload the haddock documentation. Legend has it that the Hackage server should build the haddock docs after the package has been uploaded and add it to the package version. You could 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. Allegedly, this takes a few minutes. In fact, this has never worked once, for reasons unknown. The script `bin/build-and-upload-docs.sh` takes care of that.
README.md view
@@ -3,11 +3,6 @@ Monitor your Haskell application with [Instana](https://www.instana.com/)! 🎉 -Disclaimer-------------The Instana Haskell Trace SDK is a labor of love from some of our engineers and work on it is done in their spare time. Haskell is currently not a platform that we officialy support. The experience may differ from other programming languages and platforms that Instana actively supports (such as Java, .NET, Node.js, Python, Ruby, Go, PHP, ...). That said, the SDK is a fully functional piece of software, so don't let this disclaimer discourage you from using it. If you use Instana or consider using it and Haskell support is crucial for you, make sure to give us a ping and let's talk about it.- What The Haskell Trace SDK Is And What It Is Not ------------------------------------------------ @@ -20,7 +15,7 @@ ``` extra-deps:-- instana-haskell-trace-sdk-0.7.0.0+- instana-haskell-trace-sdk-0.7.1.0 ``` Depending on the stack resolver you use, you might also need to add `aeson-extra` to your extra-deps:
instana-haskell-trace-sdk.cabal view
@@ -1,5 +1,5 @@ name: instana-haskell-trace-sdk-version: 0.7.0.0+version: 0.7.1.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/Internal/W3CTraceContext.hs view
@@ -77,6 +77,10 @@ } deriving (Eq, Generic, Show) +maxKeyValuePairsTraceState :: Int+maxKeyValuePairsTraceState = 32++ -- |Decodes the raw values of traceparent and tracestate to the parsed -- representation of the W3C trace context. If the traceparent value is invalid, -- Nothing will be returned.@@ -218,7 +222,7 @@ decodeNonEmptyTraceState traceStateText = let keyValuePairs = map T.strip $ T.splitOn "," traceStateText- inKvPairIndex =+ instanaKvPairIndex = List.findIndex (\kvPairString -> let key = T.strip $ fst $ T.breakOn "=" kvPairString@@ -227,26 +231,39 @@ ) keyValuePairs (tsHead, inKvPair, tsTail) =- case inKvPairIndex of+ case instanaKvPairIndex of Just idx -> let- preIdx = take idx keyValuePairs+ -- Use at most 31 non-Instana key-value pairs plus the Instana+ -- key-value pair, since 32 key-value pairs is the limit imposed by+ -- the W3C trace context spec.+ numKvPairsBeforeInstanaKvPair =+ min (maxKeyValuePairsTraceState - 1) idx+ maxKvPairsAfterInstanaKvPair =+ maxKeyValuePairsTraceState - numKvPairsBeforeInstanaKvPair - 1+ kvPairsBeforeInstanaKvPair =+ take numKvPairsBeforeInstanaKvPair keyValuePairs+ allKvPairsAfterInstanaKvPair = drop (idx + 1) keyValuePairs+ limitedKvPairsAfterInstanaKvPair =+ take maxKvPairsAfterInstanaKvPair allKvPairsAfterInstanaKvPair tsHd =- if null preIdx+ if null kvPairsBeforeInstanaKvPair then Nothing- else Just $ T.intercalate "," preIdx+ else Just $ T.intercalate "," kvPairsBeforeInstanaKvPair tsTl =- if null postIdx+ if null limitedKvPairsAfterInstanaKvPair then Nothing- else Just $ T.intercalate "," postIdx- postIdx = drop (idx + 1) keyValuePairs+ else Just $ T.intercalate "," limitedKvPairsAfterInstanaKvPair in ( tsHd , decodeInKeyValuePair $ keyValuePairs !! idx , tsTl ) Nothing ->- ( Just $ T.intercalate "," keyValuePairs+ -- Limit the number of key-value pairs in tracestate to 32 as per+ -- W3C trace context spec.+ ( Just $+ T.intercalate "," (take maxKeyValuePairsTraceState keyValuePairs) , Nothing , Nothing )
test/integration/Instana/SDK/IntegrationTest/Metrics.hs view
@@ -51,7 +51,7 @@ (EntityDataRequest.arguments entityData) , assertLabelIs "sensorVersion"- "0.7.0.0"+ "0.7.1.0" (EntityDataRequest.sensorVersion entityData) , assertCounterSatisfies "startTime"
test/unit/Instana/SDK/Internal/W3CTraceContextTest.hs view
@@ -86,6 +86,21 @@ "shouldDecodeTraceStateWithWhitespace" shouldDecodeTraceStateWithWhitespace , TestLabel+ "shouldDiscardExcessTraceStateListMembersWithoutInstanaKeyValuePair"+ shouldDiscardExcessTraceStateListMembersWithoutInstanaKeyValuePair+ , TestLabel+ "shouldDiscardExcessTraceStateListMembersWithInstanaKeyValuePair"+ shouldDiscardExcessTraceStateListMembersWithInstanaKeyValuePair+ , TestLabel+ "shouldDiscardExcessTraceStateListMembersWithInstanaKeyValuePairAt32"+ shouldDiscardExcessTraceStateListMembersWithInstanaKeyValuePairAt32+ , TestLabel+ "shouldDiscardExcessTraceStateListMembersWithInstanaKeyValuePairAt33"+ shouldDiscardExcessTraceStateListMembersWithInstanaKeyValuePairAt33+ , TestLabel+ "shouldDiscardExcessTraceStateListMembersWithInstanaKeyValuePairAt66"+ shouldDiscardExcessTraceStateListMembersWithInstanaKeyValuePairAt66+ , TestLabel "shouldDiscardMalformedInstanaKeyValuePair" shouldDiscardMalformedInstanaKeyValuePair , TestLabel@@ -369,6 +384,122 @@ in TestCase $ do assertEqual "Trace State" expected actual+++shouldDiscardExcessTraceStateListMembersWithoutInstanaKeyValuePair :: Test+shouldDiscardExcessTraceStateListMembersWithoutInstanaKeyValuePair =+ let+ actual =+ parseAndExtractTraceState $ Just $ T.unpack $ longTraceStateList 1 34+ expected = traceState $+ withTraceState+ defaultTraceParent+ ( Just $ longTraceStateList 1 32 )+ Nothing+ Nothing+ in+ TestCase $ do+ assertEqual "Trace State" expected actual+++shouldDiscardExcessTraceStateListMembersWithInstanaKeyValuePair :: Test+shouldDiscardExcessTraceStateListMembersWithInstanaKeyValuePair =+ let+ actual =+ parseAndExtractTraceState $ Just $+ (T.unpack $ longTraceStateList 1 10) +++ ",in=fa2375d711a4ca0f;02468acefdb97531," +++ (T.unpack $ longTraceStateList 12 34)+ expected = traceState $+ withTraceState+ defaultTraceParent+ ( Just $ longTraceStateList 1 10 )+ ( Just $ InstanaKeyValuePair+ { instanaTraceId = "fa2375d711a4ca0f"+ , instanaParentId = "02468acefdb97531"+ }+ )+ ( Just $ longTraceStateList 12 32 )+ in+ TestCase $ do+ assertEqual "Trace State" expected actual+++shouldDiscardExcessTraceStateListMembersWithInstanaKeyValuePairAt32 :: Test+shouldDiscardExcessTraceStateListMembersWithInstanaKeyValuePairAt32 =+ let+ actual =+ parseAndExtractTraceState $ Just $+ (T.unpack $ longTraceStateList 1 31) +++ ",in=fa2375d711a4ca0f;02468acefdb97531," +++ (T.unpack $ longTraceStateList 33 34)+ expected = traceState $+ withTraceState+ defaultTraceParent+ ( Just $ longTraceStateList 1 31 )+ ( Just $ InstanaKeyValuePair+ { instanaTraceId = "fa2375d711a4ca0f"+ , instanaParentId = "02468acefdb97531"+ }+ )+ Nothing+ in+ TestCase $ do+ assertEqual "Trace State" expected actual+++shouldDiscardExcessTraceStateListMembersWithInstanaKeyValuePairAt33 :: Test+shouldDiscardExcessTraceStateListMembersWithInstanaKeyValuePairAt33 =+ let+ actual =+ parseAndExtractTraceState $ Just $+ (T.unpack $ longTraceStateList 1 32) +++ ",in=fa2375d711a4ca0f;02468acefdb97531," +++ (T.unpack $ longTraceStateList 34 35)+ expected = traceState $+ withTraceState+ defaultTraceParent+ ( Just $ longTraceStateList 1 31 )+ ( Just $ InstanaKeyValuePair+ { instanaTraceId = "fa2375d711a4ca0f"+ , instanaParentId = "02468acefdb97531"+ }+ )+ Nothing+ in+ TestCase $ do+ assertEqual "Trace State" expected actual+++shouldDiscardExcessTraceStateListMembersWithInstanaKeyValuePairAt66 :: Test+shouldDiscardExcessTraceStateListMembersWithInstanaKeyValuePairAt66 =+ let+ actual =+ parseAndExtractTraceState $ Just $+ (T.unpack $ longTraceStateList 1 65) +++ ",in=fa2375d711a4ca0f;02468acefdb97531," +++ (T.unpack $ longTraceStateList 67 99)+ expected = traceState $+ withTraceState+ defaultTraceParent+ ( Just $ longTraceStateList 1 31 )+ ( Just $ InstanaKeyValuePair+ { instanaTraceId = "fa2375d711a4ca0f"+ , instanaParentId = "02468acefdb97531"+ }+ )+ Nothing+ in+ TestCase $ do+ assertEqual "Trace State" expected actual+++longTraceStateList :: Int -> Int -> Text+longTraceStateList from to =+ T.intercalate+ ","+ [ T.pack $+ "member" ++ show i ++ "=" ++ show i | i <- [from..to] ] shouldDiscardMalformedInstanaKeyValuePair :: Test