Skip to content

Commit

Permalink
feat(otlp): add integration test setup for traces (#1477)
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyCpp authored Feb 8, 2024
1 parent 80da656 commit d7c9ef0
Show file tree
Hide file tree
Showing 15 changed files with 721 additions and 7 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,25 @@ on:

jobs:
integration_tests:
rust: stable
runs-on: ubuntu-latest
timeout-minutes: 10
if: ${{ github.event.label.name == 'integration tests' || contains(github.event.pull_request.labels.*.name, 'integration tests') }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Free disk space
run: |
df -h
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
df -h
- uses: actions/checkout@v1
with:
submodules: true
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
components: rustfmt
profile: minimal
- uses: arduino/setup-protoc@v1
- name: Run integration tests using docker compose
run: ./scripts/integration_tests.sh
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ members = [
"opentelemetry-otlp/examples/basic-otlp",
"opentelemetry-otlp/examples/basic-otlp-http",
"opentelemetry-otlp/examples/external-otlp-grpcio-async-std",
"opentelemetry-otlp/tests/integration_test",
"examples/metrics-basic",
"examples/metrics-advanced",
"examples/logs-basic",
Expand Down
17 changes: 17 additions & 0 deletions opentelemetry-otlp/tests/integration_test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "integration_test_runner"
version = "0.1.0"
edition = "2021"
publish = false


[dependencies]
once_cell = "1.17"
opentelemetry = { path = "../../../opentelemetry", features = ["metrics", "logs"] }
opentelemetry_sdk = { path = "../../../opentelemetry-sdk", features = ["rt-tokio", "logs", "testing"] }
opentelemetry-otlp = { path = "../../../opentelemetry-otlp", features = ["tonic", "metrics", "logs"] }
opentelemetry-semantic-conventions = { path = "../../../opentelemetry-semantic-conventions" }
opentelemetry-proto = { path = "../../../opentelemetry-proto", features = ["gen-tonic-messages", "trace", "with-serde"] }
tokio = { version = "1.0", features = ["full"] }
serde_json = "1"
testcontainers = "0.15.0"
102 changes: 102 additions & 0 deletions opentelemetry-otlp/tests/integration_test/expected/failed_traces.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"resourceSpans": [
{
"resource": {
"attributes": [
{
"key": "service.name",
"value": {
"stringValue": "basic-otlp-tracing-example"
}
}
]
},
"scopeSpans": [
{
"scope": {
"name": "ex.com/basic"
},
"spans": [
{
"traceId": "9b458af7378cba65253d7042d34fc72e",
"spanId": "cd7cf7bf939930b7",
"parentSpanId": "",
"name": "Sub operation...",
"kind": 1,
"startTimeUnixNano": 1703985537070566698,
"endTimeUnixNano": 1703985537070572718,
"attributes": [
{
"key": "lemons",
"value": {
"stringValue": "five"
}
}
],
"events": [
{
"timeUnixNano": 1703985537070567697,
"name": "Sub span event"
}
],
"status": {}
}
]
}
]
},
{
"resource": {
"attributes": [
{
"key": "service.name",
"value": {
"stringValue": "basic-otlp-tracing-example"
}
}
]
},
"scopeSpans": [
{
"scope": {
"name": "ex.com/basic"
},
"spans": [
{
"traceId": "9b458af7378cba65253d7042d34fc72e",
"spanId": "d58cf2d702a061e0",
"parentSpanId": "cd7cf7bf939930b7",
"name": "operation",
"kind": 1,
"startTimeUnixNano": 1703985537070558635,
"endTimeUnixNano": 1703985537070580454,
"attributes": [
{
"key": "ex.com/another",
"value": {
"stringValue": "yes"
}
}
],
"events": [
{
"timeUnixNano": 1703985537070563326,
"name": "Nice operation!",
"attributes": [
{
"key": "bogons",
"value": {
"intValue": 100
}
}
]
}
],
"status": {}
}
]
}
]
}
]
}
102 changes: 102 additions & 0 deletions opentelemetry-otlp/tests/integration_test/expected/traces.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"resourceSpans": [
{
"resource": {
"attributes": [
{
"key": "service.name",
"value": {
"stringValue": "basic-otlp-tracing-example"
}
}
]
},
"scopeSpans": [
{
"scope": {
"name": "ex.com/basic"
},
"spans": [
{
"traceId": "9b458af7378cba65253d7042d34fc72e",
"spanId": "cd7cf7bf939930b7",
"parentSpanId": "d58cf2d702a061e0",
"name": "Sub operation...",
"kind": 1,
"startTimeUnixNano": 1703985537070566698,
"endTimeUnixNano": 1703985537070572718,
"attributes": [
{
"key": "lemons",
"value": {
"stringValue": "five"
}
}
],
"events": [
{
"timeUnixNano": 1703985537070567697,
"name": "Sub span event"
}
],
"status": {}
}
]
}
]
},
{
"resource": {
"attributes": [
{
"key": "service.name",
"value": {
"stringValue": "basic-otlp-tracing-example"
}
}
]
},
"scopeSpans": [
{
"scope": {
"name": "ex.com/basic"
},
"spans": [
{
"traceId": "9b458af7378cba65253d7042d34fc72e",
"spanId": "d58cf2d702a061e0",
"parentSpanId": "",
"name": "operation",
"kind": 1,
"startTimeUnixNano": 1703985537070558635,
"endTimeUnixNano": 1703985537070580454,
"attributes": [
{
"key": "ex.com/another",
"value": {
"stringValue": "yes"
}
}
],
"events": [
{
"timeUnixNano": 1703985537070563326,
"name": "Nice operation!",
"attributes": [
{
"key": "bogons",
"value": {
"intValue": 100
}
}
]
}
],
"status": {}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
receivers:
otlp:
protocols:
grpc:
http:

exporters:
logging:
loglevel: debug
file:
path: /testresults/traces.json

service:
pipelines:
traces:
receivers: [otlp]
exporters: [file]
Loading

0 comments on commit d7c9ef0

Please sign in to comment.