Skip to content

Commit

Permalink
Integrate service metrics with OpenTelemetry Collector
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirKhil committed Jun 4, 2024
1 parent 8b5f5d0 commit 1a695ac
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
1 change: 1 addition & 0 deletions docker-compose/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OTEL_COLLECTOR_TAG=0.89.0
14 changes: 14 additions & 0 deletions docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: "3.9"

services:

otel-collector:
image: otel/opentelemetry-collector:${OTEL_COLLECTOR_TAG}
command: ["--config=/etc/otel-collector-config.yaml"]
volumes:
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
ports:
- 8888:8888
- 8889:8889
- 13133:13133
- 4317:4317
21 changes: 21 additions & 0 deletions docker-compose/otel-collector-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
receivers:
otlp:
protocols:
grpc:

exporters:
logging:

processors:
batch:

extensions:
health_check:

service:
extensions: [health_check]
pipelines:
metrics:
receivers: [otlp]
processors: [batch]
exporters: [logging]
10 changes: 1 addition & 9 deletions src/Spard.Service/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,7 @@ static void AddMetrics(IServiceCollection services, IConfiguration configuration
.AddAspNetCoreInstrumentation()
.AddRuntimeInstrumentation()
.AddProcessInstrumentation()
.AddOtlpExporter(options =>
{
var otelUri = configuration["OpenTelemetry:ServiceUri"];
if (otelUri != null)
{
options.Endpoint = new Uri(otelUri);
}
}));
.AddOtlpExporter());
}

static void Configure(WebApplication app)
Expand Down

0 comments on commit 1a695ac

Please sign in to comment.