Prefer explicit OTLP resource configuration - #6746
Conversation
🦋 Changeset detectedLatest commit: 12a80f6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 29 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Warning Review limit reached
Next review available in: 27 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthrough
ChangesOTLP service identity
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant OtlpResource.fromConfig
participant ExplicitOptions
participant OTELEnvironment
participant Config
Caller->>OtlpResource.fromConfig: provide options and attributes
OtlpResource.fromConfig->>ExplicitOptions: resolve explicit service identity
OtlpResource.fromConfig->>OTELEnvironment: read OTEL service and resource attributes
OtlpResource.fromConfig->>Config: read fallback service configuration
OtlpResource.fromConfig-->>Caller: return OTLP resource
Suggested labels: 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
Comment |
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/effect/src/unstable/observability/OtlpResource.ts`:
- Around line 109-115: Validate the "service.name" and "service.version" values
read from options.attributes at runtime before using them in the serviceName and
serviceVersion resolution in make. Only accept values that are strings;
otherwise skip them and continue to the existing configuration or environment
fallbacks, preserving the current precedence for valid attributes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 22fe7e3e-635d-452a-8b1d-1666332c2ecf
📒 Files selected for processing (3)
.changeset/explicit-otel-service-identity.mdpackages/effect/src/unstable/observability/OtlpResource.tspackages/effect/test/unstable/observability/OtlpResource.test.ts
| ?? options?.attributes?.["service.name"] as string | undefined | ||
| ?? options?.serviceName | ||
| ?? (yield* Config.schema(Schema.UndefinedOr(Schema.String), "OTEL_SERVICE_NAME")) | ||
| ?? env?.["service.name"] as string | undefined | ||
| ?? (yield* Config.string("OTEL_SERVICE_NAME")) | ||
|
|
||
| const serviceVersion = (yield* Config.schema(Schema.UndefinedOr(Schema.String), "OTEL_SERVICE_VERSION")) | ||
| ?? env?.["service.version"] as string | undefined | ||
| const serviceVersion = options?.serviceVersion | ||
| ?? options?.attributes?.["service.version"] as string | undefined |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Validate service attributes before using them as strings.
options.attributes accepts unknown values, so these assertions do not validate runtime types. For example, { "service.name": 123 } is passed to make despite serviceName requiring a string, producing invalid resource metadata. Use a runtime string check or schema validation before applying these attributes.
Proposed fix
+ const serviceNameAttribute = options?.attributes?.["service.name"]
+ const serviceVersionAttribute = options?.attributes?.["service.version"]
+
const serviceName = options?.serviceName
- ?? options?.attributes?.["service.name"] as string | undefined
+ ?? (typeof serviceNameAttribute === "string" ? serviceNameAttribute : undefined)
...
const serviceVersion = options?.serviceVersion
- ?? options?.attributes?.["service.version"] as string | undefined
+ ?? (typeof serviceVersionAttribute === "string" ? serviceVersionAttribute : undefined)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ?? options?.attributes?.["service.name"] as string | undefined | |
| ?? options?.serviceName | |
| ?? (yield* Config.schema(Schema.UndefinedOr(Schema.String), "OTEL_SERVICE_NAME")) | |
| ?? env?.["service.name"] as string | undefined | |
| ?? (yield* Config.string("OTEL_SERVICE_NAME")) | |
| const serviceVersion = (yield* Config.schema(Schema.UndefinedOr(Schema.String), "OTEL_SERVICE_VERSION")) | |
| ?? env?.["service.version"] as string | undefined | |
| const serviceVersion = options?.serviceVersion | |
| ?? options?.attributes?.["service.version"] as string | undefined | |
| const serviceNameAttribute = options?.attributes?.["service.name"] | |
| const serviceVersionAttribute = options?.attributes?.["service.version"] | |
| const serviceName = options?.serviceName | |
| ?? (typeof serviceNameAttribute === "string" ? serviceNameAttribute : undefined) | |
| ?? (yield* Config.schema(Schema.UndefinedOr(Schema.String), "OTEL_SERVICE_NAME")) | |
| ?? env?.["service.name"] as string | undefined | |
| ?? (yield* Config.string("OTEL_SERVICE_NAME")) | |
| const serviceVersion = options?.serviceVersion | |
| ?? (typeof serviceVersionAttribute === "string" ? serviceVersionAttribute : undefined) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/effect/src/unstable/observability/OtlpResource.ts` around lines 109
- 115, Validate the "service.name" and "service.version" values read from
options.attributes at runtime before using them in the serviceName and
serviceVersion resolution in make. Only accept values that are strings;
otherwise skip them and continue to the existing configuration or environment
fallbacks, preserving the current precedence for valid attributes.
Summary
serviceNameandserviceVersionoptions over matching resource attributes and OTEL environment configurationOTEL_RESOURCE_ATTRIBUTESOTEL_RESOURCE_ATTRIBUTESTesting
pnpm jsdocs && pnpm exec oxlint -f unixnix shell nixpkgs#dprint --command dprint checkpnpm --filter effect test --run test/unstable/observability/OtlpResource.test.tspnpm checkpnpm exec docgenfrompackages/effectResolves #6742