Skip to content

http.response.status_code always reported as 200 #63

@ilijapuaca

Description

@ilijapuaca

What version of Elysia is running?

1.4.18

What platform is your computer?

Darwin 25.1.0 arm64 arm

What steps can reproduce the bug?

After upgrading to latest elysia and opentelemetry plugin, all the traces seem to be reported as 200 although that is not the case. The repo should be as simple as the code below and checking the trace out in Jaeger or Datadog

import { Elysia } from 'elysia'
import { opentelemetry } from '@elysiajs/opentelemetry'

import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-node'
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc'
import {ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION} from '@opentelemetry/semantic-conventions';
import {resourceFromAttributes} from '@opentelemetry/resources';

const serviceName = 'elysia-test';
const version = '0.0.0';
const environment = 'dev';

new Elysia()
	.use(
		opentelemetry({
      serviceName: 'elysia-test',
			spanProcessors: [
				new BatchSpanProcessor(
					new OTLPTraceExporter({
            url: 'http://localhost:4317',
            headers: {'Content-Type': 'application/json'},
          })
				)
			],
      resource: resourceFromAttributes({
        [ATTR_SERVICE_NAME]: serviceName,
        [ATTR_SERVICE_VERSION]: version,
        ['deployment.environment']: environment,
      }),
		})
  .get('/test', ({set}) => {
    set.status = 500;
    return 'Hello, world!';
  })
	)
	.listen(3000)

What is the expected behavior?

Correct status code is reported

What do you see instead?

All the traces are tagged as 200 although browser response is confirmed to have non-200 status code

Image Image

Additional information

No response

Have you try removing the node_modules and bun.lockb and try again yet?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions