1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "telemetry": {
10 "resourceSpans": [{
11 "resource": { "attributes": [
12 {
13 "key": "service.name",
14 "value": { "stringValue": "checkout" },
15 },
16 {
17 "key": "deployment.environment.name",
18 "value": { "stringValue": "demo" },
19 },
20 ] },
21 "scopeSpans": [{
22 "scope": {
23 "name": "io.opentelemetry.http",
24 "version": "2.9.0",
25 },
26 "spans": [
27 {
28 "traceId": "5b8efff798038103d269b633813fc60c",
29 "spanId": "eee19b7ec3c1b174",
30 "name": "GET /api/users/jane.doe@example.com/orders",
31 "kind": 2,
32 "attributes": [
33 {
34 "key": "http.request.method",
35 "value": { "stringValue": "GET" },
36 },
37 {
38 "key": "url.full",
39 "value": { "stringValue": "https://shop.example.com/api/users/jane.doe@example.com/orders?api_key=demo-k3y-0f-fake-shop-9921&page=2" },
40 },
41 {
42 "key": "http.request.header.authorization",
43 "value": { "arrayValue": { "values": [{ "stringValue": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyLTQyIiwibmFtZSI6IkphbmUgRG9lIiwiZW1haWwiOiJqYW5lLmRvZUBleGFtcGxlLmNvbSIsImlhdCI6MTcwMDAwMDAwMH0.ZGVtby1zaWduYXR1cmUtbm90LXJlYWw" }] } },
44 },
45 {
46 "key": "client.address",
47 "value": { "stringValue": "203.0.113.42" },
48 },
49 {
50 "key": "user.id",
51 "value": { "stringValue": "user-42" },
52 },
53 {
54 "key": "app.customer_ref",
55 "value": { "stringValue": "CUST-00012345" },
56 },
57 {
58 "key": "geo.location.lat",
59 "value": { "doubleValue": 42.3314 },
60 },
61 {
62 "key": "geo.location.lon",
63 "value": { "doubleValue": -83.0458 },
64 },
65 ],
66 "events": [{
67 "name": "exception",
68 "attributes": [
69 {
70 "key": "exception.type",
71 "value": { "stringValue": "OperationalError" },
72 },
73 {
74 "key": "exception.message",
75 "value": { "stringValue": "could not connect to postgres://orders_app:Sup3rS3cretPw@db.internal:5432/orders" },
76 },
77 ],
78 }],
79 "status": {
80 "code": 2,
81 "message": "upstream payment call failed",
82 },
83 },
84 {
85 "traceId": "5b8efff798038103d269b633813fc60c",
86 "spanId": "aaa19b7ec3c1b175",
87 "parentSpanId": "eee19b7ec3c1b174",
88 "name": "SELECT orders",
89 "kind": 3,
90 "attributes": [
91 {
92 "key": "db.system",
93 "value": { "stringValue": "postgresql" },
94 },
95 {
96 "key": "db.query.text",
97 "value": { "stringValue": "SELECT * FROM customers WHERE email = 'jane.doe@example.com' AND phone = '+1 202-555-0143'" },
98 },
99 ],
100 },
101 ],
102 }],
103 }],
104 "resourceLogs": [{
105 "resource": { "attributes": [
106 {
107 "key": "service.name",
108 "value": { "stringValue": "payments" },
109 },
110 {
111 "key": "deployment.environment.name",
112 "value": { "stringValue": "demo" },
113 },
114 ] },
115 "scopeLogs": [{
116 "scope": { "name": "payments.logger" },
117 "logRecords": [
118 {
119 "severityText": "INFO",
120 "body": { "stringValue": "Loaded AWS credentials AKIAIOSFODNN7EXAMPLE from environment" },
121 "attributes": [
122 {
123 "key": "payment.card_number",
124 "value": { "stringValue": "4111 1111 1111 1111" },
125 },
126 {
127 "key": "payment.iban",
128 "value": { "stringValue": "GB82 WEST 1234 5698 7654 32" },
129 },
130 ],
131 },
132 {
133 "severityText": "WARN",
134 "body": { "kvlistValue": { "values": [
135 {
136 "key": "event",
137 "value": { "stringValue": "patient_lookup" },
138 },
139 {
140 "key": "patient",
141 "value": { "kvlistValue": { "values": [
142 {
143 "key": "mrn",
144 "value": { "stringValue": "MRN-00482913" },
145 },
146 {
147 "key": "ssn",
148 "value": { "stringValue": "078-05-1120" },
149 },
150 {
151 "key": "dob",
152 "value": { "stringValue": "1985-03-12" },
153 },
154 ] } },
155 },
156 {
157 "key": "note",
158 "value": { "stringValue": "Patient diagnosis E11.9, prescribed metformin" },
159 },
160 ] } },
161 "attributes": [],
162 },
163 ],
164 }],
165 }],
166 "resourceMetrics": [{
167 "resource": { "attributes": [
168 {
169 "key": "service.name",
170 "value": { "stringValue": "checkout" },
171 },
172 {
173 "key": "deployment.environment.name",
174 "value": { "stringValue": "demo" },
175 },
176 ] },
177 "scopeMetrics": [{
178 "scope": { "name": "io.opentelemetry.http" },
179 "metrics": [{
180 "name": "http.server.request.duration",
181 "unit": "s",
182 "description": "Duration of HTTP server requests.",
183 "histogram": {
184 "aggregationTemporality": 2,
185 "dataPoints": [{
186 "count": "3",
187 "sum": 0.42,
188 "attributes": [
189 {
190 "key": "http.route",
191 "value": { "stringValue": "/api/users/{id}/orders" },
192 },
193 {
194 "key": "user.email",
195 "value": { "stringValue": "john.smith@example.org" },
196 },
197 ],
198 }],
199 },
200 }],
201 }],
202 }],
203 },
204 "customPatterns": [{
205 "name": "customer-ref",
206 "pattern": "CUST-[0-9]{8}",
207 "severity": "medium",
208 "action": "hash",
209 }],
210}
211
212
213run = client.actor("michiganpublictech/otel-pii-leak-detector").call(run_input=run_input)
214
215
216print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
217for item in client.dataset(run.default_dataset_id).iterate_items():
218 print(item)
219
220