Skip to content

Commit fc99ce7

Browse files
Default OTEL service name to agent name for multi-instance dashboards
When Telemetry.ServiceName is not explicitly overridden, it now defaults to the Agent:Name value (e.g. "RockBot", "RockBot-Bob"). This lets Grafana dashboards differentiate between instances without extra config. If Telemetry__ServiceName is set explicitly in the ConfigMap it still takes precedence — the default only applies when it equals "rockbot". Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 51d7322 commit fc99ce7

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/RockBot.Agent/Program.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,21 @@
4040
builder.Configuration.AddJsonFile(Path.Combine(pvcBase, "appsettings.json"), optional: true, reloadOnChange: false);
4141
}
4242

43+
var agentName = builder.Configuration["Agent:Name"] ?? "RockBot";
44+
4345
builder.Services.AddRockBotRabbitMq(opts => builder.Configuration.GetSection("RabbitMq").Bind(opts));
4446

4547
// OpenTelemetry — enabled via Telemetry:Enabled config key (set in k8s ConfigMap)
48+
// ServiceName defaults to the agent name so multi-instance deployments are
49+
// distinguishable in Grafana dashboards without extra config.
4650
if (builder.Configuration.GetValue<bool>("Telemetry:Enabled"))
4751
{
4852
builder.Services.AddRockBotTelemetry(opts =>
49-
builder.Configuration.GetSection("Telemetry").Bind(opts));
53+
{
54+
builder.Configuration.GetSection("Telemetry").Bind(opts);
55+
if (opts.ServiceName == "rockbot")
56+
opts.ServiceName = agentName;
57+
});
5058
}
5159

5260
// ── LLM configuration — three-tier (Low / Balanced / High) ──────────────────
@@ -253,8 +261,6 @@ async Task<IChatClient> BuildClientForTierAsync(LlmTierConfig config, string tie
253261
builder.Services.AddSingleton<IToolSkillProvider, MemoryToolSkillProvider>();
254262
builder.Services.AddSingleton<IToolSkillProvider, SkillToolSkillProvider>();
255263

256-
var agentName = builder.Configuration["Agent:Name"] ?? "RockBot";
257-
258264
builder.Services.AddRockBotHost(agent =>
259265
{
260266
agent.WithIdentity(agentName);

0 commit comments

Comments
 (0)