|
|
@@ -1,5 +1,6 @@
|
|
|
import { DynamicModule, Injectable, Type } from '@nestjs/common';
|
|
|
import { LanguageCode } from '@vendure/common/lib/generated-types';
|
|
|
+import { Span, TraceService } from 'nestjs-otel';
|
|
|
import { DataSourceOptions, getMetadataArgsStorage } from 'typeorm';
|
|
|
|
|
|
import { getConfig } from './config-helpers';
|
|
|
@@ -29,7 +30,7 @@ export class ConfigService implements VendureConfig {
|
|
|
private activeConfig: RuntimeVendureConfig;
|
|
|
private allCustomFieldsConfig: Required<CustomFields> | undefined;
|
|
|
|
|
|
- constructor() {
|
|
|
+ constructor(private readonly traceService: TraceService) {
|
|
|
this.activeConfig = getConfig();
|
|
|
if (this.activeConfig.authOptions.disableAuth) {
|
|
|
// eslint-disable-next-line
|
|
|
@@ -120,9 +121,12 @@ export class ConfigService implements VendureConfig {
|
|
|
return this.activeConfig.systemOptions;
|
|
|
}
|
|
|
|
|
|
+ @Span('vendure.config.get-custom-fields-for-all-entities')
|
|
|
private getCustomFieldsForAllEntities(): Required<CustomFields> {
|
|
|
const definedCustomFields = this.activeConfig.customFields;
|
|
|
const metadataArgsStorage = getMetadataArgsStorage();
|
|
|
+ const span = this.traceService.getSpan();
|
|
|
+ span?.setAttribute('customFields', JSON.stringify(definedCustomFields));
|
|
|
// We need to check for any entities which have a "customFields" property but which are not
|
|
|
// explicitly defined in the customFields config. This is because the customFields object
|
|
|
// only includes the built-in entities. Any custom entities which have a "customFields"
|
|
|
@@ -140,10 +144,12 @@ export class ConfigService implements VendureConfig {
|
|
|
.find(c => c.propertyName === 'languageCode');
|
|
|
if (hasCustomFields && !isTranslationEntity) {
|
|
|
definedCustomFields[entity.name] = [];
|
|
|
+ span?.addEvent('removed-custom-fields', { entity: entity.name });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ span?.end();
|
|
|
return definedCustomFields;
|
|
|
}
|
|
|
|