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

refactor(otel-attributes-cleanup): remove growi.attachment.type from application resource attributes

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

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

@@ -8,7 +8,7 @@
   - _Requirements: 1.1, 1.3_
   - _Boundary: OsResourceAttributes_
 
-- [ ] 1.2 (P) Remove growi.attachment.type from application resource attributes
+- [x] 1.2 (P) Remove growi.attachment.type from application resource attributes
   - `application-resource-attributes.ts` の返り値 attributes から `'growi.attachment.type'` 行を削除する。
   - 同ファイル内の `growiInfoService.getGrowiInfo({ includeAttachmentInfo: true })` 呼び出しから `includeAttachmentInfo: true` を除去する(このモジュールからは `attachmentType` を参照しなくなるため)。
   - `application-resource-attributes.spec.ts` から `growi.attachment.type` 関連の期待値・スタブを削除する。

+ 8 - 11
apps/app/src/features/opentelemetry/server/custom-resource-attributes/application-resource-attributes.spec.ts

@@ -21,13 +21,10 @@ describe('getApplicationResourceAttributes', () => {
     vi.clearAllMocks();
   });
 
-  it('should return complete application resource attributes when growi info is available', async () => {
+  it('should return only service and deployment type attributes when growi info is available', async () => {
     const mockGrowiInfo = {
       type: 'app',
       deploymentType: 'standalone',
-      additionalInfo: {
-        attachmentType: 'local',
-      },
     };
 
     mockGrowiInfoService.getGrowiInfo.mockResolvedValue(mockGrowiInfo);
@@ -37,28 +34,28 @@ describe('getApplicationResourceAttributes', () => {
     expect(result).toEqual({
       'growi.service.type': 'app',
       'growi.deployment.type': 'standalone',
-      'growi.attachment.type': 'local',
-    });
-    expect(mockGrowiInfoService.getGrowiInfo).toHaveBeenCalledWith({
-      includeAttachmentInfo: true,
     });
+    expect(result).not.toHaveProperty('growi.attachment.type');
+    expect(mockGrowiInfoService.getGrowiInfo).toHaveBeenCalledWith({});
   });
 
-  it('should handle missing additionalInfo gracefully', async () => {
+  it('should not include growi.attachment.type even when additionalInfo is present', async () => {
     const mockGrowiInfo = {
       type: 'app',
       deploymentType: 'standalone',
-      additionalInfo: undefined,
+      additionalInfo: {
+        attachmentType: 'local',
+      },
     };
 
     mockGrowiInfoService.getGrowiInfo.mockResolvedValue(mockGrowiInfo);
 
     const result = await getApplicationResourceAttributes();
 
+    expect(result).not.toHaveProperty('growi.attachment.type');
     expect(result).toEqual({
       'growi.service.type': 'app',
       'growi.deployment.type': 'standalone',
-      'growi.attachment.type': undefined,
     });
   });
 

+ 1 - 4
apps/app/src/features/opentelemetry/server/custom-resource-attributes/application-resource-attributes.ts

@@ -17,15 +17,12 @@ export async function getApplicationResourceAttributes(): Promise<Attributes> {
     // Dynamic import to avoid circular dependencies
     const { growiInfoService } = await import('~/server/service/growi-info');
 
-    const growiInfo = await growiInfoService.getGrowiInfo({
-      includeAttachmentInfo: true,
-    });
+    const growiInfo = await growiInfoService.getGrowiInfo({});
 
     const attributes: Attributes = {
       // Service configuration (rarely changes after system setup)
       'growi.service.type': growiInfo.type,
       'growi.deployment.type': growiInfo.deploymentType,
-      'growi.attachment.type': growiInfo.additionalInfo?.attachmentType,
     };
 
     logger.info({ attributes }, 'Application resource attributes collected');