-
Notifications
You must be signed in to change notification settings - Fork 896
feat(opentelemetry-resources): add schema url #5753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for working on this 🙂
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5753 +/- ##
==========================================
+ Coverage 95.01% 95.02% +0.01%
==========================================
Files 303 303
Lines 7957 7984 +27
Branches 1610 1618 +8
==========================================
+ Hits 7560 7587 +27
Misses 397 397
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for addressing the comments, overall this looks good already - just one small blocker left 🙂
|
||
/** | ||
* Get the schema URL for this resource. | ||
* | ||
* @returns the schema URL or undefined if not set | ||
*/ | ||
getSchemaUrl?(): string | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd prefer a readonly property, then use a getter in the ResourceImpl
to enforce it, like we do with the other properties to keep it consistent.
cc @dyladan do you have a preference? (since you re-did resources in the latest major version)
assert.strictEqual(mergedResource.getSchemaUrl?.(), schemaUrl); | ||
}); | ||
|
||
it('should retain schema URL from the resource that has it when merging', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you might have a duplicated test case between this and the next case.
|
||
warnStub.restore(); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want to add a negative test to ensure invalid schema URL formats are handled gracefully.
Which problem is this PR solving?
Resolves #4182
Short description of the changes
The JavaScript SDK, unlike most others, currently does not give the ability to provide a Schema URL to a resource. See: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md#resource-creation
This PR implements the ability to provide it.
There was a previous attempt at this by another contributor, which was closed: #5070
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
npm run test
Checklist: