Skip to content

docs: document custom OTel resource attributes configuration#1910

Open
mvanhorn wants to merge 3 commits intoopen-feature:mainfrom
mvanhorn:osc/1500-document-otel-resource-attributes
Open

docs: document custom OTel resource attributes configuration#1910
mvanhorn wants to merge 3 commits intoopen-feature:mainfrom
mvanhorn:osc/1500-document-otel-resource-attributes

Conversation

@mvanhorn
Copy link
Copy Markdown

Summary

Adds documentation for defining custom OpenTelemetry resource attributes on flagd's exported telemetry using OTEL_RESOURCE_ATTRIBUTES.

Why this matters

Per #1500, users need to know how to attach custom resource attributes (deployment environment, service version, etc.) to flagd's metrics and traces. The env var works but isn't documented, and the collector-side resource_to_telemetry_conversion setting needed to surface them as Prometheus labels wasn't mentioned.

Changes

  • docs/reference/monitoring.md: Added "Custom resource attributes" section between "Export to OTEL collector" and "Configure local collector setup". Documents the OTEL_RESOURCE_ATTRIBUTES env var with example and the collector's resource_to_telemetry_conversion config.

Fixes #1500

This contribution was developed with AI assistance (Claude Code).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mvanhorn mvanhorn requested review from a team as code owners March 21, 2026 05:50
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 21, 2026

Deploy Preview for polite-licorice-3db33c ready!

Name Link
🔨 Latest commit 4431fdc
🔍 Latest deploy log https://app.netlify.com/projects/polite-licorice-3db33c/deploys/69c152e23b046b00086268fb
😎 Deploy Preview https://deploy-preview-1910--polite-licorice-3db33c.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 21, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the documentation for flagd's OpenTelemetry integration by providing clear guidance on how users can attach custom resource attributes to exported telemetry. This addresses a user need to enrich metrics and traces with contextual information like deployment environment or service version, improving observability and troubleshooting capabilities.

Highlights

  • OpenTelemetry Resource Attributes Documentation: Added a new section to the monitoring.md documentation detailing how to configure custom OpenTelemetry resource attributes using the OTEL_RESOURCE_ATTRIBUTES environment variable.
  • Prometheus Metric Labels Configuration: Included instructions on enabling resource_to_telemetry_conversion in the OpenTelemetry Collector's Prometheus exporter configuration to expose resource attributes as metric labels.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds valuable documentation for configuring custom OpenTelemetry resource attributes. The changes are clear and address the issue described. I have a couple of suggestions to improve the clarity of the examples and prevent potential user misconfiguration. Specifically, I'm suggesting a better way to present the shell command for setting environment variables and clarifying the context of the OpenTelemetry Collector configuration snippet.

Comment on lines +89 to +90
export OTEL_RESOURCE_ATTRIBUTES="deployment.environment=staging,service.version=1.2.3"
flagd start --uri file:/flags.json --metrics-exporter otel --otel-collector-uri localhost:4317
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For better clarity and to avoid polluting the shell's environment, it's preferable to set the environment variable only for the flagd start command. This can be done in a single line. This format is also more convenient for copy-pasting and for use in container entrypoints.

Suggested change
export OTEL_RESOURCE_ATTRIBUTES="deployment.environment=staging,service.version=1.2.3"
flagd start --uri file:/flags.json --metrics-exporter otel --otel-collector-uri localhost:4317
OTEL_RESOURCE_ATTRIBUTES="deployment.environment=staging,service.version=1.2.3" flagd start --uri file:/flags.json --metrics-exporter otel --otel-collector-uri localhost:4317

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Personally I agree with this @mvanhorn

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This might also be related to #1812 and it could be like this.

export OTEL_RESOURCE_ATTRIBUTES="deployment.environment=staging,service.version=1.2.3"
export OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317
flagd start --uri file:/flags.json --metrics-exporter otel

It may be better to encourage the use of OTEL environment variables in the flagd documentation, as they offer more flexible configuration options.


These attributes follow the [OpenTelemetry resource semantic conventions](https://opentelemetry.io/docs/specs/semconv/resource/) and are attached to all exported metrics and traces.

To expose resource attributes as metric labels in Prometheus, enable `resource_to_telemetry_conversion` in your OpenTelemetry Collector exporter config:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To avoid potential confusion, it's better to be more explicit about where this configuration snippet fits. The current wording might lead a user to replace their entire exporters configuration, which could break other functionality like trace exporting.

Suggested change
To expose resource attributes as metric labels in Prometheus, enable `resource_to_telemetry_conversion` in your OpenTelemetry Collector exporter config:
To expose resource attributes as metric labels in Prometheus, update the `prometheus` exporter within the `exporters` section of your OpenTelemetry Collector configuration file as shown below:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure about this - I don't find the original wording confusing, but up to you @mvanhorn

@toddbaert
Copy link
Copy Markdown
Member

toddbaert commented Mar 23, 2026

Thanks for this! Useful addition.

One thought: the values here (environment, region, service version) overlap a lot with what you'd configure via static context -X for flag targeting. Users setting one will likely want the other. Might be worth a brief cross-reference, something like:

If you're setting resource attributes for environment identification, you may also want to configure static context values so the same attributes are available for flag evaluation targeting.

Otherwise LGTM, but you need to sign your commits as mentioned here as per CNCF policy. Also consider Gemini's nits.

@toddbaert toddbaert requested a review from beeme1mr March 23, 2026 11:08
mvanhorn and others added 2 commits March 23, 2026 07:48
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adopted @erka's suggestion to use OTEL_EXPORTER_OTLP_ENDPOINT env var
instead of the --otel-collector-uri flag, encouraging more flexible
OTel-native configuration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

@mvanhorn
Copy link
Copy Markdown
Author

Added the static context cross-reference - good call, users setting resource attributes for environment targeting will likely want the -X flags too.

Also adopted @erka's suggestion to use OTEL_EXPORTER_OTLP_ENDPOINT env var instead of --otel-collector-uri in the example.

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

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document how to define custom OTel resource attributes on exported telemetry

3 participants