-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Kazuki Okamoto
committed
Jan 24, 2023
1 parent
2bade03
commit 0d75a90
Showing
19 changed files
with
602 additions
and
131 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,18 @@ | ||
version: "3" | ||
|
||
services: | ||
jaeger: | ||
image: jaegertracing/all-in-one | ||
environment: | ||
- COLLECTOR_OTLP_ENABLED=true | ||
ports: | ||
- "4318:4318" # otelcol HTTP/JSON | ||
- "16686:16686" # UI and API | ||
|
||
postgres: | ||
image: postgres | ||
environment: | ||
- POSTGRES_USER=otel | ||
- POSTGRES_PASSWORD=password | ||
ports: | ||
- "5432:5432" |
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 @@ | ||
/bin/ |
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,15 @@ | ||
.PHONY: server.run | ||
server.run: | ||
docker compose --file ../../docker-compose.yaml up $(DOCKER_COMPOSE_OPTS) | ||
|
||
.PHONY: app.run | ||
app.run: bin/yesod-subsite | ||
bin/yesod-subsite $(YESOD_MINIMAL_OPTS) | ||
|
||
bin/yesod-subsite: | ||
stack install --local-bin-path ./bin $(CABAL_OPTS) yesod-subsite:exe:yesod-subsite | ||
|
||
.PHONY: clean | ||
clean: | ||
stack clean | ||
$(RM) bin/yesod-subsite |
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,29 @@ | ||
# yesod-subsite Example | ||
|
||
This example shows how to use hs-opentelemetry-instrumentation-wai and hs-opentelemetry-instrumentation-yesod with Yesod subsite. | ||
|
||
## How to Run | ||
|
||
Run a following command to start Jaeger. | ||
|
||
``` | ||
$ make server.run | ||
``` | ||
|
||
Build and run this example in another shell. | ||
|
||
``` | ||
$ make app.run | ||
``` | ||
|
||
You can access following end points. | ||
|
||
- http://localhost:16686/ | ||
- Jaeger UI | ||
- http://localhost:3000/ | ||
- target app | ||
|
||
When you access http://localhost:3000/, Open Telemetry's traces are sent to the Jaeger. | ||
And you can see the traces at http://localhost:16686. | ||
|
||
 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,26 @@ | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE MultiParamTypeClasses #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
|
||
-- an option for Template Haskell stage restriction | ||
{-# OPTIONS_GHC -Wno-orphans #-} | ||
|
||
module Subsite ( | ||
module Subsite.Data, | ||
) where | ||
|
||
import Subsite.Data ( | ||
Subsite(Subsite), | ||
getSubHomeR, | ||
getFooR, | ||
routeToPattern, | ||
routeToRenderer, | ||
resourcesSubsite, | ||
Route(FooR,SubHomeR)) | ||
import Yesod.Core | ||
( mkYesodSubDispatch, YesodSubDispatch(yesodSubDispatch ), ) | ||
|
||
|
||
instance YesodSubDispatch Subsite master where | ||
yesodSubDispatch = $(mkYesodSubDispatch resourcesSubsite) |
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,49 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE QuasiQuotes #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
|
||
module Subsite.Data ( | ||
Subsite(Subsite), | ||
getSubHomeR, | ||
getFooR, | ||
routeToPattern, | ||
routeToRenderer, | ||
resourcesSubsite, | ||
Route(FooR,SubHomeR))where | ||
|
||
import Data.Text (Text) | ||
import OpenTelemetry.Instrumentation.Yesod | ||
( mkRouteToPattern, mkRouteToRenderer ) | ||
import Yesod.Core | ||
( mkYesodSubData, | ||
parseRoutes, | ||
SubHandlerFor, | ||
RenderRoute(renderRoute) ) | ||
import Yesod.Core.Types (Route) | ||
|
||
|
||
data Subsite = Subsite | ||
|
||
|
||
$( do | ||
let routes = | ||
[parseRoutes| | ||
/ SubHomeR GET | ||
/foo FooR GET | ||
|] | ||
concat | ||
<$> sequence | ||
[ mkRouteToRenderer ''Subsite mempty routes | ||
, mkRouteToPattern ''Subsite mempty routes | ||
, mkYesodSubData "Subsite" routes | ||
] | ||
) | ||
|
||
|
||
getSubHomeR :: SubHandlerFor Subsite master Text | ||
getSubHomeR = pure "GET /subsite" | ||
|
||
|
||
getFooR :: SubHandlerFor Subsite master Text | ||
getFooR = pure "GET /subsite/foo" |
Oops, something went wrong.