Skip to content

Commit

Permalink
use target serverName as otel serviceName
Browse files Browse the repository at this point in the history
  • Loading branch information
andracc committed Sep 4, 2024
1 parent 1675cbb commit 10c2e57
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Backend/Otel/BackendActivitySource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ public class BackendActivitySource
{
public static ActivitySource Get()
{
return new ActivitySource(OtelKernel.ServiceName);
return new ActivitySource("service");
}
}
10 changes: 5 additions & 5 deletions Backend/Otel/OtelKernel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

// using System;
using System.Diagnostics;
using System.Diagnostics.Metrics;
// using System.Diagnostics.Metrics;
// using System.Net.Http;
// using System.Net.Http.Json;
using System.Security.Claims;
Expand All @@ -20,7 +20,7 @@ namespace BackendFramework.Otel
public static class OtelKernel
{

public const string ServiceName = "Backend-Otel";
// public const string ServiceName = "Backend-Otel";
// private readonly LocationCache _locationCache;

// public OtelKernel(LocationCache locationCache, IServiceCollection serviceCollection)
Expand All @@ -31,11 +31,11 @@ public static class OtelKernel

public static void AddOpenTelemetryInstrumentation(this IServiceCollection services)
{
var appResourceBuilder = ResourceBuilder.CreateDefault().AddService(ServiceName);
var appResourceBuilder = ResourceBuilder.CreateDefault();
// todo: include version
services.AddOpenTelemetry().WithTracing(tracerProviderBuilder => tracerProviderBuilder
.SetResourceBuilder(appResourceBuilder)
.AddSource(ServiceName)
// .AddSource(ServiceName)
.AddProcessor<LocationEnricher>()
.AddAspNetCoreInstrumentation(options =>
{
Expand Down Expand Up @@ -119,7 +119,7 @@ public static void AddOpenTelemetryInstrumentation(this IServiceCollection servi
// .AddOtlpExporter()
// );

var meter = new Meter(ServiceName);
// var meter = new Meter(ServiceName);

}

Expand Down
1 change: 0 additions & 1 deletion Backend/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"environmentVariables": {
"Key": "Value",
"ASPNETCORE_ENVIRONMENT": "Development",
"OTEL_SERVICE_NAME": "Backend-Otel",
"OTEL_EXPORTER_OTLP_PROTOCOL": "grpc",
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4317",
"COMBINE_CAPTCHA_REQUIRED": "true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ spec:
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
env:
- name: OTEL_SERVICE_NAME
value: "Otel-k8s-simple-deployment"
value: {{ .Values.global.serverName }}
# value: "Otel-k8s-simple-deployment"
- name: OTEL_EXPORTER_OTLP_PROTOCOL
value: "http/protobuf"
- name: OTEL_EXPORTER_OTLP_ENDPOINT
Expand Down

0 comments on commit 10c2e57

Please sign in to comment.