nodejs / nodejs/orchestrion-js

Cannot instrument two functions on the same tracing channel name

Open
#19 0 comments 0 reactions 1 assignee View on GitHub

@sabrenner is already working on this.

Since Jun 13, 2025.

enhancement
Dominant language
JavaScript
Stars
24
Forks
11
PR merge metrics
No merged PRs in 30d

Description

While writing tests I wanted to instrument multiple functions while using the same tracing channel, so I wrote this:

use crate::common::*;
use orchestrion_js::*;

#[test]
fn param_mutation() {
    transpile_and_test(
        file!(),
        false,
        Config::new(
            vec![
                InstrumentationConfig::new(
                    "param_mutation",
                    test_module_matcher(),
                    FunctionQuery::function_declaration("fetch_simple_args", FunctionKind::Sync),
                ),
                InstrumentationConfig::new(
                    "param_mutation",
                    test_module_matcher(),
                    FunctionQuery::function_declaration("fetch_complex_args", FunctionKind::Sync),
                ),
            ],
            None,
        ),
    );
}

but this will end up rewriting the file with this:

const { tracingChannel: tr_ch_apm_tracingChannel } = require("diagnostics_channel");
const tr_ch_apm$param_mutation = tr_ch_apm_tracingChannel("orchestrion:undici:param_mutation");
const tr_ch_apm$param_mutation = tr_ch_apm_tracingChannel("orchestrion:undici:param_mutation");

thus creating the variable tr_ch_apm$param_mutation twice, which is not legal syntax.

We have real use cases for using the same channel for multiple functions. Maybe I just don't know how to do it with the current API, but if it's not possible currently, it would be a welcomed addition.
For now we can work around it by having channel1 and channel2 but it's not optimal.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.