nextjs - 💡(How to fix) Fix Otel server spans lack required attributes according to the semantic conventions [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#92006Fetched 2026-04-08 01:40:11
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Author
Timeline (top)
labeled ×2closed ×1commented ×1issue_type_added ×1

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jan 19 22:00:55 PST 2026; root:xnu-11417.140.69.708.3~1/RELEASE_ARM64_T6000
  Available memory (MB): 65536
  Available CPU cores: 10
Binaries:
  Node: 24.14.0
  npm: 11.9.0
  Yarn: N/A
  pnpm: 10.33.0
Relevant Packages:
  next: 16.2.1 // Latest available version is detected (16.2.1).
  eslint-config-next: 14.1.4
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 6.0.2
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/vercel/next.js/tree/canary/examples/with-opentelemetry

To Reproduce

  1. start application
  2. look at server spans created

Current vs. Expected behavior

net.host.name is missing. It's not explicitly stated in your codebase but inferring from the other attributes you attempted to be compliant with 1.20.0 of the HTTP server spans. It states that this attribute is required.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jan 19 22:00:55 PST 2026; root:xnu-11417.140.69.708.3~1/RELEASE_ARM64_T6000
  Available memory (MB): 65536
  Available CPU cores: 10
Binaries:
  Node: 24.14.0
  npm: 11.9.0
  Yarn: N/A
  pnpm: 10.33.0
Relevant Packages:
  next: 16.2.1 // Latest available version is detected (16.2.1).
  eslint-config-next: 14.1.4
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 6.0.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Instrumentation

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

No response

extent analysis

Fix Plan

To fix the missing net.host.name attribute in server spans, you need to update the OpenTelemetry instrumentation to include this required attribute.

Step-by-Step Solution

  1. Update the net.host.name attribute: In your OpenTelemetry configuration, add the net.host.name attribute to the server span. You can do this by using the setAttribute method on the span object.
  2. Get the hostname: Use the os module in Node.js to get the hostname of the machine running the application.

Example Code

const os = require('os');
const { trace } = require('@opentelemetry/api');

// Get the hostname
const hostname = os.hostname();

// Create a server span
const span = trace.getTracer('my-tracer').startSpan('my-span');

// Set the net.host.name attribute
span.setAttribute('net.host.name', hostname);

// End the span
span.end();

Integration with Next.js

In your Next.js application, you can integrate this fix by updating the OpenTelemetry instrumentation in the pages/_app.js file or in a separate module that handles tracing.

import { trace } from '@opentelemetry/api';
import os from 'os';

// Get the hostname
const hostname = os.hostname();

// Create a tracer
const tracer = trace.getTracer('my-tracer');

// Update the server span
export function getServerSideProps() {
  const span = tracer.startSpan('my-span');
  span.setAttribute('net.host.name', hostname);
  // ...
  span.end();
  return {
    props: {},
  };
}

Verification

To verify that the fix worked, you can check the server spans created by your application and look for the net.host.name attribute. You can use a tool like Jaeger or Zipkin to visualize the spans and verify that the attribute is present.

Extra Tips

  • Make sure to update the OpenTelemetry version to the latest version to ensure compatibility with the latest specifications.
  • If you are using a custom tracer, make sure to update the tracer configuration to include the net.host.name attribute.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING