Skip to content

Commit 6b5d7f7

Browse files
committed
Add opentelemetry-api package
1 parent 9c00e6b commit 6b5d7f7

File tree

9 files changed

+96
-0
lines changed

9 files changed

+96
-0
lines changed

Diff for: .github/workflows/ci.yml

+18
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ jobs:
1717
with:
1818
ghc-version: ${{ matrix.ghc }}
1919
cabal-version: '3.0'
20+
- name: Update cabal package database
21+
run: cabal update
22+
- name: Build
23+
run: |
24+
cd opentelemetry-api
25+
cabal build -f examples
2026
2127
linux-stack-lts-14:
2228
runs-on: ubuntu-18.04
@@ -27,6 +33,12 @@ jobs:
2733
- uses: actions/checkout@v1
2834
- name: Install stack
2935
run: which stack || curl -sSL https://get.haskellstack.org/ | sh
36+
- name: Install GHC
37+
run: |
38+
stack setup --stack-yaml ${{ matrix.stack-yaml }}
39+
- name: Build
40+
run: |
41+
stack build --fast --stack-yaml ${{ matrix.stack-yaml }}
3042
3143
macos-stack-lts-14:
3244
runs-on: macOS-latest
@@ -37,3 +49,9 @@ jobs:
3749
- uses: actions/checkout@v1
3850
- name: Install stack
3951
run: which stack || curl -sSL https://get.haskellstack.org/ | sh
52+
- name: Install GHC
53+
run: |
54+
stack setup --stack-yaml ${{ matrix.stack-yaml }}
55+
- name: Build
56+
run: |
57+
stack build --fast --stack-yaml ${{ matrix.stack-yaml }}

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Revision history for opentelemetry
2+
3+
## 0.0.0.0 -- 2020-01-04
4+
5+
* First version. Released on an unsuspecting world.

Diff for: LICENSE

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2020-present Dmitry Ivanov
2+
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
4+
5+
http://www.apache.org/licenses/LICENSE-2.0
6+
7+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Diff for: opentelemetry-api/Setup.hs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain

Diff for: opentelemetry-api/opentelemetry.cabal

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cabal-version: 2.4
2+
name: opentelemetry
3+
version: 0.1.0.0
4+
license-file: LICENSE
5+
author: Dmitry Ivanov
6+
maintainer: [email protected]
7+
build-type: Simple
8+
extra-source-files: CHANGELOG.md
9+
10+
library
11+
build-depends:
12+
base >= 4.12,
13+
clock >= 0.8,
14+
random
15+
hs-source-dirs: src
16+
default-language: Haskell2010

Diff for: opentelemetry-api/src/OpenTracing/API/Common.hs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module OpenTracing.API.Common where
2+
3+
import Data.Int
4+
import qualified Data.Text as T
5+
6+
newtype TraceId = TId Int64
7+
8+
newtype SpanId = SId Int64
9+
10+
type Timestamp = Int64
11+
12+
data Span
13+
= Span
14+
{ spanId :: !SpanId,
15+
spanTraceId :: !TraceId,
16+
spanOperation :: T.Text,
17+
spanStartedAt :: !Timestamp,
18+
spanFinishedAt :: !Timestamp
19+
}

Diff for: opentelemetry-api/src/OpenTracing/API/Explicit.hs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module OpenTracing.API.Explicit where
2+
3+
import OpenTracing.API.Common
4+
import System.Random
5+
6+
startRootSpan :: T.Text -> IO Span
7+
startRootSpan name = do
8+
timestamp <- now64
9+
sid <- randomIO
10+
pure $! Span sid sid name timestamp 0
11+
12+
startChildSpanOf :: Span -> T.Text -> IO Span
13+
startChildSpanOf parent name = do
14+
timestamp <- now64
15+
sid <- randomIO
16+
pure $! Span sid (spanTraceId parent) name timestamp 0
17+
18+
finishSpan :: Span -> IO Span
19+
finishSpan sp = do
20+
timestamp <- now
21+
sp {spanFinishedAt = timestamp}

Diff for: stack-8.8.1.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
resolver: nightly-2020-01-04
2+
3+
packages:
4+
- opentelemetry-api

Diff for: stack.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
resolver: lts-14.19
2+
3+
packages:
4+
- opentelemetry-api

0 commit comments

Comments
 (0)