Comments (2)
Hey @julien-sugg,
Can you provide some code snippets which result in uninstrumented code?
I want to assess the required effort
from opentelemetry-ext-js.
Hi @nirsky,
Thanks for your quick response, I cannot share the real code because it is a closed-source project. However, I can share some redacted content.
Ecosystem:
- NestJS 7.X
- pg driver 8.3.0 + TypeORM 0.2.25 (using NestJS TypeORM integration that acts more or less as a wrapper around TypeORM 7.X)
The simplest use-case that we would like to instrument is the read model (query) which is done though a two layer style architecture using the TypeORM SelectQueryBuilder
// foo.controller.ts
@Controller( 'foo' )
export class FooController {
constructor(
private readonly commandBus: CommandBus,
private readonly queryBus: QueryBus
) {}
@Get()
async list(
@Query( QueryParamEnum.page ) page?: number,
@Query( QueryParamEnum.perPage ) perPage?: number,
@Query( QueryParamEnum.sortBy ) sort?: Sort[],
@Query( QueryParamEnum.filterBy ) filter?: Where,
): Promise<GetFooListDtoPresentation> {
return this.queryBus.execute<redacted>(
new GetFooListQuery(
page,
perPage,
sort,
filter,
),
);
}
}
// foo.query.ts
export class GetFooListQuery implements IQuery,
PagedQueryInterface,
SortedQueryInterface,
FilteredQueryInterface {
constructor(
) {
}
}
// foo.query-handler.ts
@QueryHandler( GetFooListQuery )
export class GetFooListQueryHandler
extends QueryableQueryHandler
implements IQueryHandler<GetFooListQuery, FooListDto> {
private readonly entityManager: EntityManager;
constructor(
@InjectEntityManager()
entityManager: EntityManager,
) {
super();
this.entityManager = entityManager;
}
async execute( query: ContextualGetFooListQuery ): Promise<FooListDto> {
const queryBuilder = this.entityManager
.createQueryBuilder( FooEntity, 'foo' )
.leftJoinAndSelect( 'foo.bar', 'bar' );
const pageData = PageQueryHelper.getPageData( query );
GetFooListQueryHandler.applyQueryingLogic(
queryBuilder,
pageData,
query,
);
const [
fooRecords,
totalRecords,
] = await queryBuilder.getManyAndCount();
// Redacted mapper
return {
records: fooRecords,
page: pageData.offset,
perPage: pageData.next,
totalRecords,
};
}
}
We also have similar instrumentation troubles on the write model (command) which is done through a multi-layered clean architecture style implementation.
// foo.repository.ts
@Injectable()
export class FooRepository implements FooRepositoryInterface {
private readonly fooRepository: Repository<FooEntity>;
constructor(
@InjectRepository( FooEntity )
fooRepository: Repository<FooEntity>,
) {
this.fooRepository = fooRepository;
}
// Here foo is an AggregateRoot, but it has no impact on the understanding as we have a mapper to convert from aggregate to DAO
async save( foo: Foo ): Promise<void> {
const fooDAO = FooMapper.toPersistence( foo );
await this.fooRepository.save( fooDAO );
}
}
If this is not helpful enough, I can create a minimalist repo for reproduction with a docker-compose stack.
from opentelemetry-ext-js.
Related Issues (20)
- Make instrumentations compatible with SDK 1.2.0/0.28.0 HOT 1
- Patch function not triggered on custom instrumentation for kafkajs library
- KafkaJs instrumentation does not work. HOT 2
- Add support for kafkajs library version 2.0.0 HOT 1
- Instrumentation not registered causing no traces/spans for typeorm HOT 4
- How to debug why kafkajs instrumentation doesn't connect spans on a different service HOT 4
- Make instrumentations compatible with latest SDK HOT 2
- Headers undefined
- B3 Propagation Context for kafkajs HOT 1
- Document supported versions HOT 3
- Support MongoDB insert instrumentation for Mongoose HOT 1
- Sequelize instrumentation is not working. HOT 2
- Upgrade OpenTelemetry to use the latest packages which include Metrics v1 GA HOT 1
- Getting error "could not resolve" while doing `npm i opentelemetry-instrumentation-elasticsearch` HOT 1
- sequelize: Suggest better regex for opentelemetry-instrumentation-sequelize/utils.js extractTableFromQuery
- Reason behind instrumentation-neo4j locked behind versions >=4.0.0 <5.0.0 of neo4j-driver HOT 4
- Error building project: yarn command fails in root dir
- Request: upstream kafkajs instrumentation HOT 4
- What happened to opentelemetry socket.io? HOT 1
- Proposal: Adding requireParentSpan: true to packages
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 opentelemetry-ext-js.