diff --git a/instrumentation/http-client/src/OpenTelemetry/Instrumentation/HttpClient/Raw.hs b/instrumentation/http-client/src/OpenTelemetry/Instrumentation/HttpClient/Raw.hs index 46b708ec..dfcec449 100644 --- a/instrumentation/http-client/src/OpenTelemetry/Instrumentation/HttpClient/Raw.hs +++ b/instrumentation/http-client/src/OpenTelemetry/Instrumentation/HttpClient/Raw.hs @@ -17,7 +17,7 @@ import Network.HTTP.Types import OpenTelemetry.Context (Context, lookupSpan) import OpenTelemetry.Context.ThreadLocal import OpenTelemetry.Propagator -import OpenTelemetry.SemConvStabilityOptIn +import OpenTelemetry.SemanticsConfig import OpenTelemetry.Trace.Core @@ -120,10 +120,10 @@ instrumentRequest conf ctxt req = do (\h -> (\v -> ("http.request.header." <> T.decodeUtf8 (foldedCase h), toAttribute (T.decodeUtf8 v))) <$> lookup h (requestHeaders req)) $ requestHeadersToRecord conf - semConvStabilityOptIn <- liftIO getSemConvStabilityOptIn - case semConvStabilityOptIn of + semanticsOptions <- liftIO getSemanticsOptions + case httpOption semanticsOptions of Stable -> addStableAttributes - Both -> addStableAttributes >> addOldAttributes + StableAndOld -> addStableAttributes >> addOldAttributes Old -> addOldAttributes hdrs <- inject (getTracerProviderPropagators $ getTracerTracerProvider tracer) ctxt $ requestHeaders req @@ -184,8 +184,8 @@ instrumentResponse conf ctxt resp = do (\h -> (\v -> ("http.response.header." <> T.decodeUtf8 (foldedCase h), toAttribute (T.decodeUtf8 v))) <$> lookup h (responseHeaders resp)) $ responseHeadersToRecord conf - semConvStabilityOptIn <- liftIO getSemConvStabilityOptIn - case semConvStabilityOptIn of + semanticsOptions <- liftIO getSemanticsOptions + case httpOption semanticsOptions of Stable -> addStableAttributes - Both -> addStableAttributes >> addOldAttributes + StableAndOld -> addStableAttributes >> addOldAttributes Old -> addOldAttributes diff --git a/instrumentation/persistent-mysql/src/OpenTelemetry/Instrumentation/Persistent/MySQL.hs b/instrumentation/persistent-mysql/src/OpenTelemetry/Instrumentation/Persistent/MySQL.hs index 7e0cac6d..60cf49cb 100644 --- a/instrumentation/persistent-mysql/src/OpenTelemetry/Instrumentation/Persistent/MySQL.hs +++ b/instrumentation/persistent-mysql/src/OpenTelemetry/Instrumentation/Persistent/MySQL.hs @@ -50,7 +50,7 @@ import qualified Database.MySQL.Base as MySQL import qualified Database.Persist.MySQL as Orig import Database.Persist.Sql import qualified OpenTelemetry.Instrumentation.Persistent as Otel -import OpenTelemetry.SemConvStabilityOptIn +import OpenTelemetry.SemanticsConfig import qualified OpenTelemetry.Trace.Core as Otel import Text.Read (readMaybe) @@ -141,11 +141,11 @@ openMySQLConn tp attrs ci@MySQL.ConnectInfo {connectUser, connectPort, connectOp , (maybe "net.peer.name" (const "net.sock.peer.addr") (readMaybe connectHost :: Maybe IP), fromString connectHost) ] - semConvStabilityOptIn <- getSemConvStabilityOptIn + semanticsOptions <- getSemanticsOptions let attrs' = - case semConvStabilityOptIn of + case httpOption semanticsOptions of Stable -> addStableAttributes attrs - Both -> addStableAttributes . addOldAttributes $ attrs + StableAndOld -> addStableAttributes . addOldAttributes $ attrs Old -> addOldAttributes attrs (conn, backend) <- Orig.openMySQLConn ci logFunc backend' <- Otel.wrapSqlBackend' tp attrs' backend diff --git a/instrumentation/postgresql-simple/src/OpenTelemetry/Instrumentation/PostgresqlSimple.hs b/instrumentation/postgresql-simple/src/OpenTelemetry/Instrumentation/PostgresqlSimple.hs index a4a62edc..709bc550 100644 --- a/instrumentation/postgresql-simple/src/OpenTelemetry/Instrumentation/PostgresqlSimple.hs +++ b/instrumentation/postgresql-simple/src/OpenTelemetry/Instrumentation/PostgresqlSimple.hs @@ -82,7 +82,7 @@ import Database.PostgreSQL.Simple.Internal ( ) import GHC.Stack import OpenTelemetry.Resource ((.=), (.=?)) -import OpenTelemetry.SemConvStabilityOptIn +import OpenTelemetry.SemanticsConfig import OpenTelemetry.Trace.Core import OpenTelemetry.Trace.Monad import Text.Read (readMaybe) @@ -99,7 +99,6 @@ staticConnectionAttributes Connection {connectionHandle} = liftIO $ do <*> LibPQ.host pqConn <*> LibPQ.port pqConn - semConvStabilityOptIn <- getSemConvStabilityOptIn let stableMaybeAttributes = [ "db.system" .= toAttribute ("postgresql" :: T.Text) , "db.user" .=? (TE.decodeUtf8 <$> mUser) @@ -129,12 +128,13 @@ staticConnectionAttributes Connection {connectionHandle} = liftIO $ do Just (IPv6 ipv6) -> "net.peer.ip" .= T.pack (show ipv6) ] + semanticsOptions <- getSemanticsOptions pure $ H.fromList $ catMaybes $ - case semConvStabilityOptIn of + case httpOption semanticsOptions of Stable -> stableMaybeAttributes - Both -> stableMaybeAttributes `union` oldMaybeAttributes + StableAndOld -> stableMaybeAttributes `union` oldMaybeAttributes Old -> oldMaybeAttributes {- diff --git a/instrumentation/wai/src/OpenTelemetry/Instrumentation/Wai.hs b/instrumentation/wai/src/OpenTelemetry/Instrumentation/Wai.hs index 150972ff..34f9881b 100644 --- a/instrumentation/wai/src/OpenTelemetry/Instrumentation/Wai.hs +++ b/instrumentation/wai/src/OpenTelemetry/Instrumentation/Wai.hs @@ -29,7 +29,7 @@ import OpenTelemetry.Attributes (lookupAttribute) import qualified OpenTelemetry.Context as Context import OpenTelemetry.Context.ThreadLocal import OpenTelemetry.Propagator -import OpenTelemetry.SemConvStabilityOptIn +import OpenTelemetry.SemanticsConfig import OpenTelemetry.Trace.Core import System.IO.Unsafe @@ -61,12 +61,13 @@ newOpenTelemetryWaiMiddleware' tp = let path_ = T.decodeUtf8 $ rawPathInfo req -- peer = remoteHost req parentContextM - semConvStabilityOptIn <- getSemConvStabilityOptIn + + semanticsOptions <- getSemanticsOptions let args = defaultSpanArguments { kind = Server , attributes = - case semConvStabilityOptIn of + case httpOption semanticsOptions of Stable -> usefulCallsite `H.union` [ @@ -74,7 +75,7 @@ newOpenTelemetryWaiMiddleware' tp = , toAttribute $ maybe "" T.decodeUtf8 (lookup hUserAgent $ requestHeaders req) ) ] - Both -> + StableAndOld -> usefulCallsite `H.union` [ ( "user_agent.original" @@ -85,6 +86,7 @@ newOpenTelemetryWaiMiddleware' tp = } inSpan'' tracer path_ args $ \requestSpan -> do ctxt <- getContext + let addStableAttributes = do addAttributes requestSpan @@ -164,9 +166,10 @@ newOpenTelemetryWaiMiddleware' tp = SockAddrUnix path -> [ ("net.peer.name", toAttribute $ T.pack path) ] - case semConvStabilityOptIn of + + case httpOption semanticsOptions of Stable -> addStableAttributes - Both -> addOldAttributes >> addStableAttributes + StableAndOld -> addOldAttributes >> addStableAttributes Old -> addOldAttributes let req' = @@ -186,13 +189,13 @@ newOpenTelemetryWaiMiddleware' tp = AttributeValue (TextAttribute route) -> updateName requestSpan route _ -> pure () - case semConvStabilityOptIn of + case httpOption semanticsOptions of Stable -> addAttributes requestSpan [ ("http.response.status_code", toAttribute $ statusCode $ responseStatus resp) ] - Both -> + StableAndOld -> addAttributes requestSpan [ ("http.response.status_code", toAttribute $ statusCode $ responseStatus resp) diff --git a/instrumentation/yesod/src/OpenTelemetry/Instrumentation/Yesod.hs b/instrumentation/yesod/src/OpenTelemetry/Instrumentation/Yesod.hs index 6b69ca92..083b1d22 100644 --- a/instrumentation/yesod/src/OpenTelemetry/Instrumentation/Yesod.hs +++ b/instrumentation/yesod/src/OpenTelemetry/Instrumentation/Yesod.hs @@ -35,7 +35,7 @@ import qualified OpenTelemetry.Context as Context import OpenTelemetry.Context.ThreadLocal import OpenTelemetry.Contrib.SpanTraversals import OpenTelemetry.Instrumentation.Wai (requestContext) -import OpenTelemetry.SemConvStabilityOptIn +import OpenTelemetry.SemanticsConfig import OpenTelemetry.Trace.Core hiding (inSpan, inSpan', inSpan'') import OpenTelemetry.Trace.Monad import UnliftIO.Exception @@ -217,7 +217,7 @@ openTelemetryYesodMiddleware openTelemetryYesodMiddleware rr m = do req <- waiRequest mr <- getCurrentRoute - semConvStabilityOptIn <- liftIO getSemConvStabilityOptIn + semanticsOptions <- liftIO getSemanticsOptions let mspan = requestContext req >>= Context.lookupSpan sharedAttributes = H.fromList $ @@ -231,15 +231,15 @@ openTelemetryYesodMiddleware rr m = do Just ("http.handler", toAttribute $ nameRender rr r) , do ff <- lookup "X-Forwarded-For" $ requestHeaders req - case semConvStabilityOptIn of + case httpOption semanticsOptions of Stable -> Just ("client.address", toAttribute $ T.decodeUtf8 ff) - Both -> Just ("client.address", toAttribute $ T.decodeUtf8 ff) + StableAndOld -> Just ("client.address", toAttribute $ T.decodeUtf8 ff) Old -> Nothing , do ff <- lookup "X-Forwarded-For" $ requestHeaders req - case semConvStabilityOptIn of + case httpOption semanticsOptions of Stable -> Nothing - Both -> Just ("http.client_ip", toAttribute $ T.decodeUtf8 ff) + StableAndOld -> Just ("http.client_ip", toAttribute $ T.decodeUtf8 ff) Old -> Just ("http.client_ip", toAttribute $ T.decodeUtf8 ff) ] args =