Skip to content

Commit f2a806a

Browse files
author
Jonas Kunz
authored
Merge pull request #3 from matthias-huber/master
Added Wavefront Demo
2 parents faecfeb + bd63264 commit f2a806a

18 files changed

+1961
-0
lines changed

ocelot-meets-wavefront/.env

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
WAVEFRONT_URL=https://longboard.wavefront.com/api/
2+
WAVEFRONT_TOKEN=<api-key>

ocelot-meets-wavefront/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Ocelot meets Wavefront
2+
3+
This is the demo scenario described in the blog post https://www.novatec-gmbh.de/en/blog/ocelot-meets-wavefront/
4+
In this Demo Ocelot enhances the data collection for Wavefront:
5+
![Setup](https://www.novatec-gmbh.de/wp-content/uploads/openapm_wavefront.png)
6+
7+
To run this Demo do the following:
8+
- Make sure docker is installed on your system
9+
- Get an Wavefront API key
10+
- Put the API key into the .env file
11+
- Maybe you also have to adapt the Wavefront URL in the .env file
12+
- Start the demo with the following command:
13+
```
14+
docker-compose -f docker-compose-wavefront.yml up -d
15+
```
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,7 @@
1+
inspectit:
2+
instrumentation:
3+
data:
4+
pet_type:
5+
up-propagation: GLOBAL
6+
down-propagation: GLOBAL
7+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
inspectit:
2+
tags:
3+
extra:
4+
application: PetClinic
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,21 @@
1+
inspectit:
2+
metrics:
3+
definitions:
4+
'[http/in/responsetime]':
5+
views:
6+
'[http/in/count]':
7+
tags:
8+
pet_type: true
9+
'[http/in/responsetime/sum]':
10+
tags:
11+
pet_type: true
12+
13+
instrumentation:
14+
rules:
15+
16+
http_server_servlet_api:
17+
metrics:
18+
'[http/in/responsetime]':
19+
value: http_duration
20+
data-tags:
21+
pet_type: pet_type
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
httpurlconnection_connect: true
13+
httpurlconnection_getOutputStream: true
14+
entry:
15+
parametrized_http_path:
16+
action: string_replace_all
17+
constant-input: { regex: "\\/\\d+(?=\\/|$)" , replacement: "/{id}"}
18+
data-input: { string: http_raw_path}
19+
only-if-not-null: http_raw_path
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
inspectit:
2+
tracing:
3+
auto-tracing:
4+
frequency: 10ms
5+
6+
instrumentation:
7+
data:
8+
get_input_stream_invoked:
9+
down-propagation: JVM_LOCAL
10+
11+
actions:
12+
string_concat_3:
13+
input:
14+
a: String
15+
b: String
16+
c: String
17+
value: new StringBuilder(a).append(b).append(c).toString()
18+
a_get_simple_method_name:
19+
input:
20+
_methodName: String
21+
_class: Class
22+
value: new StringBuilder(_class.getSimpleName()).append('.').append(_methodName).toString()
23+
24+
rules:
25+
# use the existing rules from the default configuration but enable tracing
26+
http_server_servlet_api:
27+
tracing:
28+
start-span: true
29+
name: span_name
30+
kind: SERVER
31+
start-span-conditions:
32+
only-if-true: http_is_entry
33+
attributes:
34+
'http.method': http_method
35+
'http.status_code': http_status
36+
pet-type: pet_type
37+
auto-trace: true
38+
entry:
39+
span_name:
40+
action: string_concat_3
41+
data-input:
42+
a: http_method
43+
c: parametrized_http_path
44+
constant-input:
45+
b: " "
46+
47+
http_client_apache_client:
48+
tracing:
49+
start-span: true
50+
name: span_name
51+
kind: CLIENT
52+
start-span-conditions:
53+
only-if-true: http_is_entry
54+
entry:
55+
span_name:
56+
action: string_concat_3
57+
data-input:
58+
a: http_method
59+
c: parametrized_http_path
60+
constant-input:
61+
b: " "
62+
span_type:
63+
action: set
64+
constant-input: {value: "web"}
65+
66+
67+
httpurlconnection_tracing_start:
68+
scopes:
69+
httpurlconnection_connect: true
70+
httpurlconnection_getOutputStream: true
71+
tracing:
72+
auto-trace: false
73+
start-span: true
74+
continue-span: span_obj
75+
store-span: span_obj
76+
end-span: false
77+
name: span_name
78+
kind: CLIENT
79+
entry:
80+
span_obj:
81+
action: read_attachment_on_this
82+
constant-input: {key: "span"}
83+
http_raw_path:
84+
action: httpurlconnection_get_path
85+
http_method:
86+
action: httpurlconnection_get_method
87+
span_name:
88+
action: string_concat_3
89+
data-input:
90+
a: http_method
91+
c: parametrized_http_path
92+
constant-input:
93+
b: " "
94+
post-entry:
95+
span_obj:
96+
action: replace_attachment_on_this
97+
constant-input: {key: "span"}
98+
data-input: {value: span_obj}
99+
100+
httpurlconnection_tracing_end:
101+
scopes:
102+
httpurlconnection_getInputStream: true
103+
tracing:
104+
auto-trace: false
105+
start-span: true
106+
continue-span: span_obj
107+
store-span: span_obj
108+
end-span: true
109+
continue-span-conditions:
110+
only-if-true: httpurlconn_get_is_entry
111+
start-span-conditions:
112+
only-if-true: httpurlconn_get_is_entry
113+
name: span_name
114+
kind: CLIENT
115+
entry:
116+
httpurlconn_get_is_entry:
117+
action: test_and_set_this_marker
118+
constant-input: {marker: "get_input_stream_invoked"}
119+
span_obj:
120+
action: read_attachment_on_this
121+
constant-input: {key: "span"}
122+
http_raw_path:
123+
action: httpurlconnection_get_path
124+
http_method:
125+
action: httpurlconnection_get_method
126+
span_name:
127+
action: string_concat_3
128+
data-input:
129+
a: http_method
130+
c: parametrized_http_path
131+
constant-input:
132+
b: " "
133+
post-entry:
134+
span_obj:
135+
action: replace_attachment_on_this
136+
constant-input: {key: "span"}
137+
data-input: {value: span_obj}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
resource: simple_method_name
29+
entry:
30+
pet_type:
31+
action: a_extract_pet_type
32+
simple_method_name:
33+
action: a_get_simple_method_name
34+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
dd_service: db_name
38+
dd_type: span_type
39+
dd_resource: sql
40+
start-span-conditions:
41+
only-if-true: servicegraph_is_entry
42+
entry:
43+
db_name:
44+
action: get_jdbc_statement_connection_name
45+
span_type:
46+
action: set
47+
constant-input: {value: "sql"}
48+
49+
# Extract the sql and add it to the trace
50+
hsqldb_get_prep_statement_sql:
51+
scopes:
52+
hsqldb_prepared_statement_execute: true
53+
entry:
54+
sql:
55+
action: hsqldb_prepared_statement_get_sql
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
actions:
13+
# Extracts the SQL from a PreparedStatement for HSQLDB
14+
hsqldb_prepared_statement_get_sql:
15+
imports:
16+
- org.hsqldb.jdbc
17+
- java.lang.reflect
18+
input:
19+
_this: JDBCPreparedStatement
20+
_class: Class
21+
value-body: |
22+
Field sqlField = _class.getDeclaredField("sql");
23+
sqlField.setAccessible(true);
24+
return sqlField.get(_this);
25+
26+
rules:
27+
# We also trace JDBC calls including their target database
28+
servicegraph_record_jdbc_calls:
29+
tracing:
30+
start-span: true
31+
attributes:
32+
'sql.database': db_name
33+
'sql.query': sql
34+
start-span-conditions:
35+
only-if-true: servicegraph_is_entry
36+
entry:
37+
db_name:
38+
action: get_jdbc_statement_connection_name
39+
span_type:
40+
action: set
41+
constant-input: {value: "sql"}
42+
43+
# Extract the sql and add it to the trace
44+
hsqldb_get_prep_statement_sql:
45+
scopes:
46+
hsqldb_prepared_statement_execute: true
47+
entry:
48+
sql:
49+
action: hsqldb_prepared_statement_get_sql

0 commit comments

Comments
 (0)