Automatically generate service.instance.id if not user-configured#4756
Merged
Kielek merged 3 commits intoopen-telemetry:mainfrom Jan 13, 2026
Merged
Automatically generate service.instance.id if not user-configured#4756Kielek merged 3 commits intoopen-telemetry:mainfrom
Kielek merged 3 commits intoopen-telemetry:mainfrom
Conversation
Configure a default value for the `service.instance.id` resource attribute if not specified by the user.
Kielek
approved these changes
Jan 13, 2026
martincostello
added a commit
to martincostello/opentelemetry-dotnet-instrumentation
that referenced
this pull request
Jan 13, 2026
Use an ASCII dash for the test. Spotted in Visual Studio Code while working on open-telemetry#4756.
- Add new expectation for a value matching a Regex. - Assert that `service.instance.id` is a GUID.
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request implements automatic generation of the service.instance.id resource attribute when it is not explicitly configured by the user. The attribute is set to a new UUID v4 value if not already present in the resource attributes.
Changes:
- Added automatic generation of
service.instance.idas a UUID v4 when not user-configured - Enhanced test infrastructure to support regex pattern matching for resource attribute validation
- Updated tests to verify the auto-generation behavior and ensure user-provided values are not overwritten
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/OpenTelemetry.AutoInstrumentation/Constants.cs | Added constant for service.instance.id attribute name |
| src/OpenTelemetry.AutoInstrumentation/Configurations/ResourceConfigurator.cs | Implemented logic to auto-generate service.instance.id using Guid.NewGuid() if not already configured |
| test/OpenTelemetry.AutoInstrumentation.Tests/Configurations/ServiceNameConfiguratorTests.cs | Added test case to verify user-configured service.instance.id is not overwritten; contains a typo in variable name |
| test/IntegrationTests/Helpers/OtlpResourceExpector.cs | Added Matches() method and regex support for validating resource attributes against patterns |
| test/IntegrationTests/Helpers/OtlpResourceExpectorExtensions.cs | Added expectation for service.instance.id in standard resources |
| test/IntegrationTests/AspNetTests.cs | Added validation for auto-generated service.instance.id; fixed comment typos (Wep.config → Web.config) |
| CHANGELOG.md | Documented the new feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
test/OpenTelemetry.AutoInstrumentation.Tests/Configurations/ServiceNameConfiguratorTests.cs
Outdated
Show resolved
Hide resolved
- Fix variable name typo. - Combine if statements. - Use collection expressions.
Member
Author
|
Failing test is a flake. |
nrcventura
approved these changes
Jan 13, 2026
rajkumar-rangaraj
approved these changes
Jan 13, 2026
Kielek
pushed a commit
that referenced
this pull request
Jan 13, 2026
Use an ASCII dash for the test. Spotted in Visual Studio Code while working on #4756.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Fixes #4742
What
Configure a default value for the
service.instance.idresource attribute if not specified by the user.Tests
Tested updated.
Checklist
CHANGELOG.mdis updated.