Просмотр исходного кода

feat(otel-attributes-cleanup): add attachment_type label to growi.configs gauge

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Yuki Takei 13 часов назад
Родитель
Сommit
a02d9fc04a

+ 1 - 1
.kiro/specs/otel-attributes-cleanup/tasks.md

@@ -16,7 +16,7 @@
   - _Requirements: 1.2, 1.3_
   - _Boundary: ApplicationResourceAttributes_
 
-- [ ] 2. (P) Add attachment_type label to growi.configs info gauge
+- [x] 2. (P) Add attachment_type label to growi.configs info gauge
   - `application-metrics.ts` の `result.observe(growiInfoGauge, 1, { ... })` のラベルオブジェクトに `attachment_type: growiInfo.additionalInfo?.attachmentType ?? ''` を追加する。既存の `getGrowiInfo({ includeAttachmentInfo: true })` 呼び出しはそのまま維持する。
   - `application-metrics.spec.ts` に attachment_type ラベル付与の検証を追加する: 通常ケース(例: `attachmentType: 'aws'`)と未取得フォールバックケース(`additionalInfo: undefined` で `attachment_type: ''`)の 2 系統。
   - 既存テストケース(site_url / site_url_hashed / wiki_type / external_auth_types)の期待ラベルオブジェクトに `attachment_type` を追加し、5 ラベル並存を明示的に検証する。

+ 6 - 0
apps/app/src/features/opentelemetry/server/custom-metrics/application-metrics.spec.ts

@@ -74,6 +74,7 @@ describe('addApplicationMetrics', () => {
       wikiType: 'open',
       additionalInfo: {
         activeExternalAccountTypes: ['google', 'github'],
+        attachmentType: 'aws',
       },
     };
 
@@ -102,6 +103,7 @@ describe('addApplicationMetrics', () => {
         site_url_hashed: undefined,
         wiki_type: 'open',
         external_auth_types: 'google,github',
+        attachment_type: 'aws',
       });
     });
 
@@ -131,6 +133,7 @@ describe('addApplicationMetrics', () => {
         site_url_hashed: expectedHash,
         wiki_type: 'open',
         external_auth_types: 'google,github',
+        attachment_type: 'aws',
       });
     });
 
@@ -145,6 +148,7 @@ describe('addApplicationMetrics', () => {
         ...mockGrowiInfo,
         additionalInfo: {
           activeExternalAccountTypes: [],
+          attachmentType: 'aws',
         },
       };
       mockGrowiInfoService.getGrowiInfo.mockResolvedValue(growiInfoWithoutAuth);
@@ -159,6 +163,7 @@ describe('addApplicationMetrics', () => {
         site_url_hashed: undefined,
         wiki_type: 'open',
         external_auth_types: '',
+        attachment_type: 'aws',
       });
     });
 
@@ -212,6 +217,7 @@ describe('addApplicationMetrics', () => {
         site_url_hashed: undefined,
         wiki_type: 'open',
         external_auth_types: '',
+        attachment_type: '',
       });
     });
   });

+ 1 - 0
apps/app/src/features/opentelemetry/server/custom-metrics/application-metrics.ts

@@ -55,6 +55,7 @@ export function addApplicationMetrics(): void {
           external_auth_types:
             growiInfo.additionalInfo?.activeExternalAccountTypes?.join(',') ||
             '',
+          attachment_type: growiInfo.additionalInfo?.attachmentType ?? '',
         });
       } catch (error) {
         loggerDiag.error('Failed to collect application config metrics', {