Skip to content

runtimes/go: add metrics.SetServiceLabels for per-service label enrichment - #2394

Open
twindebank wants to merge 1 commit into
encoredev:mainfrom
twindebank:service-labels-v2
Open

twindebank wants to merge 1 commit into
encoredev:mainfrom
twindebank:service-labels-v2

Conversation

@twindebank

@twindebank twindebank commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Adds metrics.SetServiceLabels(serviceName, labels) which registers additional labels to be included with all metrics exported for a given service. This enables enriching built-in metrics (like e_requests_total) with custom metadata without duplicating the metric pipeline via OTel.

All four exporters are updated (Prometheus, GCP Cloud Monitoring, Datadog, CloudWatch). Reserved keys and empty values are filtered at registration time.

…tom labels

Add metrics.SetServiceLabels(serviceName, labels) which registers additional
labels to be included with all metrics exported for a given service. This
enables enriching Encore's built-in metrics (like e_requests_total) with
custom metadata such as domain, team, or cost-center labels.

Labels are stored in the Registry, attached to CollectedMetric at collection
time, and applied by each exporter (Prometheus, GCP, Datadog, CloudWatch)
when the service name is resolved.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@twindebank twindebank changed the title metrics: add SetServiceLabels for enriching built-in metrics runtimes/go: add metrics.SetServiceLabels for per-service label enrichment Apr 10, 2026

@bkach bkach left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding service labels makes sense, nice one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants