packages feed

opentelemetry-plugin 1.1.0 → 1.1.1

raw patch · 4 files changed

+47/−11 lines, 4 filesnew-uploaderPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+# 1.1.1++- The plugin now records the package name in the `packageName` attribute on spans.+ # 1.1.0  - The plugin now records much more of the module's compilation. Previously, the
opentelemetry-plugin.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               opentelemetry-plugin-version:            1.1.0+version:            1.1.1 synopsis:           GHC plugin for open telemetry description:        This package provides a GHC plugin that exports each module's build times to an open telemetry collector.  See the included `README` below for more details. license:            BSD-3-Clause
src/OpenTelemetry/Plugin.hs view
@@ -87,8 +87,10 @@          Shared.setRootModuleNames rootModuleNames -        Shared.initializeTopLevelContext+        let packageName = getPackageName hscEnv +        Shared.initializeTopLevelContext packageName+         pure hscEnv             { hsc_hooks =                 (hsc_hooks hscEnv)@@ -101,7 +103,7 @@                                                 modSummary                                         modObjectLocation =                                             Plugins.ml_obj_file $ Plugins.ms_location modSummary-                                    Shared.recordModuleStart modObjectLocation modName+                                    Shared.recordModuleStart packageName modObjectLocation modName                                     runPhase phase                                 T_MergeForeign _pipeEnv _hscEnv objectFilePath _filePaths -> do                                     -- this phase appears to only be run@@ -163,3 +165,11 @@     pluginRecompile = Plugins.purePlugin  data ClosePhase = CloseInHscBackend | CloseInMergeForeign++getPackageName :: HscEnv -> Shared.PackageName+getPackageName =+    Shared.PackageName+        . Text.pack+        . Plugins.unitIdString+        . Plugins.homeUnitId_+        . Plugins.hsc_dflags
src/OpenTelemetry/Plugin/Shared.hs view
@@ -1,4 +1,6 @@ {-# LANGUAGE BlockArguments    #-}+{-# LANGUAGE DerivingStrategies    #-}+{-# LANGUAGE GeneralizedNewtypeDeriving    #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} @@ -22,6 +24,7 @@     , initializeTopLevelContext     , getTopLevelContext     , modifyContextWithParentSpan+    , PackageName (..)        -- * Root module names     , setRootModuleNames@@ -245,8 +248,10 @@ topLevelSpanMapMVar = Unsafe.unsafePerformIO MVar.newEmptyMVar {-# NOINLINE topLevelSpanMapMVar #-} -getTopLevelSpan :: IO Span-getTopLevelSpan = do+getTopLevelSpan+    :: PackageName+    -> IO Span+getTopLevelSpan packageName = do     traceParent <- lookupEnv "TRACEPARENT"     traceState_ <- lookupEnv "TRACESTATE" @@ -274,7 +279,11 @@              let arguments =                     Trace.defaultSpanArguments-                        { startTime = Just timestamp }+                        { startTime = Just timestamp+                        , attributes = HashMap.fromList+                            [ ("packageName", Trace.Core.toAttribute packageName)+                            ]+                        }              span <- Trace.createSpan tracer Context.empty "opentelemetry GHC plugin" arguments @@ -301,9 +310,11 @@     You have to run this command before calling `getTopLevelContext` otherwise     the latter will hang. -}-initializeTopLevelContext :: IO ()-initializeTopLevelContext = do-    span <- getTopLevelSpan+initializeTopLevelContext+    :: PackageName+    -> IO ()+initializeTopLevelContext packageName = do+    span <- getTopLevelSpan packageName      context <- getTopLevelBaggage @@ -423,17 +434,22 @@ -- | Create a 'Span' for the given 'ModSummary' and record it in the -- 'SpanMap'. recordModuleStart-    :: FilePath+    :: PackageName+    -> FilePath     -- ^ The location of the object file for the module. This should be     -- available through the 'ModSummary' via 'ms_location' and     -- 'ml_obj_file'     -> String     -- ^ A string representing the name of the module.     -> IO ()-recordModuleStart modObjectLocation modName = do+recordModuleStart packageName modObjectLocation modName = do     spanMap <- MVar.readMVar topLevelSpanMapMVar     context <- getTopLevelContext     span_ <- Trace.createSpan tracer context (Text.pack modName) Trace.defaultSpanArguments+        { attributes = HashMap.fromList+            [ ("packageName", Trace.Core.toAttribute packageName)+            ]+        }     let spanRelease =             SpanRelease                 { spanReleaseSpan =@@ -489,3 +505,9 @@         Trace.endSpan spanReleaseSpan Nothing         STM.atomically spanReleaseAction         flushMetricsWhenRootModule spanReleaseModuleName++-- | The name of the package that is being compiled.+newtype PackageName = PackageName+    { unPackageName :: Text+    }+    deriving newtype Trace.Core.ToAttribute