opentelemetry-js icon indicating copy to clipboard operation
opentelemetry-js copied to clipboard

Success status code for grpc (rpc.grpc.status_code) incorrect using grpc-js

Open GregoryBL opened this issue 3 years ago • 1 comments
trafficstars

Please answer these questions before submitting a bug report.

What version of OpenTelemetry are you using?

1.1.0

What version of Node are you using?

16.14.0

Please provide the code you used to setup the OpenTelemetry SDK

This shouldn't be relevant, but:

import { registerInstrumentations } from '@opentelemetry/instrumentation'
import { GrpcInstrumentation } from '@opentelemetry/instrumentation-grpc'
import { Resource } from '@opentelemetry/resources'
import {
  ConsoleSpanExporter,
  SimpleSpanProcessor
} from '@opentelemetry/sdk-trace-base'
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'

const exporter = new ConsoleSpanExporter()
const provider = new NodeTracerProvider({
  resource: new Resource({
    [SemanticResourceAttributes.SERVICE_NAME]: 'test-service',
  }),
})
provider.addSpanProcessor(new SimpleSpanProcessor(exporter))
provider.register()

// Register the gRPC instrumentation
registerInstrumentations({
  instrumentations: [new GrpcInstrumentation()],
})

What did you do?

Make a successful request after setting up a grpc server with grpc-js and registering GrpcInstrumentation.

What did you expect to see?

Tag rpc.grpc.status_code is 0 (success)

What did you see instead?

Tag rpc.grpc.status_code is 1 (cancelled)

Additional context

This seems to be because it returns the OK value from the span status code enum instead of from the grpc status code enum. It also seems to work correctly if you use the grpc library (rather than grpc-js). See code here: https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/serverUtils.ts#L138

I'll have a PR fixing this coming shortly.

GregoryBL avatar May 19 '22 23:05 GregoryBL

Adding amir to assignees as he is looking into a related issue

dyladan avatar Jun 29 '22 16:06 dyladan