Skip to content

Commit 1ea8cad

Browse files
Merge pull request #1 from AlexanderWert/master
added ocelot-meets-datadog scenario
2 parents e63ca03 + d96b524 commit 1ea8cad

18 files changed

+798
-0
lines changed

ocelot-meets-datadog/.env

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DD_API_KEY=<PUT_YOUR_DATADOG_API_KEY_HERE>

ocelot-meets-datadog/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Ocelot meets Datadog
2+
3+
This is the demo scenario described in the blog post https://www.novatec-gmbh.de/en/blog/ocelot-meets-bits/
4+
In this Demo Ocelot enhances the data collection for Datadog:
5+
![Setup](https://www.novatec-gmbh.de/wp-content/uploads/ocelot-datadog-landscape.png)
6+
7+
To run this Demo do the following:
8+
- Make sure docker is installed on your system
9+
- Get an Datadog API key
10+
- Put the API key into the .env file
11+
- Start the demo with the following command:
12+
```
13+
docker-compose -f docker-compose-datadog.yml up -d
14+
```
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,179 @@
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: c_servlet_request
29+
kind: SERVER
30+
start-span-conditions:
31+
only-if-true: http_is_entry
32+
attributes:
33+
dd_resource: resource_name
34+
dd_type: span_type
35+
'http.method': http_method
36+
'http.status_code': http_status
37+
'dd_metric__dd1.sr.eausr': dd_sampling_rate
38+
pet-type: pet_type
39+
language: jvm
40+
env: demo
41+
auto-trace: true
42+
entry:
43+
span_name:
44+
action: string_concat_3
45+
data-input:
46+
a: http_method
47+
c: http_raw_path
48+
constant-input:
49+
b: " "
50+
resource_name:
51+
action: string_replace_all
52+
constant-input: { regex: "\\/\\d+(?=\\/|$)" , replacement: "/{id}"}
53+
data-input: { string: span_name}
54+
only-if-not-null: span_name
55+
span_type:
56+
action: set
57+
constant-input: {value: "web"}
58+
dd_sampling_rate:
59+
action: set
60+
constant-input: {value: 1.0}
61+
jvm:
62+
action: set
63+
constant-input: {value: "jvm"}
64+
demo:
65+
action: set
66+
constant-input: {value: "demo"}
67+
c_servlet_request:
68+
action: set
69+
constant-input: {value: "servlet.request"}
70+
71+
http_client_apache_client:
72+
tracing:
73+
start-span: true
74+
name: span_name
75+
kind: CLIENT
76+
start-span-conditions:
77+
only-if-true: http_is_entry
78+
attributes:
79+
dd_resource: resource_name
80+
dd_type: span_type
81+
entry:
82+
span_name:
83+
action: string_concat_3
84+
data-input:
85+
a: http_method
86+
c: http_raw_path
87+
constant-input:
88+
b: " "
89+
resource_name:
90+
action: string_replace_all
91+
constant-input: { regex: "\\/\\d+(?=\\/|$)" , replacement: "/{id}"}
92+
data-input: { string: span_name}
93+
only-if-not-null: span_name
94+
span_type:
95+
action: set
96+
constant-input: {value: "web"}
97+
98+
httpurlconnection_tracing_start:
99+
scopes:
100+
httpurlconnection_connect: true
101+
httpurlconnection_getOutputStream: true
102+
tracing:
103+
auto-trace: false
104+
start-span: true
105+
continue-span: span_obj
106+
store-span: span_obj
107+
end-span: false
108+
name: span_name
109+
kind: CLIENT
110+
entry:
111+
span_obj:
112+
action: read_attachment_on_this
113+
constant-input: {key: "span"}
114+
http_raw_path:
115+
action: httpurlconnection_get_path
116+
http_method:
117+
action: httpurlconnection_get_method
118+
span_name:
119+
action: string_concat_3
120+
data-input:
121+
a: http_method
122+
c: http_raw_path
123+
constant-input:
124+
b: " "
125+
post-entry:
126+
span_obj:
127+
action: replace_attachment_on_this
128+
constant-input: {key: "span"}
129+
data-input: {value: span_obj}
130+
131+
httpurlconnection_tracing_end:
132+
scopes:
133+
httpurlconnection_getInputStream: true
134+
tracing:
135+
auto-trace: false
136+
start-span: true
137+
continue-span: span_obj
138+
store-span: span_obj
139+
end-span: true
140+
continue-span-conditions:
141+
only-if-true: httpurlconn_get_is_entry
142+
start-span-conditions:
143+
only-if-true: httpurlconn_get_is_entry
144+
name: span_name
145+
kind: CLIENT
146+
attributes:
147+
dd_resource: resource_name
148+
dd_type: span_type
149+
entry:
150+
httpurlconn_get_is_entry:
151+
action: test_and_set_this_marker
152+
constant-input: {marker: "get_input_stream_invoked"}
153+
span_obj:
154+
action: read_attachment_on_this
155+
constant-input: {key: "span"}
156+
http_raw_path:
157+
action: httpurlconnection_get_path
158+
http_method:
159+
action: httpurlconnection_get_method
160+
span_name:
161+
action: string_concat_3
162+
data-input:
163+
a: http_method
164+
c: http_raw_path
165+
constant-input:
166+
b: " "
167+
resource_name:
168+
action: string_replace_all
169+
constant-input: { regex: "\\/\\d+(?=\\/|$)" , replacement: "/{id}"}
170+
data-input: { string: span_name}
171+
only-if-not-null: span_name
172+
span_type:
173+
action: set
174+
constant-input: {value: "web"}
175+
post-entry:
176+
span_obj:
177+
action: replace_attachment_on_this
178+
constant-input: {key: "span"}
179+
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,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

0 commit comments

Comments
 (0)