Skip to content

Commit faecfeb

Browse files
Merge pull request #2 from AlexanderWert/master
Added lightstep demo
2 parents 1ea8cad + 1400512 commit faecfeb

17 files changed

+831
-0
lines changed

ocelot-meets-lightstep/.env

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
LIGHTSTEP_TOKEN=<PUT_YOUR_LIGHTSTPE_ACCESS_TOKEN_HERE>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
- name: "Gateway"
2+
sources:
3+
- "/gateway"
4+
- "/all"
5+
attributes:
6+
service: "api-gateway"
7+
- name: "Services"
8+
sources:
9+
- "/services"
10+
- "/all"
11+
attributes:
12+
service: ".*-service"
13+
- name: "Default Mapping"
14+
sources:
15+
- "/all"
16+
attributes:
17+
service: ".*"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
inspectit:
2+
instrumentation:
3+
data:
4+
# The application is defined in the API-Gateway, see "application-detection.yml"
5+
application: {down-propagation: GLOBAL}
6+
pet_type:
7+
up-propagation: GLOBAL
8+
down-propagation: GLOBAL
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# See https://github.com/inspectIT/inspectit-oce/blob/0.1.M1/inspectit-oce-core/src/main/resources/config/default.yml
2+
# for all the configuration options.
3+
inspectit:
4+
metrics:
5+
# root setting for the polling frequency of all metrics
6+
# when a metrics has no frequency defined separately, this frequency will be used
7+
frequency: 15s
8+
config:
9+
http:
10+
frequency: 10s
11+
logging:
12+
debug: false # set to true to see more details in the agents logs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Parametrizes HTTP paths to be used in metrics
2+
inspectit:
3+
instrumentation:
4+
rules:
5+
6+
parametrize_paths:
7+
scopes:
8+
servletapi_servlet_service: true
9+
servletapi_filter_doFilter: true
10+
httpurlconnection_getInputStream: true
11+
apache_http_client_doExecute: true
12+
exit:
13+
parametrized_http_path:
14+
action: string_replace_all
15+
constant-input: { regex: "\\/\\d+(?=\\/|$)" , replacement: "/{id}"}
16+
data-input: { string: http_raw_path}
17+
only-if-not-null: http_raw_path
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
inspectit:
2+
tracing:
3+
auto-tracing:
4+
frequency: 10ms
5+
instrumentation:
6+
data:
7+
get_input_stream_invoked:
8+
down-propagation: JVM_LOCAL
9+
10+
actions:
11+
string_concat_3:
12+
input:
13+
a: String
14+
b: String
15+
c: String
16+
value: new StringBuilder(a).append(b).append(c).toString()
17+
a_get_simple_method_name:
18+
input:
19+
_methodName: String
20+
_class: Class
21+
value: new StringBuilder(_class.getSimpleName()).append('.').append(_methodName).toString()
22+
23+
rules:
24+
# use the existing rules from the default configuration but enable tracing
25+
http_server_servlet_api:
26+
tracing:
27+
start-span: true
28+
name: resource_name
29+
kind: SERVER
30+
start-span-conditions:
31+
only-if-true: http_is_entry
32+
attributes:
33+
'http.method': http_method
34+
pet-type: pet_type
35+
'ingress.operation': t_r_u_e
36+
auto-trace: false
37+
entry:
38+
span_name:
39+
action: string_concat_3
40+
data-input:
41+
a: http_method
42+
c: http_raw_path
43+
constant-input:
44+
b: " "
45+
resource_name:
46+
action: string_replace_all
47+
constant-input: { regex: "\\/\\d+(?=\\/|$)" , replacement: "/{id}"}
48+
data-input: { string: span_name}
49+
only-if-not-null: span_name
50+
t_r_u_e:
51+
action: set
52+
constant-input: {value: true}
53+
54+
55+
http_client_apache_client:
56+
tracing:
57+
start-span: true
58+
name: resource_name
59+
kind: CLIENT
60+
start-span-conditions:
61+
only-if-true: http_is_entry
62+
entry:
63+
span_name:
64+
action: string_concat_3
65+
data-input:
66+
a: http_method
67+
c: http_raw_path
68+
constant-input:
69+
b: " "
70+
resource_name:
71+
action: string_replace_all
72+
constant-input: { regex: "\\/\\d+(?=\\/|$)" , replacement: "/{id}"}
73+
data-input: { string: span_name}
74+
only-if-not-null: span_name
75+
76+
httpurlconnection_tracing_start:
77+
scopes:
78+
httpurlconnection_connect: true
79+
httpurlconnection_getOutputStream: true
80+
tracing:
81+
auto-trace: false
82+
start-span: true
83+
continue-span: span_obj
84+
store-span: span_obj
85+
end-span: false
86+
name: resource_name
87+
kind: CLIENT
88+
entry:
89+
span_obj:
90+
action: read_attachment_on_this
91+
constant-input: {key: "span"}
92+
http_raw_path:
93+
action: httpurlconnection_get_path
94+
http_method:
95+
action: httpurlconnection_get_method
96+
span_name:
97+
action: string_concat_3
98+
data-input:
99+
a: http_method
100+
c: http_raw_path
101+
constant-input:
102+
b: " "
103+
resource_name:
104+
action: string_replace_all
105+
constant-input: { regex: "\\/\\d+(?=\\/|$)" , replacement: "/{id}"}
106+
data-input: { string: span_name}
107+
only-if-not-null: span_name
108+
post-entry:
109+
span_obj:
110+
action: replace_attachment_on_this
111+
constant-input: {key: "span"}
112+
data-input: {value: span_obj}
113+
114+
httpurlconnection_tracing_end:
115+
scopes:
116+
httpurlconnection_getInputStream: true
117+
tracing:
118+
auto-trace: false
119+
start-span: true
120+
continue-span: span_obj
121+
store-span: span_obj
122+
end-span: true
123+
continue-span-conditions:
124+
only-if-true: httpurlconn_get_is_entry
125+
start-span-conditions:
126+
only-if-true: httpurlconn_get_is_entry
127+
name: resource_name
128+
kind: CLIENT
129+
entry:
130+
httpurlconn_get_is_entry:
131+
action: test_and_set_this_marker
132+
constant-input: {marker: "get_input_stream_invoked"}
133+
span_obj:
134+
action: read_attachment_on_this
135+
constant-input: {key: "span"}
136+
http_raw_path:
137+
action: httpurlconnection_get_path
138+
http_method:
139+
action: httpurlconnection_get_method
140+
span_name:
141+
action: string_concat_3
142+
data-input:
143+
a: http_method
144+
c: http_raw_path
145+
constant-input:
146+
b: " "
147+
resource_name:
148+
action: string_replace_all
149+
constant-input: { regex: "\\/\\d+(?=\\/|$)" , replacement: "/{id}"}
150+
data-input: { string: span_name}
151+
only-if-not-null: span_name
152+
post-entry:
153+
span_obj:
154+
action: replace_attachment_on_this
155+
constant-input: {key: "span"}
156+
data-input: {value: span_obj}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This configuration defines the application based on the url called at the API-gateway.
2+
# The application is propagated with service calls.
3+
inspectit:
4+
instrumentation:
5+
actions:
6+
get_servlet_application:
7+
imports:
8+
- javax.servlet
9+
- javax.servlet.http
10+
input:
11+
_arg0: ServletRequest
12+
value-body: |
13+
if(_arg0 instanceof HttpServletRequest) {
14+
String path = ((HttpServletRequest)_arg0).getServletPath();
15+
if (path.contains("vets")) {
16+
return "veterinarians";
17+
} else if(path.contains("owner")){
18+
return "customers";
19+
}
20+
}
21+
return null;
22+
23+
rules:
24+
servlet_detect_application:
25+
scopes:
26+
servletapi_servlet_service: true
27+
servletapi_filter_doFilter: true
28+
entry:
29+
application:
30+
action: get_servlet_application
31+
only-if-null: application
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
inspectit:
2+
instrumentation:
3+
scopes:
4+
s_gateway_controller_validate_pet:
5+
type:
6+
name: org.springframework.samples.petclinic.api.boundary.web.ApiGatewayController
7+
methods:
8+
- name: validatePet
9+
matcher-mode: STARTS_WITH
10+
11+
actions:
12+
a_extract_pet_type:
13+
imports:
14+
- org.springframework.samples.petclinic.api.dto
15+
input:
16+
_arg0: PetDetails
17+
value-body: |
18+
return _arg0.getType().getName();
19+
20+
rules:
21+
r_extract_pet_type:
22+
scopes:
23+
s_gateway_controller_validate_pet: true
24+
tracing:
25+
start-span: true
26+
attributes:
27+
pet-type: pet_type
28+
entry:
29+
pet_type:
30+
action: a_extract_pet_type
31+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
inspectit:
2+
instrumentation:
3+
4+
scopes:
5+
hsqldb_prepared_statement_execute:
6+
type:
7+
name: org.hsqldb.jdbc.JDBCPreparedStatement
8+
methods:
9+
- name: execute
10+
matcher-mode: STARTS_WITH
11+
12+
data:
13+
db_name: {down-propagation: NONE, is-tag: false}
14+
sql: {down-propagation: NONE, is-tag: false}
15+
16+
actions:
17+
# Extracts the SQL from a PreparedStatement for HSQLDB
18+
hsqldb_prepared_statement_get_sql:
19+
imports:
20+
- org.hsqldb.jdbc
21+
- java.lang.reflect
22+
input:
23+
_this: JDBCPreparedStatement
24+
_class: Class
25+
value-body: |
26+
Field sqlField = _class.getDeclaredField("sql");
27+
sqlField.setAccessible(true);
28+
return sqlField.get(_this);
29+
30+
rules:
31+
# We also trace JDBC calls including their target database
32+
servicegraph_record_jdbc_calls:
33+
tracing:
34+
start-span: true
35+
attributes:
36+
'sql.database': db_name
37+
'sql.query': db_name
38+
start-span-conditions:
39+
only-if-true: servicegraph_is_entry
40+
entry:
41+
db_name:
42+
action: get_jdbc_statement_connection_name
43+
span_type:
44+
action: set
45+
constant-input: {value: "sql"}
46+
47+
# Extract the sql and add it to the trace
48+
hsqldb_get_prep_statement_sql:
49+
scopes:
50+
hsqldb_prepared_statement_execute: true
51+
entry:
52+
sql:
53+
action: hsqldb_prepared_statement_get_sql

0 commit comments

Comments
 (0)