Skip to content

Commit

Permalink
Adapt metadata to New Relic required format for attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-rr committed Feb 5, 2024
1 parent e0f6949 commit 75e0a2d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/commands/optimize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,23 @@ export default class Optimize extends Command {
this.optimizations = flags.optimization as Optimizations[];
this.outputMethod = flags.output as Outputs;

this.metricsMetadata.optimizations = JSON.stringify(this.optimizations);

if (!(report.moveToComponents?.length || report.removeComponents?.length || report.reuseComponents?.length)) {
this.log(`No optimization has been applied since ${this.specFile.getFilePath() ?? this.specFile.getFileURL()} looks optimized!`);
this.metricsMetadata.optimized = false;
return;
}

if (report.moveToComponents?.length) {
this.metricsMetadata.optimization_moveToComponents = true;
this.metricsMetadata.optimized = true;
}
if (report.removeComponents?.length) {
this.metricsMetadata.optimization_removeComponents = true;
this.metricsMetadata.optimized = true;
}
if (report.reuseComponents?.length) {
this.metricsMetadata.optimization_reuseComponents = true;
this.metricsMetadata.optimized = true;
return;
}

Expand Down

0 comments on commit 75e0a2d

Please sign in to comment.