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 Wavefront Demo #3

Merged
merged 1 commit into from
May 5, 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
2 changes: 2 additions & 0 deletions ocelot-meets-wavefront/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
WAVEFRONT_URL=https://longboard.wavefront.com/api/
WAVEFRONT_TOKEN=<api-key>
15 changes: 15 additions & 0 deletions ocelot-meets-wavefront/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Ocelot meets Wavefront

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

To run this Demo do the following:
- Make sure docker is installed on your system
- Get an Wavefront API key
- Put the API key into the .env file
- Maybe you also have to adapt the Wavefront URL in the .env file
- Start the demo with the following command:
```
docker-compose -f docker-compose-wavefront.yml up -d
```
17 changes: 17 additions & 0 deletions ocelot-meets-wavefront/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,7 @@
inspectit:
instrumentation:
data:
pet_type:
up-propagation: GLOBAL
down-propagation: GLOBAL

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
inspectit:
tags:
extra:
application: PetClinic
12 changes: 12 additions & 0 deletions ocelot-meets-wavefront/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,21 @@
inspectit:
metrics:
definitions:
'[http/in/responsetime]':
views:
'[http/in/count]':
tags:
pet_type: true
'[http/in/responsetime/sum]':
tags:
pet_type: true

instrumentation:
rules:

http_server_servlet_api:
metrics:
'[http/in/responsetime]':
value: http_duration
data-tags:
pet_type: pet_type
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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
httpurlconnection_connect: true
httpurlconnection_getOutputStream: true
entry:
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
137 changes: 137 additions & 0 deletions ocelot-meets-wavefront/configuration-server/files/all/tracing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
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: span_name
kind: SERVER
start-span-conditions:
only-if-true: http_is_entry
attributes:
'http.method': http_method
'http.status_code': http_status
pet-type: pet_type
auto-trace: true
entry:
span_name:
action: string_concat_3
data-input:
a: http_method
c: parametrized_http_path
constant-input:
b: " "

http_client_apache_client:
tracing:
start-span: true
name: span_name
kind: CLIENT
start-span-conditions:
only-if-true: http_is_entry
entry:
span_name:
action: string_concat_3
data-input:
a: http_method
c: parametrized_http_path
constant-input:
b: " "
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: parametrized_http_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
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: parametrized_http_path
constant-input:
b: " "
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,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
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
inspectit:
instrumentation:

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

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
'sql.query': 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