Skip to content
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

docs: document null and undefined attribute values undefined behavior #1650

Merged
merged 3 commits into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/opentelemetry-api/src/trace/attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ export interface Attributes {
[attributeKey: string]: AttributeValue | undefined;
}

/**
* Attribute values may be any non-nullish primitive value except an object.
*
* null or undefined attribute values are invalid and will result in undefined behavior.
*/
export type AttributeValue =
| string
| number
Expand Down
5 changes: 4 additions & 1 deletion packages/opentelemetry-api/src/trace/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,17 @@ export interface Span {
* Sets a single Attribute with the key and value passed as arguments.
*
* @param key the key for this attribute.
* @param value the value for this attribute.
* @param value the value for this attribute. Setting a value null or
* undefined is invalid and will result in undefined behavior.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: could you indent this second line of the JSDoc by 4 spaces to make to be consistent with others, also to make visually clear that it's a continued line.

*/
setAttribute(key: string, value?: AttributeValue): this;

/**
* Sets attributes to the span.
*
* @param attributes the attributes that will be added.
* null or undefined attribute values
Copy link
Member

Choose a reason for hiding this comment

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

ditto

* are invalid and will result in undefined behavior.
*/
setAttributes(attributes: Attributes): this;

Expand Down