Skip to content

Commit a029011

Browse files
authored
Merge pull request #80 from sailalithkanumuri8/sai-opentelemetry-integration
2 parents e350b9b + 68cb5d4 commit a029011

21 files changed

Lines changed: 5246 additions & 914 deletions

File tree

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ COAP_SIMPLE_PORT_OUT=5683
1313
COAP_NEGOTIATION_PORT_OUT=5684
1414
SMART_HOME_SMART_CLOCK_PORT_OUT=5685
1515
TRAEFIK_DASHBOARD_PORT_OUT=8080
16+
JAEGER_ENDPOINT=http://host.docker.internal:8085/api/traces
1617

1718
STACK_HOSTNAME="plugfest.thingweb.io"
1819
BROKER_URI="plugfest.thingweb.io"

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ If you are going to add a completely new Thing:
6969
2. Add your Thing Model under the previously created directory and name it such as `<your_thing_name>.tm.json`.
7070
3. Follow the steps above to add your protocol and programming language/framework.
7171

72+
**TypeScript Tracing Integration:**
73+
Wrap your WoT Thing with auto-tracing to get detailed OpenTelemetry spans for validation, processing, and database operations:
74+
75+
```typescript
76+
import { createAutoTracedThing, TracedBusinessLogic } from "../../util/dist/auto-tracing";
77+
const tracedThing = createAutoTracedThing(thing);
78+
79+
// Property writes get ".read" suffix
80+
tracedThing.setPropertyReadHandler("allAvailableResources", async (options) => {
81+
return getResources(); // Span: "allAvailableResources.read"
82+
});
83+
84+
// Property writes get ".write" suffix
85+
tracedThing.setPropertyWriteHandler("servedCounter", async (value) => {
86+
updateCounter(value); // Span: "servedCounter.write"
87+
});
88+
```
89+
7290
## Current Devices
7391

7492
The table below contains the public base URIs of the Things used for protocol testing.
@@ -178,3 +196,24 @@ docker buildx build \
178196
For running the things separately, using their `Dockerfile`'s, `docker build -t <image-tag> -f ./Dockerfile ../../` command must be used to give the context to be able to copy `tm.json` into the container.
179197
180198
For Node.js-based devices, we use npm workspaces and running `npm install` at the root directory installs all the packages needed for every device. After packages are installed, running `node main.js` would run the thing. For port configuration, running either `node main.js -p 1000` or `node main.js --port 1000` would start the thing on port 1000.
199+
200+
## Tracing
201+
202+
Distributed tracing is enabled using OpenTelemetry and Jaeger. To view all traces and logs, open [http://localhost:8084](http://localhost:8084) in your browser (Jaeger UI). Traces are sent to the Jaeger collector on port 8085.
203+
204+
Enhanced auto-tracing automatically injects `TracedBusinessLogic` for detailed span creation without redundancy. Function signatures determine tracing mode.
205+
206+
Also, there is comprehensive test suites that are also traced and visible in Jaeger:
207+
208+
- **Thing Description (TD) validation tests** - Test if the exposed TD is valid according to W3C WoT standards
209+
- **Thing Model (TM) validation tests** - Validate the Thing Model against the schema
210+
- **Integration tests** - Test actual interactions with the Things
211+
212+
When tests run, they appear in Jaeger with clear span names like `td.test` or `tm.test`. Failed tests show up as **error spans** with red highlighting in the Jaeger UI, making it easy to:
213+
214+
- **Debug test failures** by examining the error details and stack traces in span logs
215+
- **Track test performance** and identify slow validation steps
216+
- **Monitor CI/CD pipelines** by observing test execution patterns
217+
- **Correlate test failures** with specific Thing operations or configurations
218+
219+
Test spans include detailed attributes about what was validated, error messages for failures, and timing information for performance analysis.

docker-compose-things-local.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,15 @@ services:
101101
- things_network
102102
http-advanced-coffee-machine:
103103
build:
104-
context: ./things/advanced-coffee-machine
105-
dockerfile: ./http/ts/Dockerfile
104+
context: .
105+
dockerfile: ./things/advanced-coffee-machine/http/ts/Dockerfile
106106
labels:
107107
- traefik.http.routers.http-advanced-coffee-machine.rule=PathPrefix(`/http-advanced-coffee-machine`)
108108
- traefik.http.services.http-advanced-coffee-machine.loadbalancer.server.port=${WEB_PORT_OUT}
109109
environment:
110110
- HOSTNAME=${STACK_HOSTNAME}
111111
- PORT=${WEB_PORT_OUT}
112+
- JAEGER_ENDPOINT=${JAEGER_ENDPOINT}
112113
networks:
113114
- things_network
114115
http-data-schema-thing:
@@ -128,7 +129,7 @@ services:
128129
counter-thing:
129130
build:
130131
context: ./things/counter-thing
131-
dockerfile: Dockerfile
132+
dockerfile: ./http/ts/Dockerfile
132133
labels:
133134
- traefik.http.routers.counter-thing.rule=PathPrefix(`/counter-thing`)
134135
- traefik.http.services.counter-thing.loadbalancer.server.port=${WEB_PORT_OUT}

docker-compose-things.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ services:
149149
environment:
150150
- HOSTNAME=${STACK_HOSTNAME}
151151
- PORT=${WEB_PORT_OUT}
152+
- JAEGER_ENDPOINT=${JAEGER_ENDPOINT}
152153
deploy:
153154
resources:
154155
limits:

0 commit comments

Comments
 (0)