Skip to content

Commit 28bb544

Browse files
authored
Adding test JSON spec for service resource auto-inference (#467)
1 parent b277682 commit 28bb544

File tree

1 file changed

+219
-0
lines changed

1 file changed

+219
-0
lines changed
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
[
2+
{
3+
"span": {
4+
"exit": "true",
5+
"type": "custom",
6+
"subtype": "test-subtype"
7+
},
8+
"expected_resource": "test-subtype",
9+
"failure_message": "In the absence of specific context fields, subtype should used"
10+
},
11+
{
12+
"span": {
13+
"exit": "true",
14+
"type": "custom",
15+
"subtype": "test-subtype",
16+
"context": {
17+
"destination": {
18+
"service": {
19+
"resource": "already-set-resource"
20+
}
21+
}
22+
}
23+
},
24+
"expected_resource": "already-set-resource",
25+
"failure_message": "If the `service.resource` is already set, the inference mechanism should not override it"
26+
},
27+
{
28+
"span": {
29+
"exit": "true",
30+
"type": "custom"
31+
},
32+
"expected_resource": "custom",
33+
"failure_message": "In the absence of specific context fields and absence of subtype, the type should be used"
34+
},
35+
{
36+
"span": {
37+
"exit": "false",
38+
"type": "custom",
39+
"subtype": "test-subtype"
40+
},
41+
"expected_resource": null,
42+
"failure_message": "The output for non-exit spans should be `null`"
43+
},
44+
{
45+
"span": {
46+
"exit": "true",
47+
"type": "db",
48+
"subtype": "mysql",
49+
"context": {
50+
"db": {
51+
"instance": "myInstance"
52+
}
53+
}
54+
},
55+
"expected_resource": "mysql/myInstance",
56+
"failure_message": "If `context.db.instance` exists, the output should be: `${subtype}/${context.db.instance}`"
57+
},
58+
{
59+
"span": {
60+
"exit": "true",
61+
"type": "db",
62+
"subtype": "mysql",
63+
"context": {
64+
"db": {
65+
"type": "sql"
66+
}
67+
}
68+
},
69+
"expected_resource": "mysql",
70+
"failure_message": "If `context.db` exists without `context.db.instance`, the subtype should be used"
71+
},
72+
{
73+
"span": {
74+
"exit": "true",
75+
"type": "db",
76+
"context": {
77+
"db": {
78+
"instance": "myInstance"
79+
}
80+
}
81+
},
82+
"expected_resource": "db/myInstance",
83+
"failure_message": "If `context.db.instance` exists and subtype is `null`, the output should be: `${type}/${context.db.instance}`"
84+
},
85+
{
86+
"span": {
87+
"exit": "true",
88+
"type": "db",
89+
"subtype": "elasticsearch",
90+
"context": {
91+
"db": {
92+
"type": "elasticsearch"
93+
},
94+
"http": {
95+
"url": {
96+
"host": "my-cluster.com",
97+
"port": 9200
98+
}
99+
}
100+
}
101+
},
102+
"expected_resource": "elasticsearch",
103+
"failure_message": "If `context.db` exists without `context.db.instance`, the subtype should be used, even if `context.http` exists"
104+
},
105+
{
106+
"span": {
107+
"exit": "true",
108+
"type": "messaging",
109+
"subtype": "msg-http-client",
110+
"context": {
111+
"message": {
112+
"body": "Text message"
113+
},
114+
"http": {
115+
"url": {
116+
"host": "my-broker.com",
117+
"port": 8888
118+
}
119+
}
120+
}
121+
},
122+
"expected_resource": "msg-http-client",
123+
"failure_message": "If `context.message` exists without `context.message.queue.name`, the subtype should be used, even if `context.http` exists"
124+
},
125+
{
126+
"span": {
127+
"exit": "true",
128+
"type": "http",
129+
"context": {
130+
"http": {
131+
"url": {
132+
"host": "my-cluster.com",
133+
"port": 9200
134+
}
135+
}
136+
}
137+
},
138+
"expected_resource": "my-cluster.com:9200",
139+
"failure_message": "If `context.http.url` exists, output should be `${context.http.url.host}:${context.http.url.port}"
140+
},
141+
{
142+
"span": {
143+
"exit": "true",
144+
"type": "http",
145+
"context": {
146+
"http": {
147+
"url": {
148+
"host": "my-cluster.com",
149+
"port": -1
150+
}
151+
}
152+
}
153+
},
154+
"expected_resource": "my-cluster.com",
155+
"failure_message": "Negative `context.http.url.port` should be omitted from output"
156+
},
157+
{
158+
"span": {
159+
"exit": "true",
160+
"type": "http",
161+
"context": {
162+
"http": {
163+
"url": {
164+
"host": "my-cluster.com"
165+
}
166+
}
167+
}
168+
},
169+
"expected_resource": "my-cluster.com",
170+
"failure_message": "If `context.http.url.port` does not exist, output should be `${context.http.url.host}`"
171+
},
172+
{
173+
"span": {
174+
"exit": "true",
175+
"type": "messaging",
176+
"context": {
177+
"message": {
178+
"body": "Text message",
179+
"queue": {
180+
"name": "myQueue"
181+
}
182+
}
183+
}
184+
},
185+
"expected_resource": "messaging/myQueue",
186+
"failure_message": "If `context.message` exists, and subtype is `null`, output should be `${type}:${context.message.queue.name}"
187+
},
188+
{
189+
"span": {
190+
"exit": "true",
191+
"type": "messaging",
192+
"subtype": "kafka",
193+
"context": {
194+
"message": {
195+
"body": "Text message",
196+
"queue": {
197+
"name": "myQueue"
198+
}
199+
}
200+
}
201+
},
202+
"expected_resource": "kafka/myQueue",
203+
"failure_message": "If `context.message` exists, output should be `${subtype}:${context.message.queue.name}"
204+
},
205+
{
206+
"span": {
207+
"exit": "true",
208+
"type": "messaging",
209+
"subtype": "kafka",
210+
"context": {
211+
"message": {
212+
"body": "Text message"
213+
}
214+
}
215+
},
216+
"expected_resource": "kafka",
217+
"failure_message": "If `context.message` exists without `context.message.queue.name`, output should be `${subtype}`"
218+
}
219+
]

0 commit comments

Comments
 (0)