Skip to content

Commit

Permalink
Add Tracing to the Apodini Service (#93)
Browse files Browse the repository at this point in the history
Co-authored-by: Paul Schmiedmayer <[email protected]>
Co-authored-by: Philipp Zagar <[email protected]>
  • Loading branch information
3 people authored Apr 13, 2022
1 parent 239d71e commit 8302f33
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ KIBANA_SYSTEM_PASSWORD=FA2021
LOGSTASH_SYSTEM_USER=logstash_system
LOGSTASH_SYSTEM_PASSWORD=FA2021

# OpenTelemetry

OTLP_HOST=otel-collector
OTLP_PORT=4137

REACT_APP_SCIENCE_LAB_MAP_ACCESS_TOKEN=<ACCESS TOKEN>
21 changes: 21 additions & 0 deletions Observability/otel-collector/collector-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
receivers:
otlp:
protocols:
grpc:
endpoint: otel-collector:4317

exporters:
logging:
logLevel: debug

jaeger:
endpoint: "jaeger:14250"
tls:
insecure: true


service:
pipelines:
traces:
receivers: otlp
exporters: [logging, jaeger]
1 change: 1 addition & 0 deletions WebService/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ let package = Package(
.product(name: "ApodiniREST", package: "Apodini"),
.product(name: "ApodiniObserve", package: "Apodini"),
.product(name: "ApodiniObservePrometheus", package: "ApodiniObservePrometheus"),
.product(name: "ApodiniObserveOpenTelemetry", package: "Apodini"),
.product(name: "ApodiniOpenAPI", package: "Apodini"),
.product(name: "ApodiniDatabase", package: "Apodini"),
.product(name: "ApodiniAuthorization", package: "Apodini"),
Expand Down
10 changes: 10 additions & 0 deletions WebService/Sources/WebService/main.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation
import Apodini
import ApodiniObserve
import ApodiniObserveOpenTelemetry
import ApodiniObservePrometheus
import ApodiniOpenAPI
import ApodiniREST
Expand Down Expand Up @@ -57,6 +58,11 @@ struct FA2021WebService: WebService {
),
systemMetricsConfiguration: .default
)

// Setup of Tracing with an OpenTelemetry backend
TracingConfiguration(
.defaultOpenTelemetry(serviceName: "FA2021")
)

// Setup of ApodiniAuthorization
JWTSigner(.hs256(key: "secret"))
Expand All @@ -83,12 +89,16 @@ struct FA2021WebService: WebService {
var content: some Component {
MeasurementComponent()
.record(.all)
.trace()
SensorTypeComponent()
.record(.all)
.trace()
AuthComponent()
.record(.all)
.trace()
DummyComponent()
.record(.all)
.trace()
}
}

Expand Down
18 changes: 18 additions & 0 deletions docker-compose-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,24 @@ services:
depends_on:
- prometheus

otel-collector:
image: otel/opentelemetry-collector-contrib:latest
container_name: otel-collector-develop
command: ["--config=/etc/config.yml"]
volumes:
- ./Observability/otel-collector/collector-config.yml:/etc/config.yml
ports:
# Expose on host port 4317
- 4317:4317
depends_on: [jaeger]

jaeger:
image: jaegertracing/all-in-one:latest
container_name: jaeger-develop
ports:
# Expose on host port 16686
- 16686:16686

volumes:
database-data: # Volume for PostgreSQL
elasticsearch: # Volume for ElasticSearch
Expand Down
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ services:
POSTGRES_DB: ${POSTGRES_DB}
LOGSTASH_HOST: ${LOGSTASH_HOST}
LOGSTASH_PORT: ${LOGSTASH_PORT}
OTLP_HOST: ${OTLP_HOST}
OTLP_PORT: ${OTLP_PORT}
expose:
# The webservice is exposed internally to the reverse proxy
- "8080"
Expand Down Expand Up @@ -222,6 +224,24 @@ services:
depends_on:
- prometheus

otel-collector:
image: otel/opentelemetry-collector-contrib:latest
container_name: otel-collector
command: ["--config=/etc/config.yml"]
volumes:
- ./Observability/otel-collector/collector-config.yml:/etc/config.yml
ports:
# Expose on host port 4317
- 4317:4317
depends_on: [jaeger]

jaeger:
image: jaegertracing/all-in-one:latest
container_name: jaeger
ports:
# Expose on host port 16686
- 16686:16686

volumes:
database-data: # Volume for PostgreSQL
elasticsearch: # Volume for ElasticSearch
Expand Down

0 comments on commit 8302f33

Please sign in to comment.