1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "traces": [
12 {
13 "traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
14 "spanId": "a1b2c3d4e5f60001",
15 "name": "POST /api/checkout",
16 "kind": "SERVER",
17 "startTime": "2026-10-01T12:00:00.000Z",
18 "durationMs": 420,
19 "attributes": {
20 "http.request.method": "POST",
21 "http.route": "/api/checkout",
22 "http.response.status_code": 200
23 },
24 "resource": {
25 "service.name": "frontend",
26 "service.version": "2.3.1",
27 "deployment.environment.name": "production",
28 "service.instance.id": "frontend-7d9f",
29 "telemetry.sdk.language": "nodejs",
30 "telemetry.sdk.version": "1.28.0"
31 },
32 "scope": "@opentelemetry/instrumentation-http"
33 },
34 {
35 "traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
36 "spanId": "a1b2c3d4e5f60002",
37 "parentSpanId": "a1b2c3d4e5f60001",
38 "name": "POST",
39 "kind": "CLIENT",
40 "startTime": "2026-10-01T12:00:00.005Z",
41 "durationMs": 400,
42 "attributes": {
43 "http.request.method": "POST",
44 "server.address": "checkout.shop.svc.cluster.local",
45 "url.full": "http://checkout.shop.svc.cluster.local:8080/checkout"
46 },
47 "resource": {
48 "service.name": "frontend",
49 "service.version": "2.3.1",
50 "deployment.environment.name": "production",
51 "service.instance.id": "frontend-7d9f",
52 "telemetry.sdk.language": "nodejs",
53 "telemetry.sdk.version": "1.28.0"
54 },
55 "scope": "@opentelemetry/instrumentation-http"
56 },
57 {
58 "traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
59 "spanId": "a1b2c3d4e5f60003",
60 "parentSpanId": "a1b2c3d4e5f60002",
61 "name": "POST /checkout",
62 "kind": "SERVER",
63 "startTime": "2026-10-01T12:00:00.007Z",
64 "durationMs": 395,
65 "attributes": {
66 "http.request.method": "POST",
67 "http.route": "/checkout",
68 "http.response.status_code": 200
69 },
70 "resource": {
71 "service.name": "checkout",
72 "service.version": "1.5.0",
73 "deployment.environment.name": "production",
74 "service.instance.id": "checkout-5c2a",
75 "telemetry.sdk.language": "java",
76 "telemetry.sdk.version": "1.43.0"
77 },
78 "scope": "io.opentelemetry.spring-webmvc-6.0"
79 },
80 {
81 "traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
82 "spanId": "a1b2c3d4e5f60004",
83 "parentSpanId": "a1b2c3d4e5f60003",
84 "name": "SELECT orders",
85 "kind": "CLIENT",
86 "startTime": "2026-10-01T12:00:00.010Z",
87 "durationMs": 60,
88 "attributes": {
89 "db.system.name": "postgresql",
90 "db.operation.name": "SELECT",
91 "server.address": "orders-db.shop.svc.cluster.local"
92 },
93 "resource": {
94 "service.name": "checkout",
95 "service.version": "1.5.0",
96 "deployment.environment.name": "production",
97 "service.instance.id": "checkout-5c2a",
98 "telemetry.sdk.language": "java",
99 "telemetry.sdk.version": "1.43.0"
100 },
101 "scope": "io.opentelemetry.jdbc"
102 },
103 {
104 "traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
105 "spanId": "a1b2c3d4e5f60005",
106 "parentSpanId": "a1b2c3d4e5f60003",
107 "name": "GET",
108 "kind": "CLIENT",
109 "startTime": "2026-10-01T12:00:00.072Z",
110 "durationMs": 50,
111 "attributes": {
112 "http.request.method": "GET",
113 "server.address": "inventory.shop.svc.cluster.local",
114 "url.full": "http://inventory.shop.svc.cluster.local:8080/stock/1042"
115 },
116 "resource": {
117 "service.name": "checkout",
118 "service.version": "1.5.0",
119 "deployment.environment.name": "production",
120 "service.instance.id": "checkout-5c2a",
121 "telemetry.sdk.language": "java",
122 "telemetry.sdk.version": "1.43.0"
123 },
124 "scope": "io.opentelemetry.java-http-client"
125 },
126 {
127 "traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
128 "spanId": "a1b2c3d4e5f60006",
129 "parentSpanId": "a1b2c3d4e5f60003",
130 "name": "POST",
131 "kind": "CLIENT",
132 "startTime": "2026-10-01T12:00:00.124Z",
133 "durationMs": 80,
134 "attributes": {
135 "http.request.method": "POST",
136 "server.address": "fraud-check.shop.svc.cluster.local",
137 "url.full": "http://fraud-check.shop.svc.cluster.local:8080/score"
138 },
139 "resource": {
140 "service.name": "checkout",
141 "service.version": "1.5.0",
142 "deployment.environment.name": "production",
143 "service.instance.id": "checkout-5c2a",
144 "telemetry.sdk.language": "java",
145 "telemetry.sdk.version": "1.43.0"
146 },
147 "scope": "io.opentelemetry.java-http-client"
148 },
149 {
150 "traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
151 "spanId": "a1b2c3d4e5f60007",
152 "parentSpanId": "a1b2c3d4e5f60003",
153 "name": "POST",
154 "kind": "CLIENT",
155 "startTime": "2026-10-01T12:00:00.206Z",
156 "durationMs": 120,
157 "attributes": {
158 "http.request.method": "POST",
159 "server.address": "api.stripe.com",
160 "url.full": "https://api.stripe.com/v1/payment_intents"
161 },
162 "resource": {
163 "service.name": "checkout",
164 "service.version": "1.5.0",
165 "deployment.environment.name": "production",
166 "service.instance.id": "checkout-5c2a",
167 "telemetry.sdk.language": "java",
168 "telemetry.sdk.version": "1.43.0"
169 },
170 "scope": "io.opentelemetry.java-http-client"
171 },
172 {
173 "traceId": "8f2a1c9d3e4b5a6f7081928374655647",
174 "spanId": "b1b2c3d4e5f60001",
175 "name": "GET /stock/{sku}",
176 "kind": "SERVER",
177 "startTime": "2026-10-01T12:00:00.075Z",
178 "durationMs": 44,
179 "attributes": {
180 "http.request.method": "GET",
181 "http.route": "/stock/{sku}",
182 "url.path": "/stock/1042",
183 "http.response.status_code": 200
184 },
185 "resource": {
186 "service.name": "inventory",
187 "deployment.environment.name": "production",
188 "telemetry.sdk.language": "python",
189 "telemetry.sdk.version": "1.16.0"
190 },
191 "scope": "opentelemetry.instrumentation.fastapi"
192 }
193 ],
194 "traceSetName": "shop-production",
195 "expectedServices": [
196 "frontend",
197 "checkout",
198 "inventory",
199 "shipping"
200 ]
201};
202
203
204const run = await client.actor("michiganpublictech/otel-coverage-auditor").call(input);
205
206
207console.log('Results from dataset');
208console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
209const { items } = await client.dataset(run.defaultDatasetId).listItems();
210items.forEach((item) => {
211 console.dir(item);
212});
213
214