Skip to content

Automatically generate service.instance.id if not user-configured#4756

Merged
Kielek merged 3 commits intoopen-telemetry:mainfrom
martincostello:gh-4742
Jan 13, 2026
Merged

Automatically generate service.instance.id if not user-configured#4756
Kielek merged 3 commits intoopen-telemetry:mainfrom
martincostello:gh-4742

Conversation

@martincostello
Copy link
Member

Why

Fixes #4742

What

Configure a default value for the service.instance.id resource attribute if not specified by the user.

Tests

Tested updated.

Checklist

  • CHANGELOG.md is updated.
  • Documentation is updated.
  • New features are covered by tests.

Configure a default value for the `service.instance.id` resource attribute if not specified by the user.
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.
@martincostello martincostello mentioned this pull request Jan 13, 2026
3 tasks
- Add new expectation for a value matching a Regex.
- Assert that `service.instance.id` is a GUID.
@martincostello martincostello marked this pull request as ready for review January 13, 2026 16:01
@martincostello martincostello requested a review from a team as a code owner January 13, 2026 16:01
Copilot AI review requested due to automatic review settings January 13, 2026 16:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.id as 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.

- Fix variable name typo.
- Combine if statements.
- Use collection expressions.
@martincostello
Copy link
Member Author

Failing test is a flake.

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.
@Kielek Kielek merged commit dee34d4 into open-telemetry:main Jan 13, 2026
51 of 52 checks passed
@martincostello martincostello deleted the gh-4742 branch January 13, 2026 20:46
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.

Automatically generate service.instance.id if not user-configured

4 participants

Comments