Skip to content

Cannot instrument two functions on the same tracing channel name #19

Description

@simon-id

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions