-
Notifications
You must be signed in to change notification settings - Fork 599
Description
Is it possible to add an option or an hook for the default span created in
opentelemetry-js-contrib/packages/instrumentation-amqplib/src/amqplib.ts
Lines 416 to 447 in ca26f63
if (self._config.useLinksForConsume) { | |
const parentSpanContext = parentContext | |
? trace.getSpan(parentContext)?.spanContext() | |
: undefined; | |
parentContext = undefined; | |
if (parentSpanContext) { | |
links = [ | |
{ | |
context: parentSpanContext, | |
}, | |
]; | |
} | |
} | |
const span = self.tracer.startSpan( | |
`${queue} process`, | |
{ | |
kind: SpanKind.CONSUMER, | |
attributes: { | |
...channel?.connection?.[CONNECTION_ATTRIBUTES], | |
[SEMATTRS_MESSAGING_DESTINATION]: exchange, | |
[SEMATTRS_MESSAGING_DESTINATION_KIND]: | |
MESSAGINGDESTINATIONKINDVALUES_TOPIC, | |
[SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY]: msg.fields?.routingKey, | |
[SEMATTRS_MESSAGING_OPERATION]: MESSAGINGOPERATIONVALUES_PROCESS, | |
[SEMATTRS_MESSAGING_MESSAGE_ID]: msg?.properties.messageId, | |
[SEMATTRS_MESSAGING_CONVERSATION_ID]: | |
msg?.properties.correlationId, | |
}, | |
links, | |
}, | |
parentContext | |
); |
undefined
as the parentContext
makes it pick up the current active context, and an option to control that would be great.
If one uses useLinksForConsume
, the span gets created under the previously active spanContext
which might make things very hard for understanding where the span gets added (despite the links). It would be nice to add control over it, for example to set root: true
so that the span creates a new trace that it is linked to the publish one.
For example, using @opentelemetry/instrumentation-nestjs-core
all consumers with useLinksForConsume
will end up in the Create Nest App
(
opentelemetry-js-contrib/packages/instrumentation-nestjs-core/src/instrumentation.ts
Lines 124 to 131 in ca26f63
const span = tracer.startSpan('Create Nest App', { | |
attributes: { | |
...NestInstrumentation.COMMON_ATTRIBUTES, | |
[AttributeNames.TYPE]: NestType.APP_CREATION, | |
[AttributeNames.VERSION]: moduleVersion, | |
[AttributeNames.MODULE]: nestModule.name, | |
}, | |
}); |