Skip to content

Conversation

vitalii-diachkov-sumup
Copy link

As it was discussed in other issue before, OTEL allows you to configure your exporter URL and other attributes using environment variables, e.g. OTEL_EXPORTER_ENDPOINT for settings URL and service name can be set via OTEL_SERVICE_NAME or using OTEL_RESURCE_ATTRIBUTES="service.name=my-service-name". This PR makes url and serviceName fields non-mandatory to set when configuring OTEL node.

I've also noticed that child spans has different service.name value as it was overwritten and set to the node name itself, for example http request, which I found as unintuitive and undesired behaviour. If you want to keep this behaviour, I can remove this one change from the PR

Copy link
Owner

@nioc nioc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR.

I'd like you to change a few things:

  • keeping service.name attribute
  • keep exporter url default value
  • check and display error in node status if there is no exporter URL configured
  • keep serviceName default value
  • update node HTML documentation
  • remove merge import which is not used

CompositePropagator,
W3CBaggagePropagator,
W3CTraceContextPropagator,
merge,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not used

parentSpan = tracer.startSpan(_rootPrefix + spanName, {
attributes: {
[ATTR_IS_MESSAGE_CREATION]: true,
[ATTR_SERVICE_NAME]: nodeDefinition.type,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to keep the service.name attribute for the parent, as it describes the logical name of the service (cf. https://opentelemetry.io/docs/specs/semconv/attributes-registry/service/).
It is different from node_red.node.type which is used to describe a specific Node-RED span attribute and code.function which is used for child spans only.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I tested it it was just set to http in, which confused me. Even if it contains the flow name itself, I don't want it to override service.name attribute on spans/traces, as service.name attribute for us is reserved for the name of internal microservice and is stattic across all application.

I can make it as another config option which is turned on by default, what do you think?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my understanding, you have a service name for each Node-RED instance?
In my use, I want to have the "parent" span telling me "yeah this is a message inject" (coming from inside my Node-RED) or "this trace come from an external http request".


// create tracer
let spanProcessor
const traceExporterProps = url ? { url } : {}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's weird... exporting to nothing? 😆
Cf. previous comment about error prone.

Copy link
Author

@vitalii-diachkov-sumup vitalii-diachkov-sumup Mar 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If URL is not explicitly provided, OTEL will derive the value from the environment. I can leave a code comment above this line

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, add an explicit comment, and may be this is the place to add the check from previous comment.

Comment on lines 47 to 48
value: '',
required: false,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also a source of errors (if it's left empty and there's no environment variable, traces come from unknown_service:/usr/local/bin/node)...
Ok not to be mandatory, but I prefer to keep the default value.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just thought since we have a placeholders, users might already have a clue on what's the expected value there. I can put the default there in place, also add a red badge when its missing (same as for URL)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can go checking in repo issues, sometimes users install without reading the doc and don't think about the configuration either and come telling "that's do not work" 😆

@nioc nioc added the enhancement New feature or request label Mar 16, 2025
@nioc nioc linked an issue Mar 16, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change Url, Service and Root Prefix using environments variables

2 participants