Skip to content

Commit

Permalink
Update Docker Compose and configuration files
Browse files Browse the repository at this point in the history
Update Prometheus configuration

Update OpenTelemetry configuration

Update logging and metrics exporters

Refactor code in Program.cs
  • Loading branch information
0GiS0 committed Dec 18, 2023
1 parent c019be3 commit fdb9822
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 34 deletions.
25 changes: 8 additions & 17 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
version: "3.5"
version: "3.8"

services:
app:
# build:
# context: .
# dockerfile: Dockerfile

build:
context: .
dockerfile: Dockerfile
volumes:
- ../..:/workspaces:cached

command: sleep infinity
networks:
- observability
environment:
OTEL_SERVICE_NAME: tour-of-heroes-api
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4317
# OTEL_EXPORTER_JAEGER_ENDPOINT: http://jaeger:14268/api/traces
# OTEL_EXPORTER_JAEGER_AGENT_HOST: jaeger
# OTEL_EXPORTER_JAEGER_AGENT_PORT: 6831
# APPLICATIONINSIGHTS_CONNECTION_STRING: <INSTRUMENTATION_KEY>
ports:
- "127.0.0.1:5010:5010"
- "5010:5010"

db:
image: mcr.microsoft.com/azure-sql-edge
Expand All @@ -36,7 +29,7 @@ services:
jaeger:
image: jaegertracing/all-in-one:latest
ports:
- "127.0.0.1:16686:16686" # Jaeger UI
- "16686:16686" # Jaeger UI
command: --query.ui-config=/etc/jaeger/jaeger-ui.json --collector.otlp.enabled=true --prometheus.server-url=http://prometheus:9090 --prometheus.query.support-spanmetrics-connector=true
environment:
METRICS_STORAGE_TYPE: "prometheus"
Expand All @@ -50,7 +43,7 @@ services:
prometheus:
image: prom/prometheus
ports:
- "127.0.0.1:9090:9090"
- "9090:9090"
networks:
- observability
volumes:
Expand All @@ -60,7 +53,7 @@ services:
image: grafana/loki:latest
command: -config.file=/mnt/config/loki-config.yml
ports:
- "127.0.0.1:3100:3100"
- "3100:3100"
networks:
- observability
volumes:
Expand All @@ -69,7 +62,7 @@ services:
grafana:
image: grafana/grafana
ports:
- "127.0.0.1:3000:3000"
- "3000:3000"
environment:
GF_AUTH_ANONYMOUS_ENABLED: true
GF_AUTH_ANONYMOUS_ORG_ROLE: Admin
Expand All @@ -87,11 +80,9 @@ services:
volumes:
- ./otel-collector-config.yml:/etc/otelcol/otel-collector-config.yml
ports:
- "127.0.0.1:4317:4317"
- "4317:4317"
networks:
- observability
depends_on:
- jaeger

fake-calls:
image: alpine/curl:latest
Expand Down
20 changes: 15 additions & 5 deletions .devcontainer/otel-collector-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ receivers:

# Exporters send data to one or more backends or destinations
exporters:
debug:
# verbosity: detailed
prometheus:
endpoint: "0.0.0.0:8889"

otlp:
endpoint: "jaeger:4317"
tls:
insecure: true

loki:
endpoint: http://loki:3100/loki/api/v1/push

Expand All @@ -40,13 +40,23 @@ processors:

service:
pipelines:
# traces:
# receivers: [zipkin, otlp ]
# exporters: [ debug, otlp, spanmetrics ]
# metrics:
# receivers: [ spanmetrics ]
# exporters: [ debug, prometheus ]
# logs:
# receivers: [ otlp ]
# processors: [ resource ]
# exporters: [ debug, loki ]
traces:
receivers: [ otlp ]
exporters: [ otlp, spanmetrics ]
exporters: [ debug, otlp, spanmetrics ]
metrics:
receivers: [ spanmetrics ]
exporters: [ prometheus ]
exporters: [ debug, prometheus ]
logs:
receivers: [ otlp ]
processors: [ resource ]
exporters: [ loki ]
exporters: [ debug, loki ]
11 changes: 1 addition & 10 deletions .devcontainer/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,16 @@ global:
evaluation_interval: 10s

scrape_configs:
# - job_name: "tour-of-heroes-api"
# static_configs:
# - targets: ["app:5010"] # Replace with actual container hostname and port

# # - job_name: "tour-of-heroes-angular"
# # static_configs:
# # - targets: ["nginx-exporter:9113"] # Replace with actual container hostname and port
- job_name: aggregated-trace-metrics
static_configs:
- targets:
- otel-collector:8889

- job_name: jaeger
static_configs:
- targets:
- jaeger:14269

- job_name: services
static_configs:
- targets:
# - proxy-service:80
- app:5010
10 changes: 8 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
options.SetResourceBuilder(resourceBuilder);

// options.AddConsoleExporter();

options.AddOtlpExporter();

});
Expand All @@ -51,8 +50,11 @@
tracing.AddHttpClientInstrumentation();
// tracing.AddSqlClientInstrumentation();
tracing.AddEntityFrameworkCoreInstrumentation();
// tracing.AddConsoleExporter();

tracing.AddOtlpExporter();

// tracing.AddConsoleExporter();

})
.WithMetrics(metrics =>
{
Expand All @@ -61,7 +63,11 @@
metrics.AddProcessInstrumentation();
metrics.AddRuntimeInstrumentation();
// metrics.AddConsoleExporter();

metrics.AddPrometheusExporter();

metrics.AddOtlpExporter();

});

builder.Services.Configure<AspNetCoreInstrumentationOptions>(options =>
Expand Down

0 comments on commit fdb9822

Please sign in to comment.