Skip to content

Commit

Permalink
chore(docs): update opentelemetry docs (#70271)
Browse files Browse the repository at this point in the history
### What?


https://nextjs.org/docs/app/building-your-application/optimizing/open-telemetry
is partially outdated.

### Why?

- As mentioned
[here](https://github.com/open-telemetry/opentelemetry-js/blob/cdfefb829441f0c2765756d61078c39531c04d05/semantic-conventions/src/resource/SemanticResourceAttributes.ts#L649-L656),
SEMRESATTRS_SERVICE_NAME has been deprecated.
- Also, the default ESLint configuration generated by create-next-app
triggers warnings about the import order.

### How?

- so it has been changed to ATTR_SERVICE_NAME.
- Also, fixed the import order.

Co-authored-by: JJ Kasper <[email protected]>
  • Loading branch information
AnaTofuZ and ijjk authored Sep 23, 2024
1 parent 866537b commit 5c793bc
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,31 +113,31 @@ export async function register() {
```

```ts filename="instrumentation.node.ts" switcher
import { NodeSDK } from '@opentelemetry/sdk-node'
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'
import { Resource } from '@opentelemetry/resources'
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions'
import { NodeSDK } from '@opentelemetry/sdk-node'
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-node'
import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions'

const sdk = new NodeSDK({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: 'next-app',
[ATTR_SERVICE_NAME]: 'next-app',
}),
spanProcessor: new SimpleSpanProcessor(new OTLPTraceExporter()),
})
sdk.start()
```

```js filename="instrumentation.node.js" switcher
import { NodeSDK } from '@opentelemetry/sdk-node'
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'
import { Resource } from '@opentelemetry/resources'
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions'
import { NodeSDK } from '@opentelemetry/sdk-node'
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-node'
import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions'

const sdk = new NodeSDK({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: 'next-app',
[ATTR_SERVICE_NAME]: 'next-app',
}),
spanProcessor: new SimpleSpanProcessor(new OTLPTraceExporter()),
})
Expand Down

0 comments on commit 5c793bc

Please sign in to comment.