Skip to content
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

how to dynamically name for each function #10

Closed
sgraham785 opened this issue Nov 15, 2018 · 5 comments
Closed

how to dynamically name for each function #10

sgraham785 opened this issue Nov 15, 2018 · 5 comments
Labels
enhancement New feature or request

Comments

@sgraham785
Copy link

this work well thanks. however, I have a service that has multiple functions and I would like to split and track each separately. the easiest way is to name the stat with the function, even append the name when it's invoked in the function? just starting the conversation cause I am not completely clear on how you implemented yet

@spike008t
Copy link
Contributor

Hi! Thank you for your feedback.

I don't really understand what you want. Do you mean that you want to create the entry on the fly?

@sgraham785
Copy link
Author

on the call of a single function in a service. for example is i have a service that has multiple functions that all compose the module. how can i define the entry specific to the function without having to create a separate static configuration for each function in the module and inject in the service

@sgraham785
Copy link
Author

does my above comment make it clearer? or still need further comments?

@spike008t
Copy link
Contributor

Sorry for the delay, I was a quite busy at the moment.

I do understand your need, I'll try to find out some time to handle it. I need to think how can I manage it. I think it can be possible to have something like this:

class MyClass {
  @PromCounterMetric('myCounter')
  doStuff() {
    myCounter.inc();
  }
}

Or if the aim is to monitor how many time a function is called, can be cool to have something like that:

class MyClass {
  @PromCounterMetricAutoInc()
  doStuff() {
  }
}

@spike008t spike008t added the enhancement New feature or request label Aug 21, 2019
@spike008t
Copy link
Contributor

@sgraham785 I've updated the module with new decorators @PromInstanceCounter and @PromMethodCounter.

It's a simple decorator that will generate automatically counter without need to declare the counter.
See

  • v0.1.0 for nestjs 5
  • v0.2.0 for nestjs 6

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

No branches or pull requests

2 participants