Recommend @opentelemetry/api instead of @vercel/otel reexport (#48013)
- remove vscode folder from example - recommend `@poentelemetry/api` over `@vercel/otel` <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation or adding/fixing Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # --> fix NEXT-959
This commit is contained in:
parent
dd959251e6
commit
e35710f71f
4 changed files with 8 additions and 10 deletions
|
@ -56,13 +56,16 @@ To see more spans, you must set `NEXT_OTEL_VERBOSE=1`.
|
|||
|
||||
## Custom Spans
|
||||
|
||||
OpenTelemetry enables you to add your own custom spans to trace using official OpenTelemetry APIs.
|
||||
Our package `@vercel/otel` exports everything from `@opentelemetry/api` so you don't need to install anything.
|
||||
You can add your own span with [OpenTelemetry APIs](https://opentelemetry.io/docs/instrumentation/js/instrumentation).
|
||||
|
||||
```bash
|
||||
npm install @opentelemetry/api
|
||||
```
|
||||
|
||||
The following example demonstrates a function that fetches GitHub stars and adds a custom `fetchGithubStars` span to track the fetch request's result:
|
||||
|
||||
```ts
|
||||
import { trace } from '@vercel/otel'
|
||||
import { trace } from '@opentelemetry/api'
|
||||
|
||||
export async function fetchGithubStars() {
|
||||
return await trace
|
||||
|
@ -77,8 +80,6 @@ export async function fetchGithubStars() {
|
|||
}
|
||||
```
|
||||
|
||||
More documentation can be found in [OpenTelemetry docs](https://opentelemetry.io/docs/instrumentation/js/instrumentation/).
|
||||
|
||||
The `register` function will execute before your code runs in a new environment.
|
||||
You can start creating new spans, and they should be correctly added to the exported trace.
|
||||
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"typescript.tsdk": "../../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib",
|
||||
"typescript.enablePromptUseWorkspaceTsdk": true
|
||||
}
|
|
@ -8,6 +8,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@vercel/otel": "latest",
|
||||
"@opentelemetry/api": "^1.4.1",
|
||||
"next": "latest",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { trace } from '@vercel/otel'
|
||||
import { trace } from '@opentelemetry/api'
|
||||
|
||||
export async function fetchGithubStars() {
|
||||
return await trace
|
||||
|
|
Loading…
Reference in a new issue