Skip to content

Commit

Permalink
Add OtlpInstanceId
Browse files Browse the repository at this point in the history
  • Loading branch information
agile.zhou committed Jun 2, 2024
1 parent 2cec041 commit ac1f022
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/AgileConfig.Server.Apisite/Appsettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class Appsettings
public static string OtlpMetricsEndpoint => Global.Config["otlp:metrics:endpoint"];

public static string OtlpMetricsProtocol => Global.Config["otlp:metrics:protocol"];
public static string OtlpInstanceId => Global.Config["otlp:instanceId"];

}
}
2 changes: 1 addition & 1 deletion src/AgileConfig.Server.Apisite/Metrics/MeterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public MeterService(IServiceScopeFactory sf)
{
return _serverNodeCount;
}, "", "The number of nodes");
PullAppConfigCounter = AgileConfigMeter.CreateCounter<long>("PullAppConfigCounter", "The number of times the app configuration was pulled");
PullAppConfigCounter = AgileConfigMeter.CreateCounter<long>("PullAppConfigCounter", "", "The number of times the app configuration was pulled");
}

public void Start()
Expand Down
4 changes: 3 additions & 1 deletion src/AgileConfig.Server.Apisite/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ private static void AddOtlpLogging(ILoggingBuilder builder)

builder.AddOpenTelemetry(options =>
{
options.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(Program.AppName));
options.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(Program.AppName
, null, null, string.IsNullOrEmpty(Appsettings.OtlpInstanceId), Appsettings.OtlpInstanceId)
);
options
.AddOtlpExporter(expOp =>
{
Expand Down
3 changes: 2 additions & 1 deletion src/AgileConfig.Server.Apisite/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public void ConfigureServices(IServiceCollection services)
services.AddSingleton<IMeterService, MeterService>();

services.AddOpenTelemetry()
.ConfigureResource(resource => resource.AddService(Program.AppName))
.ConfigureResource(resource => resource.AddService(Program.AppName,
null, null, string.IsNullOrEmpty(Appsettings.OtlpInstanceId), Appsettings.OtlpInstanceId))
.AddOtlpTraces()
.AddOtlpMetrics();
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
}
},
"otlp": {
"instanceId": "agileconfig server -1", // if empty, will generate a new one
"logs": {
"protocol": "http", // http grpc
"endpoint": "http://192.168.0.201:5341/ingest/otlp/v1/logs"
Expand Down
1 change: 1 addition & 0 deletions src/AgileConfig.Server.Apisite/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
}
},
"otlp": {
"instanceId": "", // if empty, will generate a new one
"logs": {
"protocol": "http", // http grpc
"endpoint": ""
Expand Down

0 comments on commit ac1f022

Please sign in to comment.