-
Notifications
You must be signed in to change notification settings - Fork 825
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
✨Add initial span interface #31
Changes from 10 commits
dff68bb
2311095
fafce9f
db13c94
52e53ab
424c9fd
d969247
01d1340
53b8093
595465c
f1d2b7e
5c92e51
f4803cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Copyright 2019, OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** Defines a attributes interface. */ | ||
export interface Attributes { | ||
[attributeKey: string]: unknown; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright 2019, OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { Attributes } from './attributes'; | ||
import { SpanContext } from './span_context'; | ||
|
||
/** | ||
* A pointer from the current span to another span in the same trace or in a | ||
* different trace. | ||
*/ | ||
export interface Link { | ||
/** The SpanContext of a linked span. */ | ||
spanContext: SpanContext; | ||
/** A set of attributes on the link. */ | ||
attributes: Attributes; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/** | ||
* Copyright 2019, OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { SpanContext } from './span_context'; | ||
import { Status } from './status'; | ||
|
||
/** | ||
* An interface that represents a span. A span represents a single operation | ||
* within a trace. Examples of span might include remote procedure calls or a | ||
* in-process function calls to sub-components. A Trace has a single, top-level | ||
* "root" Span that in turn may have zero or more child Spans, which in turn | ||
* may have children. | ||
*/ | ||
export interface Span { | ||
/** | ||
* Returns the SpanContext object associated with this Span. | ||
* | ||
* @returns the SpanContext object associated with this Span. | ||
*/ | ||
context(): SpanContext; | ||
|
||
// /** | ||
// * # TODO | ||
// * Returns the Tracer object used to create this Span. | ||
// * https://github.com/open-telemetry/opentelemetry-specification/issues/21 | ||
// */ | ||
// tracer(): Tracer; | ||
|
||
/** | ||
* Sets an attribute to the span. | ||
* | ||
* @param key the key for this attribute. | ||
* @param value the value for this attribute. | ||
*/ | ||
setAttribute(key: string, value: unknown): this; | ||
|
||
/** | ||
* Adds an event to the Span. | ||
* | ||
* @param name the name of the event. | ||
* @param [attributes] the attributes that will be added; these are | ||
* associated with this event. | ||
*/ | ||
addEvent(name: string, attributes?: { [key: string]: unknown }): this; | ||
|
||
/** | ||
* Adds a link to the Span. | ||
* | ||
* @param spanContext the context of the linked span. | ||
* @param [attributes] the attributes that will be added; these are | ||
* associated with this link. | ||
*/ | ||
addLink(spanContext: SpanContext, attributes?: { [key: string]: unknown }): this; | ||
|
||
/** | ||
* Sets a status to the span. If used, this will override the default Span | ||
* status. Default is 'OK'. | ||
* | ||
* @param status the Status to set. | ||
*/ | ||
setStatus(status: Status): this; | ||
|
||
/** | ||
* Updates the Span name. | ||
* | ||
* TODO (revision): https://github.com/open-telemetry/opentelemetry-specification/issues/119 | ||
* | ||
* @param name the Span name. | ||
*/ | ||
updateName(name: string): this; | ||
|
||
/** | ||
* Marks the end of Span execution. | ||
* | ||
* Call to End of a Span MUST not have any effects on child spans. Those may | ||
* still be running and can be ended later. | ||
* | ||
* Do not return `this`. The Span generally should not be used after it | ||
* is ended so chaining is not desired in this context. | ||
* | ||
* @param [endTime] the timestamp to set as Span's end time. If not provided, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you specify how the timestamp is formatted? Are we going to use epoch millis? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you don't mind, I will update once we have some conclusion here #19 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. Could you add a TODO comment that points to that issue though? |
||
* use the current time as the span's end time. | ||
*/ | ||
end(endTime?: number): void; | ||
|
||
/** | ||
* Returns the flag whether this span will be recorded. | ||
* | ||
* @returns true if this Span is active and recording information like events | ||
* with the AddEvent operation and attributes using setAttributes. | ||
*/ | ||
isRecordingEvents(): boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the description it sounds like the fact that it's recording events is only part of the state. Should this be called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This flag is used to indicate whether events should be recorded or not. If it's set, |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* Copyright 2019, OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { TraceState } from './tracestate'; | ||
import { TraceOptions } from './traceoptions'; | ||
|
||
/** | ||
* A SpanContext represents the portion of a Span which must be serialized and | ||
* propagated along side of a distributed context. | ||
*/ | ||
export interface SpanContext { | ||
/** | ||
* The ID of the trace that this span belongs to. It is worldwide unique | ||
* with practically sufficient probability by being made as 16 randomly | ||
* generated bytes, encoded as a 32 lowercase hex characters corresponding to | ||
* 128 bits. | ||
*/ | ||
traceId: string; | ||
/** | ||
* The ID of the Span. It is globally unique with practically sufficient | ||
* probability by being made as 8 randomly generated bytes, encoded as a 16 | ||
* lowercase hex characters corresponding to 64 bits. | ||
*/ | ||
spanId: string; | ||
/** | ||
* Trace options to propagate. | ||
* | ||
* It is represented as 1 byte (bitmap). Bit to represent whether trace is | ||
* sampled or not. | ||
* SAMPLED_VALUE = 0x1 and NOT_SAMPLED_VALUE = 0x0; | ||
*/ | ||
traceOptions?: TraceOptions; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this just be a |
||
/** | ||
* Tracing-system-specific info to propagate. | ||
* | ||
* The tracestate field value is a `list` as defined below. The `list` is a | ||
* series of `list-members` separated by commas `,`, and a list-member is a | ||
* key/value pair separated by an equals sign `=`. Spaces and horizontal tabs | ||
* surrounding `list-members` are ignored. There can be a maximum of 32 | ||
* `list-members` in a `list`. | ||
* More Info: https://www.w3.org/TR/trace-context/#tracestate-field | ||
* | ||
* Examples: | ||
* Single tracing system (generic format): | ||
* tracestate: rojo=00f067aa0ba902b7 | ||
* Multiple tracing systems (with different formatting): | ||
* tracestate: rojo=00f067aa0ba902b7,congo=t61rcWkgMzE | ||
*/ | ||
traceState?: TraceState; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems that the comment about is describing this as a string, but the type seems to imply something more complex - is this meant to become the parsed trace state? I'm OK with leaving this as-is though since the structure is marked as TODO anyway. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* Copyright 2019, OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* Type of span. Can be used to specify additional relationships between spans | ||
* in addition to a parent/child relationship. | ||
*/ | ||
export enum SpanKind { | ||
/** Default value. Indicates that the span is used internally. */ | ||
INTERNAL = 0, | ||
|
||
/** | ||
* Indicates that the span covers server-side handling of an RPC or other | ||
* remote request. | ||
*/ | ||
SERVER = 1, | ||
|
||
/** | ||
* Indicates that the span covers the client-side wrapper around an RPC or | ||
* other remote request. | ||
*/ | ||
CLIENT = 2, | ||
|
||
/** | ||
* Indicates that the span describes producer sending a message to a | ||
* broker. Unlike client and server, there is no direct critical path latency | ||
* relationship between producer and consumer spans. | ||
*/ | ||
PRODUCER = 3, | ||
|
||
/** | ||
* Indicates that the span describes consumer receiving a message from a | ||
* broker. Unlike client and server, there is no direct critical path latency | ||
* relationship between producer and consumer spans. | ||
*/ | ||
CONSUMER = 4, | ||
} |
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.
It's not clear what these attributes are used for.
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
attributes
are the collection of key:value pairs associated with the link to conserve meaningful information related to link.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.
What I meant is that this should be better explained in the TypeDoc. In general I feel the documentation of the file doesn't explain much of what the different methods do. Of course, documentation can be improved in later iterations.