forked from iand675/hs-opentelemetry
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
107 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
cabal-version: 3.4 | ||
|
||
name: herp-logger-example | ||
version: 0.0.0 | ||
build-type: Simple | ||
|
||
common common | ||
ghc-options: -threaded | ||
-with-rtsopts=-N | ||
-Wall | ||
-Wcompat | ||
-Widentities | ||
-Wincomplete-record-updates | ||
-Wincomplete-uni-patterns | ||
-Wmissing-export-lists | ||
-Wmissing-exported-signatures | ||
-Wmissing-home-modules | ||
-Wmissing-export-lists | ||
-Wmonomorphism-restriction | ||
-Wno-name-shadowing | ||
-Wpartial-fields | ||
-Wredundant-constraints | ||
-Wunused-packages | ||
if impl(ghc >= 9.0) | ||
ghc-options: -Winvalid-haddock | ||
if impl(ghc >= 9.2) | ||
ghc-options: -Wmissing-kind-signatures | ||
-Woperator-whitespace | ||
-Wredundant-bang-patterns | ||
default-language: Haskell2010 | ||
|
||
executable herp-logger-example | ||
import: common | ||
main-is: main.hs | ||
hs-source-dirs: . | ||
build-depends: base, | ||
herp-logger, | ||
hs-opentelemetry-sdk, | ||
hs-opentelemetry-instrumentation-herp-logger-datadog, | ||
hs-opentelemetry-vendor-datadog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE DataKinds #-} | ||
|
||
import Control.Exception (bracket) | ||
import OpenTelemetry.Trace | ||
import OpenTelemetry.Resource | ||
import Herp.Logger | ||
import OpenTelemetry.Instrumentation.Herp.Logger.Datadog | ||
import OpenTelemetry.Vendor.Datadog | ||
|
||
main :: IO () | ||
main = do | ||
let | ||
resource :: Resource 'Nothing | ||
resource = | ||
mkResource | ||
[ envKey .=$ "test" | ||
, serviceKey .=$ "hs-opentelemetry" | ||
, versionKey .=$ "0" | ||
] | ||
bracket | ||
( do | ||
(processors, options) <- getTracerProviderInitializationOptions' resource | ||
createTracerProvider processors options | ||
) | ||
shutdownTracerProvider | ||
$ \tracerProvider -> | ||
let loggerConfig = appendHooksToConfig tracerProvider defaultLoggerConfig | ||
in do | ||
withLogger loggerConfig $ \logger -> do | ||
let tracer = makeTracer tracerProvider "main" tracerOptions | ||
inSpan' tracer "main" defaultSpanArguments $ \span -> do | ||
addAttributeByKey span envKey "test" | ||
logIO logger "log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters