Skip to content
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

opentelemetry-tracing - document how to use it with NodeSDK #5617

Open
mjarosie opened this issue Feb 5, 2024 · 2 comments
Open

opentelemetry-tracing - document how to use it with NodeSDK #5617

mjarosie opened this issue Feb 5, 2024 · 2 comments
Labels
docs Documentation creation, updates or corrections

Comments

@mjarosie
Copy link

mjarosie commented Feb 5, 2024

Problem

As far as I understand there are two ways of configuring OpenTelemetry in JavaScript (source):

Most beginners will be more familiar with @opentelemetry/sdk-node as OpenTelemetry's JavaScript getting started guide uses it.

Currently Prisma documentation on enabling OpenTelemetry tracing describes only how to make use of the first approach. Showing how to make it work with new NodeSDK({ /* ... */ }) would make it easier to enable tracing in Prisma.

Suggested solution

Expand the documentation page to also mention how to use it with @opentelemetry/sdk-node.

Additional context

I got really confused when trying to enable tracing in Prisma following the documentation mentioned above after having configured basic instrumentation based on OpenTelemetry's JavaScript getting started guide (also mentioned above).

@apolanc apolanc transferred this issue from prisma/prisma Feb 6, 2024
@Jolg42
Copy link
Contributor

Jolg42 commented Feb 8, 2024

@mjarosie (I did not try this code, but that should be the idea for Honeycomb here)

import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto'
import { NodeSDK } from '@opentelemetry/sdk-node'
import { PrismaInstrumentation } from '@prisma/instrumentation'

const traceExporter = new OTLPTraceExporter({
  url: `https://api.honeycomb.io/v1/traces`,
  headers: {
    'x-honeycomb-team': "HONEYCOMB_API_KEY",
  },
})

const sdk = new NodeSDK({
  serviceName: "my-service-name",
  traceExporter,
  instrumentations: [
    new PrismaInstrumentation(),
  ],
})

sdk.start()

process.on(`SIGTERM`, () => {
  sdk.shutdown().finally(() => process.exit(0))
})

@mjarosie
Copy link
Author

mjarosie commented Feb 8, 2024

Yes, got it working with a very similar setup 👍 Something similar should probably end up in the documentation (either with traceExporter as you've shown or also with spanProcessor, but not sure if that wouldn't complicate the example too much).

@janpio janpio added the docs Documentation creation, updates or corrections label Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation creation, updates or corrections
Projects
None yet
Development

No branches or pull requests

3 participants