NodeJS
Send traces to aspecto directly from your code using exporter-collector . Here is an example Node.js TypeScript snippet:
1
import { NodeTracerProvider } from '@opentelemetry/node';
2
import { Resource } from '@opentelemetry/resources';
3
import { SimpleSpanProcessor } from '@opentelemetry/tracing';
4
import { CollectorTraceExporter } from '@opentelemetry/exporter-collector';
5
​
6
const provider = new NodeTracerProvider({
7
resource: new Resource({
8
'service.name': 'my-service-name' // service.name is required
9
}),
10
});
11
​
12
provider.register();
13
provider.addSpanProcessor(
14
new SimpleSpanProcessor(
15
new CollectorTraceExporter({
16
url: 'https://otelcol.aspecto.io/v1/trace',
17
headers: {
18
// Aspecto API-Key is required
19
Authorization: process.env.ASPECTO_API_KEY
20
}
21
})
22
)
23
);
Copied!
Last modified 1mo ago
Copy link