Comments (13)
@issackr I just fixed the reuse of metrics. I haven't tested on NestJS 8.x yet. They have changed a lot of things. Might need to test a new example this week.
from nestjs-otel.
Hey, I created PrometheusModule for metrics based on the package and I'm trying to test it but get the error:
Nest can't resolve dependencies of the MetricService (?). Please make sure that the argument OpenTelemetryMeterProvider at index [0] is available in the PrometheusModule context.
this is my module:
import { Module } from "@nestjs/common";
import { LoggerModule } from "../../logger/logger.module";
import { PrometheusService } from "./prometheus.service";
import { MetricService } from "nestjs-otel";
@module({
imports: [LoggerModule],
providers: [PrometheusService, MetricService],
exports: [PrometheusService],
})
export class PrometheusModule {}
and my testing module:
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [PrometheusModule],
providers: [
SweetLogger,
ImageResolver,
{
provide: 'METADATA_SERVICE',
useValue: Image,
},
],
}).compile();
resolver = module.get<ImageResolver>(ImageResolver);
});
but I fail to provide OpenTelemetryMeterProvider whatever I do, I'm not sure how to provide injected stuff.
Will be glad for any help!
Tnx
from nestjs-otel.
MetricService is injected globally when you use that lib. What you are trying to do is to inject the service directly into another module without any other dependency is available.
In your main app you need OpenTelemetryModule.forRoot(
to be called in your imports for all the dependencies of this service to be available.
Is there a reason you would be creating a prometheus service? MetricService should cover most of the cases, all you need is a prometheus exporter
from nestjs-otel.
basically you are right but I used interceptor to meter all requests and I noticed that the counters are reset each time if not injected one by one, so I wrapped it with a module that is MetricService alike.
Regarding the error, I added OpenTelemetryModule.forRoot() to my PrometheusModule and now I get another error:
Nest can't resolve dependencies of the OpenTelemetryCoreModule
from nestjs-otel.
Hey @issackr could you share more on that issue? when you mean reset each time if not injected, what you mean by that? It should reuse the existing one.
from nestjs-otel.
@pragmaticivan Sure, it means the counters value aggregators remain on 1 after each call, no matter how many calls you make. Regarding the injection I meant like in other libraries which you need to inject each counter your'e using (not generic enough for me), anyway I solved it by wrapping my metric in another map of my own like in MetricService.
I can share the code if you like.
Anyway, do you have any lead how to solve my tests problem about OpenTelemetryCoreModule ModuleRef?
The error:
Nest can't resolve dependencies of the OpenTelemetryCoreModule (OpenTelemetryModuleOptions, ?). Please make sure that the argument ModuleRef at index [1] is available in the OpenTelemetryCoreModule context.
Tnx
from nestjs-otel.
@pragmaticivan I also migrated my project to nest 8, maybe this is whats making problems
from nestjs-otel.
Ohh I haven't tested with nest 8, there might be a problem there indeed.
from nestjs-otel.
basically you are right but I used interceptor to meter all requests and I noticed that the counters are reset each time if not injected one by one, so I wrapped it with a module that is MetricService alike.
Regarding the error, I added OpenTelemetryModule.forRoot() to my PrometheusModule and now I get another error:
Nest can't resolve dependencies of the OpenTelemetryCoreModule
I think I found the bug you mentioned while adding more tests today.
from nestjs-otel.
release 1.8.2
should have the fix @issackr
from nestjs-otel.
@pragmaticivan Looks awesome, thanks for the great work! still having the testing ModuleRef issue though
from nestjs-otel.
fyi @issackr a lot of the problems I found when I created that lib are going to be fixed in this PR: #55
It will require a Major version though.
from nestjs-otel.
@pragmaticivan Tnx for the update, I'm definitely gonna use it
from nestjs-otel.
Related Issues (20)
- ApiMetricsMiddleware is not initialized if forRootAsync is used HOT 1
- TraceService.getSpan should return Span|undefined
- Error: Cannot read properties of undefined (reading 'getMeterProvider') since v5.0.0 HOT 2
- README configuration Typescript errors: NodeJSConfiguration interface doesn't have metricExporter and metricInterval properties HOT 3
- Typescript errors: Cannot find module 'dns/promises' or its corresponding type declarations HOT 2
- Cannot find module '@opentelemetry/exporter-prometheus' or its corresponding type declarations.ts(2307) HOT 2
- Custom metrics README example is generating TS errors HOT 5
- metric name for the grafana dashboard example is wrong HOT 1
- Server response error and client request error count metrics returns the same value HOT 3
- Support for nestjs v10? HOT 1
- Tutorial section provides wrong suggestions (for Kubernetes cluster) HOT 1
- Breaking changes 5.1.3 | Cannot use with nest v9 HOT 1
- Latency buckets are not matching the expected time unit in milliseconds HOT 4
- Prometeus metric cluster aggregation HOT 2
- Failure to collect metrics using Telegraf HOT 1
- apiMetrics cannot be used with OpenTelemetry Prometheus exporter when getNodeAutoInstrumentations is used HOT 2
- Access function args in @Span decorator HOT 1
- Counter example from the README generating TS errors HOT 1
- Distributed tracing correlation issue. HOT 2
- Please update dependencies HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nestjs-otel.