-
Notifications
You must be signed in to change notification settings - Fork 533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cucumber instrumentation not creating spans #2502
Comments
do you compile your code to ESM or commonjs? 🤔 |
Yes, it turns out that was the problem. If this is useful for anyone, this is what my execution command looks like to run And this is my tracing.ts file: import { NodeSDK } from '@opentelemetry/sdk-node'
import { Resource } from '@opentelemetry/resources'
import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from '@opentelemetry/semantic-conventions'
import * as api from '@opentelemetry/api'
import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'
import * as grpc from '@grpc/grpc-js'
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc'
import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base'
import TracingConstants from './src/tracing/constants'
import { Constants } from './src/shared/constants'
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node'
const collectorOptions = {
url: TracingConstants.OTEL_EXPORTER_OTLP_ENDPOINT,
credentials: grpc.credentials.createInsecure(),
}
const spanProcessors = [new SimpleSpanProcessor(new OTLPTraceExporter(collectorOptions))]
if (Constants.ERROR_LEVEL === 'DEBUG') {
spanProcessors.push(new SimpleSpanProcessor(new ConsoleSpanExporter()))
}
export const sdk = new NodeSDK({
resource: new Resource({
[ATTR_SERVICE_NAME]: TracingConstants.SERVICE_NAME,
[ATTR_SERVICE_VERSION]: TracingConstants.SERVICE_VERSION,
}),
spanProcessors: spanProcessors,
instrumentations: [getNodeAutoInstrumentations()],
})
const contextManager = new AsyncHooksContextManager().enable()
api.context.setGlobalContextManager(contextManager)
try {
sdk.start()
console.log('Tracing initialized')
} catch (error) {
console.log('Error initializing tracing', error)
} Edit: |
I am trying to instrument my cucumber tests in NodeJS but I can't make it trace anything at all.
I tried using both
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node'
and
import { CucumberInstrumentation } from '@opentelemetry/instrumentation-cucumber'
but had no luck with either.
This is the file I have that sets up the telemetry:
It gets called and if I create spans manually they show up in the OTELCollector, so telemetry seems to be properly set up.
Does anyone have a real example of to set it up for a real cucumber project?
The text was updated successfully, but these errors were encountered: