|
| 1 | +--- |
| 2 | +description: How to send traces to Aspecto without using our SDK |
| 3 | +--- |
| 4 | + |
| 5 | +# Use w/o Aspecto SDK |
| 6 | + |
| 7 | +To enjoy Aspecto to the fullest, we encourage you to use our SDK to send traces. |
| 8 | +If you already have an existing OpenTelemetry setup and prefer to keep using it, there are a couple of ways to do it. |
| 9 | + |
| 10 | +The minimum required for our collector to accept your traces is to have the `service.name` resource attribute on your spans and pass the [Aspecto API-Key](https://app.aspecto.io/app/integration/api-key), either through `aspecto.token` resource attribute, or through the `Authorization` HTTP header when making a request to our collector. |
| 11 | + |
| 12 | +## Send Traces to Aspecto directly from your code |
| 13 | + |
| 14 | +To do so, you'd need to use the [`exporter-collector`](https://www.npmjs.com/package/@opentelemetry/exporter-collector) , here's an example Node.js snippet: |
| 15 | + |
| 16 | +```typescript |
| 17 | +import { NodeTracerProvider } from '@opentelemetry/node'; |
| 18 | +import { Resource } from '@opentelemetry/resources'; |
| 19 | +import { SimpleSpanProcessor } from '@opentelemetry/tracing'; |
| 20 | +import { CollectorTraceExporter } from '@opentelemetry/exporter-collector'; |
| 21 | + |
| 22 | +const provider = new NodeTracerProvider({ |
| 23 | + resource: new Resource({ |
| 24 | + 'service.name': 'my-service-name' // service.name is required |
| 25 | + }), |
| 26 | +}); |
| 27 | + |
| 28 | +provider.register(); |
| 29 | +provider.addSpanProcessor( |
| 30 | + new SimpleSpanProcessor( |
| 31 | + new CollectorTraceExporter({ |
| 32 | + url: 'https://otelcol-fast.aspecto.io/v1/trace', |
| 33 | + headers: { |
| 34 | + // Aspecto API-Key is required |
| 35 | + Authorization: process.env.ASPECTO_API_KEY |
| 36 | + } |
| 37 | + }) |
| 38 | + ) |
| 39 | +); |
| 40 | +``` |
| 41 | + |
| 42 | +## Export to Aspecto Collector from your own OpenTelemetry Collector |
| 43 | + |
| 44 | +If you already have your own [OpenTelemetry Collector](https://github.com/open-telemetry/opentelemetry-collector) and want to export your traces to Aspecto, you'd need to add a new `otlphttp` exporter in your config.yml: |
| 45 | + |
| 46 | +```yaml |
| 47 | +exporters: |
| 48 | + otlphttp: |
| 49 | + endpoint: https://otelcol-fast.aspecto.io |
| 50 | + headers: |
| 51 | + Authorization: <aspecto-api-key> |
| 52 | + |
| 53 | +service: |
| 54 | + pipelines: |
| 55 | + traces: |
| 56 | + receivers: [...] |
| 57 | + processors: [...] |
| 58 | + exporters: [otlphttp, ...] |
| 59 | +``` |
| 60 | +
|
0 commit comments