Skip to content

Commit eccdf35

Browse files
Michal Baczunustiugov
authored andcommitted
Adds unit tests for tracing util
Signed-off-by: Michal Baczun <[email protected]>
1 parent 049090e commit eccdf35

File tree

5 files changed

+78
-4
lines changed

5 files changed

+78
-4
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ updates:
44
directory: "/"
55
schedule:
66
interval: "weekly"
7+
8+
updates:
79
- package-ecosystem: "gomod"
810
directory: "/function-images/tests/chained-function-serving"
911
schedule:
@@ -16,5 +18,8 @@ updates:
1618
directory: "/utils/benchmarking/eventing"
1719
schedule:
1820
interval: "weekly"
19-
20-
# Use https://dependabot.com/docs/config-file/validator/ to check for errors.
21+
updates:
22+
- package-ecosystem: "gomod"
23+
directory: "/utils/tracing/go"
24+
schedule:
25+
interval: "weekly"

.github/workflows/unit_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
strategy:
2727
fail-fast: false
2828
matrix:
29-
module: [taps, misc, profile]
29+
module: [taps, misc, profile, utils/tracing/go]
3030
steps:
3131
- name: Set up Go 1.15
3232
uses: actions/setup-go@v2

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
- Added [script](./scripts/cloudlab/start_onenode_vhive_cluster.sh) to (re)start vHive single node cluster in a push-button.
88
- CRI test logs are now stored as GitHub artifacts.
99
- Added Knative Eventing Tutorial: [documentation](./docs/knative/eventing.md) and [example](./examples/knative-eventing-tutorial).
10-
- Added a chained functions microbenchmark that uses Knative Serving.
10+
- Added a chained functions microbenchmark that uses Knative Serving with tracing.
1111
- Added a linter for link checking in markdown files
1212
- Added documentation for adding benchmarks to vHive.
13+
- Added a utility for tracing using zipkin.
1314

1415
### Changed
1516

utils/tracing/go/Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2021 Michal Baczun and EASE lab
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
EXTRAGOARGS:=-v -race -cover
24+
25+
test:
26+
# Need to pass GOROOT because GitHub-hosted runners may have several
27+
# go versions installed so that calling go from root may fail
28+
sudo env "PATH=$(PATH)" "GOROOT=$(GOROOT)" go test ./ $(EXTRAGOARGS)
29+
30+
test-man:
31+
echo "Nothing to test manually"
32+
33+
.PHONY: test test-man

utils/tracing/go/tracing_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package tracing
2+
3+
import (
4+
"context"
5+
"log"
6+
"os"
7+
"testing"
8+
"time"
9+
10+
"go.opentelemetry.io/otel"
11+
"go.opentelemetry.io/otel/attribute"
12+
)
13+
14+
func TestInitBasicTracer(t *testing.T) {
15+
InitBasicTracer("http://localhost:9999", "test-tracer")
16+
tracer := otel.GetTracerProvider().Tracer("test-tracer")
17+
_, traceSpan := tracer.Start(context.Background(), "test-span")
18+
traceSpan.End()
19+
}
20+
21+
func TestInitCustomTracer(t *testing.T) {
22+
logger := log.New(os.Stderr, "tracer-log", log.Ldate|log.Ltime|log.Llongfile)
23+
InitCustomTracer("http://localhost:9999", 1.0, logger, attribute.String("service.name", "custom tracer"))
24+
tracer := otel.GetTracerProvider().Tracer("test-tracer")
25+
_, traceSpan := tracer.Start(context.Background(), "test-span")
26+
traceSpan.End()
27+
}
28+
29+
func TestSpan(t *testing.T) {
30+
InitBasicTracer("http://localhost:9999", "test-tracer")
31+
span := Span{SpanName: "test-span", TracerName: "test-tracer"}
32+
span.StartSpan(context.Background())
33+
<-time.After(1 * time.Second)
34+
span.EndSpan()
35+
}

0 commit comments

Comments
 (0)