Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added ocelot-meets-datadog scenario #1

Merged
merged 1 commit into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ocelot-meets-datadog/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DD_API_KEY=<PUT_YOUR_DATADOG_API_KEY_HERE>
14 changes: 14 additions & 0 deletions ocelot-meets-datadog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Ocelot meets Datadog

This is the demo scenario described in the blog post https://www.novatec-gmbh.de/en/blog/ocelot-meets-bits/
In this Demo Ocelot enhances the data collection for Datadog:
![Setup](https://www.novatec-gmbh.de/wp-content/uploads/ocelot-datadog-landscape.png)

To run this Demo do the following:
- Make sure docker is installed on your system
- Get an Datadog API key
- Put the API key into the .env file
- Start the demo with the following command:
```
docker-compose -f docker-compose-datadog.yml up -d
```
17 changes: 17 additions & 0 deletions ocelot-meets-datadog/configuration-server/agent_mappings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- name: "Gateway"
sources:
- "/gateway"
- "/all"
attributes:
service: "api-gateway"
- name: "Services"
sources:
- "/services"
- "/all"
attributes:
service: ".*-service"
- name: "Default Mapping"
sources:
- "/all"
attributes:
service: ".*"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
inspectit:
instrumentation:
data:
# The application is defined in the API-Gateway, see "application-detection.yml"
application: {down-propagation: GLOBAL}
pet_type:
up-propagation: GLOBAL
down-propagation: GLOBAL

12 changes: 12 additions & 0 deletions ocelot-meets-datadog/configuration-server/files/all/general.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# See https://github.com/inspectIT/inspectit-oce/blob/0.1.M1/inspectit-oce-core/src/main/resources/config/default.yml
# for all the configuration options.
inspectit:
metrics:
# root setting for the polling frequency of all metrics
# when a metrics has no frequency defined separately, this frequency will be used
frequency: 15s
config:
http:
frequency: 10s
logging:
debug: false # set to true to see more details in the agents logs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Parametrizes HTTP paths to be used in metrics
inspectit:
instrumentation:
rules:

parametrize_paths:
scopes:
servletapi_servlet_service: true
servletapi_filter_doFilter: true
httpurlconnection_getInputStream: true
apache_http_client_doExecute: true
exit:
parametrized_http_path:
action: string_replace_all
constant-input: { regex: "\\/\\d+(?=\\/|$)" , replacement: "/{id}"}
data-input: { string: http_raw_path}
only-if-not-null: http_raw_path
179 changes: 179 additions & 0 deletions ocelot-meets-datadog/configuration-server/files/all/tracing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
inspectit:
tracing:
auto-tracing:
frequency: 10ms
instrumentation:
data:
get_input_stream_invoked:
down-propagation: JVM_LOCAL

actions:
string_concat_3:
input:
a: String
b: String
c: String
value: new StringBuilder(a).append(b).append(c).toString()
a_get_simple_method_name:
input:
_methodName: String
_class: Class
value: new StringBuilder(_class.getSimpleName()).append('.').append(_methodName).toString()

rules:
# use the existing rules from the default configuration but enable tracing
http_server_servlet_api:
tracing:
start-span: true
name: c_servlet_request
kind: SERVER
start-span-conditions:
only-if-true: http_is_entry
attributes:
dd_resource: resource_name
dd_type: span_type
'http.method': http_method
'http.status_code': http_status
'dd_metric__dd1.sr.eausr': dd_sampling_rate
pet-type: pet_type
language: jvm
env: demo
auto-trace: true
entry:
span_name:
action: string_concat_3
data-input:
a: http_method
c: http_raw_path
constant-input:
b: " "
resource_name:
action: string_replace_all
constant-input: { regex: "\\/\\d+(?=\\/|$)" , replacement: "/{id}"}
data-input: { string: span_name}
only-if-not-null: span_name
span_type:
action: set
constant-input: {value: "web"}
dd_sampling_rate:
action: set
constant-input: {value: 1.0}
jvm:
action: set
constant-input: {value: "jvm"}
demo:
action: set
constant-input: {value: "demo"}
c_servlet_request:
action: set
constant-input: {value: "servlet.request"}

http_client_apache_client:
tracing:
start-span: true
name: span_name
kind: CLIENT
start-span-conditions:
only-if-true: http_is_entry
attributes:
dd_resource: resource_name
dd_type: span_type
entry:
span_name:
action: string_concat_3
data-input:
a: http_method
c: http_raw_path
constant-input:
b: " "
resource_name:
action: string_replace_all
constant-input: { regex: "\\/\\d+(?=\\/|$)" , replacement: "/{id}"}
data-input: { string: span_name}
only-if-not-null: span_name
span_type:
action: set
constant-input: {value: "web"}

httpurlconnection_tracing_start:
scopes:
httpurlconnection_connect: true
httpurlconnection_getOutputStream: true
tracing:
auto-trace: false
start-span: true
continue-span: span_obj
store-span: span_obj
end-span: false
name: span_name
kind: CLIENT
entry:
span_obj:
action: read_attachment_on_this
constant-input: {key: "span"}
http_raw_path:
action: httpurlconnection_get_path
http_method:
action: httpurlconnection_get_method
span_name:
action: string_concat_3
data-input:
a: http_method
c: http_raw_path
constant-input:
b: " "
post-entry:
span_obj:
action: replace_attachment_on_this
constant-input: {key: "span"}
data-input: {value: span_obj}

httpurlconnection_tracing_end:
scopes:
httpurlconnection_getInputStream: true
tracing:
auto-trace: false
start-span: true
continue-span: span_obj
store-span: span_obj
end-span: true
continue-span-conditions:
only-if-true: httpurlconn_get_is_entry
start-span-conditions:
only-if-true: httpurlconn_get_is_entry
name: span_name
kind: CLIENT
attributes:
dd_resource: resource_name
dd_type: span_type
entry:
httpurlconn_get_is_entry:
action: test_and_set_this_marker
constant-input: {marker: "get_input_stream_invoked"}
span_obj:
action: read_attachment_on_this
constant-input: {key: "span"}
http_raw_path:
action: httpurlconnection_get_path
http_method:
action: httpurlconnection_get_method
span_name:
action: string_concat_3
data-input:
a: http_method
c: http_raw_path
constant-input:
b: " "
resource_name:
action: string_replace_all
constant-input: { regex: "\\/\\d+(?=\\/|$)" , replacement: "/{id}"}
data-input: { string: span_name}
only-if-not-null: span_name
span_type:
action: set
constant-input: {value: "web"}
post-entry:
span_obj:
action: replace_attachment_on_this
constant-input: {key: "span"}
data-input: {value: span_obj}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This configuration defines the application based on the url called at the API-gateway.
# The application is propagated with service calls.
inspectit:
instrumentation:
actions:
get_servlet_application:
imports:
- javax.servlet
- javax.servlet.http
input:
_arg0: ServletRequest
value-body: |
if(_arg0 instanceof HttpServletRequest) {
String path = ((HttpServletRequest)_arg0).getServletPath();
if (path.contains("vets")) {
return "veterinarians";
} else if(path.contains("owner")){
return "customers";
}
}
return null;

rules:
servlet_detect_application:
scopes:
servletapi_servlet_service: true
servletapi_filter_doFilter: true
entry:
application:
action: get_servlet_application
only-if-null: application
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
inspectit:
instrumentation:
scopes:
s_gateway_controller_validate_pet:
type:
name: org.springframework.samples.petclinic.api.boundary.web.ApiGatewayController
methods:
- name: validatePet
matcher-mode: STARTS_WITH

actions:
a_extract_pet_type:
imports:
- org.springframework.samples.petclinic.api.dto
input:
_arg0: PetDetails
value-body: |
return _arg0.getType().getName();

rules:
r_extract_pet_type:
scopes:
s_gateway_controller_validate_pet: true
tracing:
start-span: true
attributes:
pet-type: pet_type
resource: simple_method_name
entry:
pet_type:
action: a_extract_pet_type
simple_method_name:
action: a_get_simple_method_name

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
inspectit:
instrumentation:

scopes:
hsqldb_prepared_statement_execute:
type:
name: org.hsqldb.jdbc.JDBCPreparedStatement
methods:
- name: execute
matcher-mode: STARTS_WITH

data:
db_name: {down-propagation: NONE, is-tag: false}
sql: {down-propagation: NONE, is-tag: false}

actions:
# Extracts the SQL from a PreparedStatement for HSQLDB
hsqldb_prepared_statement_get_sql:
imports:
- org.hsqldb.jdbc
- java.lang.reflect
input:
_this: JDBCPreparedStatement
_class: Class
value-body: |
Field sqlField = _class.getDeclaredField("sql");
sqlField.setAccessible(true);
return sqlField.get(_this);

rules:
# We also trace JDBC calls including their target database
servicegraph_record_jdbc_calls:
tracing:
start-span: true
attributes:
'sql.database': db_name
dd_service: db_name
dd_type: span_type
dd_resource: sql
start-span-conditions:
only-if-true: servicegraph_is_entry
entry:
db_name:
action: get_jdbc_statement_connection_name
span_type:
action: set
constant-input: {value: "sql"}

# Extract the sql and add it to the trace
hsqldb_get_prep_statement_sql:
scopes:
hsqldb_prepared_statement_execute: true
entry:
sql:
action: hsqldb_prepared_statement_get_sql
Loading