68 lines
1.6 KiB
Markdown
68 lines
1.6 KiB
Markdown
# Open Telemetry Example
|
|
|
|
Writes Telemetry Tracing information to the endpoint provided using the [OLTP JSON over HTTP specification](https://github.com/open-telemetry/opentelemetry-proto/blob/main/docs/specification.md#json-protobuf-encoding)
|
|
|
|
## Example Usage
|
|
|
|
Use the _code block_ widget to start and end spans.
|
|
|
|
Spans can be nested to form a stack, with the parent span being the most recent
|
|
active span added to the stack. You can have multiple spans using the same name,
|
|
and ending a span by name will always end the most recent span.
|
|
|
|
Spans will only be written to the opentelemetry endpoint once the _endSpan_
|
|
method is called.
|
|
|
|
## Visualization
|
|
|
|
For example, using Jaeger UI:
|
|
|
|

|
|
|
|
## Code Snippets
|
|
|
|
### Start Span
|
|
|
|
```javascript
|
|
(async () => {
|
|
opentelemetry.startSpan("Global Flow");
|
|
})()
|
|
.catch((error) => {
|
|
console.error(error.message);
|
|
recognizedObject.answers.push("");
|
|
recognizedObject.errorInfo = {
|
|
...recognizedObject.errorInfo,
|
|
label: {
|
|
data: error.toJSON ? error.toJSON() : {},
|
|
message: error.message,
|
|
},
|
|
};
|
|
})
|
|
.finally(() => {
|
|
next();
|
|
});
|
|
```
|
|
|
|
### End Span
|
|
|
|
```javascript
|
|
(async () => {
|
|
opentelemetry.endSpan("Global Flow");
|
|
})()
|
|
.catch((error) => {
|
|
console.error(error.message);
|
|
recognizedObject.answers.push("");
|
|
recognizedObject.errorInfo = {
|
|
...recognizedObject.errorInfo,
|
|
label: {
|
|
data: error.toJSON ? error.toJSON() : {},
|
|
message: error.message,
|
|
},
|
|
};
|
|
})
|
|
.finally(() => {
|
|
next();
|
|
});
|
|
```
|
|
|