Skip to content

Commit d7c9ef0

Browse files
authored
feat(otlp): add integration test setup for traces (#1477)
1 parent 80da656 commit d7c9ef0

File tree

15 files changed

+721
-7
lines changed

15 files changed

+721
-7
lines changed

.github/workflows/integration_tests.yml

+16-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,25 @@ on:
77

88
jobs:
99
integration_tests:
10+
rust: stable
1011
runs-on: ubuntu-latest
1112
timeout-minutes: 10
1213
if: ${{ github.event.label.name == 'integration tests' || contains(github.event.pull_request.labels.*.name, 'integration tests') }}
1314
steps:
14-
- name: Checkout
15-
uses: actions/checkout@v2
15+
- name: Free disk space
16+
run: |
17+
df -h
18+
sudo rm -rf /usr/local/lib/android
19+
sudo rm -rf /usr/share/dotnet
20+
df -h
21+
- uses: actions/checkout@v1
22+
with:
23+
submodules: true
24+
- uses: actions-rs/toolchain@v1
25+
with:
26+
toolchain: ${{ matrix.rust }}
27+
components: rustfmt
28+
profile: minimal
29+
- uses: arduino/setup-protoc@v1
1630
- name: Run integration tests using docker compose
1731
run: ./scripts/integration_tests.sh

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ members = [
1818
"opentelemetry-otlp/examples/basic-otlp",
1919
"opentelemetry-otlp/examples/basic-otlp-http",
2020
"opentelemetry-otlp/examples/external-otlp-grpcio-async-std",
21+
"opentelemetry-otlp/tests/integration_test",
2122
"examples/metrics-basic",
2223
"examples/metrics-advanced",
2324
"examples/logs-basic",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "integration_test_runner"
3+
version = "0.1.0"
4+
edition = "2021"
5+
publish = false
6+
7+
8+
[dependencies]
9+
once_cell = "1.17"
10+
opentelemetry = { path = "../../../opentelemetry", features = ["metrics", "logs"] }
11+
opentelemetry_sdk = { path = "../../../opentelemetry-sdk", features = ["rt-tokio", "logs", "testing"] }
12+
opentelemetry-otlp = { path = "../../../opentelemetry-otlp", features = ["tonic", "metrics", "logs"] }
13+
opentelemetry-semantic-conventions = { path = "../../../opentelemetry-semantic-conventions" }
14+
opentelemetry-proto = { path = "../../../opentelemetry-proto", features = ["gen-tonic-messages", "trace", "with-serde"] }
15+
tokio = { version = "1.0", features = ["full"] }
16+
serde_json = "1"
17+
testcontainers = "0.15.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{
2+
"resourceSpans": [
3+
{
4+
"resource": {
5+
"attributes": [
6+
{
7+
"key": "service.name",
8+
"value": {
9+
"stringValue": "basic-otlp-tracing-example"
10+
}
11+
}
12+
]
13+
},
14+
"scopeSpans": [
15+
{
16+
"scope": {
17+
"name": "ex.com/basic"
18+
},
19+
"spans": [
20+
{
21+
"traceId": "9b458af7378cba65253d7042d34fc72e",
22+
"spanId": "cd7cf7bf939930b7",
23+
"parentSpanId": "",
24+
"name": "Sub operation...",
25+
"kind": 1,
26+
"startTimeUnixNano": 1703985537070566698,
27+
"endTimeUnixNano": 1703985537070572718,
28+
"attributes": [
29+
{
30+
"key": "lemons",
31+
"value": {
32+
"stringValue": "five"
33+
}
34+
}
35+
],
36+
"events": [
37+
{
38+
"timeUnixNano": 1703985537070567697,
39+
"name": "Sub span event"
40+
}
41+
],
42+
"status": {}
43+
}
44+
]
45+
}
46+
]
47+
},
48+
{
49+
"resource": {
50+
"attributes": [
51+
{
52+
"key": "service.name",
53+
"value": {
54+
"stringValue": "basic-otlp-tracing-example"
55+
}
56+
}
57+
]
58+
},
59+
"scopeSpans": [
60+
{
61+
"scope": {
62+
"name": "ex.com/basic"
63+
},
64+
"spans": [
65+
{
66+
"traceId": "9b458af7378cba65253d7042d34fc72e",
67+
"spanId": "d58cf2d702a061e0",
68+
"parentSpanId": "cd7cf7bf939930b7",
69+
"name": "operation",
70+
"kind": 1,
71+
"startTimeUnixNano": 1703985537070558635,
72+
"endTimeUnixNano": 1703985537070580454,
73+
"attributes": [
74+
{
75+
"key": "ex.com/another",
76+
"value": {
77+
"stringValue": "yes"
78+
}
79+
}
80+
],
81+
"events": [
82+
{
83+
"timeUnixNano": 1703985537070563326,
84+
"name": "Nice operation!",
85+
"attributes": [
86+
{
87+
"key": "bogons",
88+
"value": {
89+
"intValue": 100
90+
}
91+
}
92+
]
93+
}
94+
],
95+
"status": {}
96+
}
97+
]
98+
}
99+
]
100+
}
101+
]
102+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{
2+
"resourceSpans": [
3+
{
4+
"resource": {
5+
"attributes": [
6+
{
7+
"key": "service.name",
8+
"value": {
9+
"stringValue": "basic-otlp-tracing-example"
10+
}
11+
}
12+
]
13+
},
14+
"scopeSpans": [
15+
{
16+
"scope": {
17+
"name": "ex.com/basic"
18+
},
19+
"spans": [
20+
{
21+
"traceId": "9b458af7378cba65253d7042d34fc72e",
22+
"spanId": "cd7cf7bf939930b7",
23+
"parentSpanId": "d58cf2d702a061e0",
24+
"name": "Sub operation...",
25+
"kind": 1,
26+
"startTimeUnixNano": 1703985537070566698,
27+
"endTimeUnixNano": 1703985537070572718,
28+
"attributes": [
29+
{
30+
"key": "lemons",
31+
"value": {
32+
"stringValue": "five"
33+
}
34+
}
35+
],
36+
"events": [
37+
{
38+
"timeUnixNano": 1703985537070567697,
39+
"name": "Sub span event"
40+
}
41+
],
42+
"status": {}
43+
}
44+
]
45+
}
46+
]
47+
},
48+
{
49+
"resource": {
50+
"attributes": [
51+
{
52+
"key": "service.name",
53+
"value": {
54+
"stringValue": "basic-otlp-tracing-example"
55+
}
56+
}
57+
]
58+
},
59+
"scopeSpans": [
60+
{
61+
"scope": {
62+
"name": "ex.com/basic"
63+
},
64+
"spans": [
65+
{
66+
"traceId": "9b458af7378cba65253d7042d34fc72e",
67+
"spanId": "d58cf2d702a061e0",
68+
"parentSpanId": "",
69+
"name": "operation",
70+
"kind": 1,
71+
"startTimeUnixNano": 1703985537070558635,
72+
"endTimeUnixNano": 1703985537070580454,
73+
"attributes": [
74+
{
75+
"key": "ex.com/another",
76+
"value": {
77+
"stringValue": "yes"
78+
}
79+
}
80+
],
81+
"events": [
82+
{
83+
"timeUnixNano": 1703985537070563326,
84+
"name": "Nice operation!",
85+
"attributes": [
86+
{
87+
"key": "bogons",
88+
"value": {
89+
"intValue": 100
90+
}
91+
}
92+
]
93+
}
94+
],
95+
"status": {}
96+
}
97+
]
98+
}
99+
]
100+
}
101+
]
102+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
receivers:
2+
otlp:
3+
protocols:
4+
grpc:
5+
http:
6+
7+
exporters:
8+
logging:
9+
loglevel: debug
10+
file:
11+
path: /testresults/traces.json
12+
13+
service:
14+
pipelines:
15+
traces:
16+
receivers: [otlp]
17+
exporters: [file]

0 commit comments

Comments
 (0)