@codebayu/usesignoz
Version:
The reusable plugin to implement signoz on Nuxt project
94 lines (74 loc) • 1.7 kB
Markdown
# @codebayu/usesignoz

A utility package to simplify the integration of Signoz (OpenTelemetry-based observability) in Nuxt.js projects.
## Installation
```bash
# npm
npm install @codebayu/usesignoz
# yarn
yarn add @codebayu/usesignoz
```
## Usage
### initTracer
```ts
import { initTracer } from '@codebayu/usesignoz';
const tracer = initTracer({
serviceName: 'your-service-name',
exporterUrl: 'http://your-exporter-url',
attributes: {
path: '/example',
uuid: 'user-123',
},
});
```
### createSpan
```ts
import { createSpan } from '@codebayu/usesignoz';
const spanName = 'your-span-name';
createSpan({
tracer,
name: spanName,
func: () => {
// Your code to be executed within the span
},
attributes: {
key1: 'value1',
key2: 'value2',
},
events: {
name: 'event-name',
keyValue: { key: 'value' },
},
});
```
## Example
```ts
import { initTracer, createSpan } from '@codebayu/usesignoz';
const tracer = initTracer({
serviceName: 'example-nuxt-project',
exporterUrl: 'http://127.0.0.1:4318/v1/traces',
attributes: {
path: '/example',
uuid: 'user-123',
},
});
// Creating a span for a specific operation
createSpan({
tracer,
name: 'example-operation',
func: () => {
// Your code for the operation
console.log('Executing example operation...');
},
attributes: {
key1: 'value1',
key2: 'value2',
},
events: {
name: 'operation-event',
keyValue: { status: 'completed' },
},
});
```
## License
This project is licensed under the [MIT License](https://opensource.org/licenses/MIT) - see the [LICENSE](LICENSE) file for details.