Skip to content

Commit

Permalink
Recommend @opentelemetry/api instead of @vercel/otel reexport (#48013)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
jankaifer authored Apr 6, 2023
1 parent dd95925 commit e35710f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
11 changes: 6 additions & 5 deletions docs/advanced-features/open-telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Expand Down
4 changes: 0 additions & 4 deletions examples/with-opentelemetry/.vscode/settings.json

This file was deleted.

1 change: 1 addition & 0 deletions examples/with-opentelemetry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"dependencies": {
"@vercel/otel": "latest",
"@opentelemetry/api": "^1.4.1",
"next": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/with-opentelemetry/shared/fetch-github-stars.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { trace } from '@vercel/otel'
import { trace } from '@opentelemetry/api'

export async function fetchGithubStars() {
return await trace
Expand Down

0 comments on commit e35710f

Please sign in to comment.