Skip to content

Docs: Optimizing:Opentelemetry should be updated #77451

@WendaoLee

Description

@WendaoLee

What is the documentation issue?

The sample code in https://nextjs.org/docs/app/building-your-application/optimizing/open-telemetry#manual-opentelemetry-configuration:

import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'
import { Resource } from '@opentelemetry/resources'
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({
    [ATTR_SERVICE_NAME]: 'next-app',
  }),
  spanProcessor: new SimpleSpanProcessor(new OTLPTraceExporter()),
})
sdk.start()

is not supported for newest OpentelemetrySDK . It should be:

import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'
import { resourceFromAttributes } from '@opentelemetry/resources'
import { NodeSDK } from '@opentelemetry/sdk-node'
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-node'
import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from '@opentelemetry/semantic-conventions'

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

If anyone try to write code like this above opentelemetry/resources >= 2.0.0,the new Resource({ [ATTR_SERVICE_NAME]: 'next-app', }), won't work,for the developer has changed its api.

Should add some annotation for it.

Is there any context that might help us understand?

See open-telemetry/opentelemetry-js#5421.

Does the docs page already exist? Please link to it.

Metadata

Metadata

Assignees

Labels

ImprovementReport possible improvements to make in our documentationgood first issueEasy to fix issues, good for newcomerslocked

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions