Skip to content

Commit

Permalink
continuing fixing issues and working on OpenTelemetry for metrics, tr…
Browse files Browse the repository at this point in the history
…aces and logs.

also trying to correctly setup the otel collector, prometheus, loki, tempo and grafana locally.
  • Loading branch information
macel94 committed Jan 20, 2024
1 parent 0a63fc7 commit 5676d54
Show file tree
Hide file tree
Showing 12 changed files with 188 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/.dapr/components/pubsub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ spec:
version: v1
metadata:
- name: redisHost
value: localhost:6379
value: redis:6379
- name: redisPassword
value: ""
2 changes: 1 addition & 1 deletion src/.dapr/components/statestore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ spec:
version: v1
metadata:
- name: redisHost
value: localhost:6379
value: redis:6379
- name: redisPassword
value: ""
- name: actorStateStore
Expand Down
21 changes: 14 additions & 7 deletions src/BlazorPong.SignalR/BlazorPong.SignalR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0">
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Version="8.0.0" />
<PackageReference Include="StackExchange.Redis" Version="2.7.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Version="8.0.1" />
<PackageReference Include="StackExchange.Redis" Version="2.7.17" />

<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.5.0-rc.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.7.0" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion src/BlazorPong.SignalR/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
});
});


var app = builder.Build();
app.UseCors("AllowAnyOriginPolicy");
app.MapHub<GameHub>("/gamehub");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.1" />
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components" Version="4.*-* " />
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components.Icons" Version="4.*-* " />
</ItemGroup>
Expand Down
11 changes: 9 additions & 2 deletions src/BlazorPong.Web/Server/BlazorPong.Web.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />

<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.5.0-rc.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.7.0" />
</ItemGroup>

<ItemGroup>
Expand Down
23 changes: 23 additions & 0 deletions src/Observability/grafana-datasources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: 1

datasources:
- name: Tempo
type: tempo
access: proxy
orgId: 1
url: http://tempo:3200
basicAuth: false
isDefault: false
version: 1
editable: false
apiVersion: 1
uid: tempo
- name: Loki
type: loki
access: proxy
orgId: 1
url: http://loki:3100
basicAuth: false
isDefault: true
version: 1
editable: false
23 changes: 23 additions & 0 deletions src/Observability/loki.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

auth_enabled: false

server:
http_listen_port: 3100

common:
ring:
instance_addr: 127.0.0.1
kvstore:
store: inmemory
replication_factor: 1
path_prefix: /tmp/loki

schema_config:
configs:
- from: 2020-05-15
store: boltdb-shipper
object_store: filesystem
schema: v11
index:
prefix: index_
period: 24h
21 changes: 21 additions & 0 deletions src/Observability/otel-collector-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
receivers:
otlp:
protocols:
grpc:
http:

exporters:
logging:
loglevel: info
otlp:
endpoint: tempo:4317
tls:
insecure: true
loki:
endpoint: "http://loki:3100/loki/api/v1/push"

service:
pipelines:
traces:
receivers: [otlp]
exporters: [logging, otlp, loki]
24 changes: 24 additions & 0 deletions src/Observability/prometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
global:
scrape_interval: 15s
scrape_timeout: 10s
evaluation_interval: 15s

scrape_configs:
- job_name: signalr
honor_timestamps: true
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /metrics
scheme: http
static_configs:
- targets:
- signalr:9090
- job_name: webapp
honor_timestamps: true
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /metrics
scheme: http
static_configs:
- targets:
- webapp:9090
15 changes: 15 additions & 0 deletions src/Observability/tempo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
server:
http_listen_port: 3200

distributor:
receivers:
otlp:
protocols:
http:
grpc:

storage:
trace:
backend: local
local:
path: /tmp/tempo/blocks
56 changes: 55 additions & 1 deletion src/docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ services:
webapp:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_FORWARDEDHEADERS_ENABLED=true
- GameHubEndpoint=http://localhost:6351/gamehub
ports:
- "6350:8080"
- "6401:9090"
depends_on:
- signalr

Expand All @@ -17,6 +19,7 @@ services:
- ConnectionStrings__AzureSql=Server=azuresql;Database=Blazorpong.Database.AzureSql;User=sa;Password=yourStrong(!)Password;TrustServerCertificate=True
ports:
- "6351:8080"
- "6402:9090"
depends_on:
- redis
- azuresql
Expand Down Expand Up @@ -61,4 +64,55 @@ services:
- "./.dapr/:/home/nonroot/configuration"
- ./docker-compose.yml:/home/nonroot/docker-compose.yml

# send logs to dapr and integrate opentelemetry with something like jaeger or zipkin or prometheus and grafana
prometheus:
image: prom/prometheus:latest
ports:
- "9090:9090"
volumes:
- ./Observability/prometheus.yaml:/etc/prometheus/prometheus.yaml

collector:
image: otel/opentelemetry-collector-contrib:latest
container_name: collector
command: [ "--config=/etc/collector.yaml" ]
ports:
- "4317:4317"
volumes:
- ./Observability/otel-collector-config.yaml:/etc/collector.yaml
depends_on:
- tempo
- prometheus

tempo:
image: grafana/tempo:latest
container_name: tempo
command: [ "-config.file=/etc/tempo.yaml" ]
volumes:
- ./Observability/tempo.yaml:/etc/tempo.yaml

grafana:
image: grafana/grafana:latest
container_name: grafana
ports:
- "3000:3000"
volumes:
- ./Observability/grafana-datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
environment:
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
- GF_AUTH_DISABLE_LOGIN_FORM=true
depends_on:
- collector
- tempo
- loki

loki:
image: grafana/loki:latest
container_name: loki
command: -config.file=/etc/loki.yaml
ports:
- "3100:3100"
volumes:
- ./Observability/loki.yaml:/etc/loki.yaml
depends_on:
- collector

0 comments on commit 5676d54

Please sign in to comment.