1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "telemetry": {
12 "resourceSpans": [
13 {
14 "resource": {
15 "attributes": [
16 {
17 "key": "service.name",
18 "value": {
19 "stringValue": "checkout"
20 }
21 },
22 {
23 "key": "deployment.environment",
24 "value": {
25 "stringValue": "production"
26 }
27 },
28 {
29 "key": "telemetry.sdk.language",
30 "value": {
31 "stringValue": "java"
32 }
33 }
34 ]
35 },
36 "scopeSpans": [
37 {
38 "scope": {
39 "name": "io.opentelemetry.tomcat-10.0"
40 },
41 "spans": [
42 {
43 "traceId": "5b8efff798038103d269b633813fc60c",
44 "spanId": "eee19b7ec3c1b174",
45 "name": "GET /orders/12345",
46 "kind": 2,
47 "startTimeUnixNano": "1760000000000000000",
48 "endTimeUnixNano": "1760000000012000000",
49 "attributes": [
50 {
51 "key": "http.method",
52 "value": {
53 "stringValue": "get"
54 }
55 },
56 {
57 "key": "http.status_code",
58 "value": {
59 "stringValue": "503"
60 }
61 },
62 {
63 "key": "http.target",
64 "value": {
65 "stringValue": "/orders/12345?coupon=SPRING"
66 }
67 },
68 {
69 "key": "http.scheme",
70 "value": {
71 "stringValue": "https"
72 }
73 },
74 {
75 "key": "http.route",
76 "value": {
77 "stringValue": "/orders/{id}"
78 }
79 }
80 ],
81 "status": {}
82 },
83 {
84 "traceId": "5b8efff798038103d269b633813fc60c",
85 "spanId": "aab19b7ec3c1b175",
86 "parentSpanId": "eee19b7ec3c1b174",
87 "name": "SELECT orders",
88 "kind": 3,
89 "startTimeUnixNano": "1760000000001000000",
90 "endTimeUnixNano": "1760000000009000000",
91 "attributes": [
92 {
93 "key": "db.system",
94 "value": {
95 "stringValue": "postgresql"
96 }
97 },
98 {
99 "key": "db.statement",
100 "value": {
101 "stringValue": "SELECT * FROM orders WHERE id = $1"
102 }
103 },
104 {
105 "key": "db.name",
106 "value": {
107 "stringValue": "shop"
108 }
109 }
110 ]
111 }
112 ]
113 }
114 ]
115 }
116 ],
117 "resourceMetrics": [
118 {
119 "resource": {
120 "attributes": [
121 {
122 "key": "service.name",
123 "value": {
124 "stringValue": "checkout"
125 }
126 }
127 ]
128 },
129 "scopeMetrics": [
130 {
131 "scope": {
132 "name": "io.opentelemetry.tomcat-10.0"
133 },
134 "metrics": [
135 {
136 "name": "http.server.request.duration",
137 "unit": "ms",
138 "histogram": {
139 "aggregationTemporality": 2,
140 "dataPoints": [
141 {
142 "attributes": [
143 {
144 "key": "http.request.method",
145 "value": {
146 "stringValue": "GET"
147 }
148 },
149 {
150 "key": "url.scheme",
151 "value": {
152 "stringValue": "https"
153 }
154 },
155 {
156 "key": "url.full",
157 "value": {
158 "stringValue": "https://shop.example.com/orders/12345"
159 }
160 }
161 ],
162 "count": "1",
163 "sum": 12,
164 "bucketCounts": [
165 "0",
166 "1"
167 ],
168 "explicitBounds": [
169 10
170 ]
171 }
172 ]
173 }
174 }
175 ]
176 }
177 ]
178 }
179 ]
180 }
181};
182
183
184const run = await client.actor("michiganpublictech/otel-semconv-validator").call(input);
185
186
187console.log('Results from dataset');
188console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
189const { items } = await client.dataset(run.defaultDatasetId).listItems();
190items.forEach((item) => {
191 console.dir(item);
192});
193
194