Unverified Commit e6763488 authored by Dima Voytenko's avatar Dima Voytenko Committed by GitHub

OpenTelemetry: update docs for new @vercel/otel (#61044)

Co-authored-by: 's avatarAndrew Gadzik <andrew.gadzik@vercel.com>
parent 2d4dbcdf
...@@ -20,14 +20,10 @@ This documentation uses terms like _Span_, _Trace_ or _Exporter_ throughout this ...@@ -20,14 +20,10 @@ This documentation uses terms like _Span_, _Trace_ or _Exporter_ throughout this
Next.js supports OpenTelemetry instrumentation out of the box, which means that we already instrumented Next.js itself. Next.js supports OpenTelemetry instrumentation out of the box, which means that we already instrumented Next.js itself.
When you enable OpenTelemetry we will automatically wrap all your code like `getStaticProps` in _spans_ with helpful attributes. When you enable OpenTelemetry we will automatically wrap all your code like `getStaticProps` in _spans_ with helpful attributes.
> **Good to know**: We currently support OpenTelemetry bindings only in serverless functions.
> We don't provide any for `edge` or client side code.
## Getting Started ## Getting Started
OpenTelemetry is extensible but setting it up properly can be quite verbose. OpenTelemetry is extensible but setting it up properly can be quite verbose.
That's why we prepared a package `@vercel/otel` that helps you get started quickly. That's why we prepared a package `@vercel/otel` that helps you get started quickly.
It's not extensible and you should configure OpenTelemetry manually if you need to customize your setup.
### Using `@vercel/otel` ### Using `@vercel/otel`
...@@ -53,7 +49,7 @@ Next, create a custom [`instrumentation.ts`](/docs/pages/building-your-applicati ...@@ -53,7 +49,7 @@ Next, create a custom [`instrumentation.ts`](/docs/pages/building-your-applicati
import { registerOTel } from '@vercel/otel' import { registerOTel } from '@vercel/otel'
export function register() { export function register() {
registerOTel('next-app') registerOTel({ serviceName: 'next-app' })
} }
``` ```
...@@ -61,10 +57,12 @@ export function register() { ...@@ -61,10 +57,12 @@ export function register() {
import { registerOTel } from '@vercel/otel' import { registerOTel } from '@vercel/otel'
export function register() { export function register() {
registerOTel('next-app') registerOTel({ serviceName: 'next-app' })
} }
``` ```
See the [`@vercel/otel` documentation](https://www.npmjs.com/package/@vercel/otel) for additional configuration options.
<AppOnly> <AppOnly>
> **Good to know** > **Good to know**
...@@ -87,7 +85,7 @@ export function register() { ...@@ -87,7 +85,7 @@ export function register() {
### Manual OpenTelemetry configuration ### Manual OpenTelemetry configuration
If our wrapper `@vercel/otel` doesn't suit your needs, you can configure OpenTelemetry manually. The `@vercel/otel` package provides many configuration options and should serve most of common use cases. But if it doesn't suit your needs, you can configure OpenTelemetry manually.
Firstly you need to install OpenTelemetry packages: Firstly you need to install OpenTelemetry packages:
...@@ -146,8 +144,7 @@ const sdk = new NodeSDK({ ...@@ -146,8 +144,7 @@ const sdk = new NodeSDK({
sdk.start() sdk.start()
``` ```
Doing this is equivalent to using `@vercel/otel`, but it's possible to modify and extend. Doing this is equivalent to using `@vercel/otel`, but it's possible to modify and extend some features that are not exposed by the `@vercel/otel`.
For example, you could use `@opentelemetry/exporter-trace-otlp-grpc` instead of `@opentelemetry/exporter-trace-otlp-http` or you can specify more resource attributes.
## Testing your instrumentation ## Testing your instrumentation
...@@ -183,8 +180,7 @@ Once you have your collector up and running, you can deploy your Next.js app to ...@@ -183,8 +180,7 @@ Once you have your collector up and running, you can deploy your Next.js app to
### Custom Exporters ### Custom Exporters
We recommend using OpenTelemetry Collector. OpenTelemetry Collector is not necessary. You can use a custom OpenTelemetry exporter with [`@vercel/otel`](#using-vercelotel) or [manual OpenTelemetry configuration](/docs/pages/building-your-application/optimizing/open-telemetry#manual-opentelemetry-configuration).
If that is not possible on your platform, you can use a custom OpenTelemetry exporter with [manual OpenTelemetry configuration](/docs/pages/building-your-application/optimizing/open-telemetry#manual-opentelemetry-configuration)
## Custom Spans ## Custom Spans
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment