Skip to content

Commit f01e5ff

Browse files
author
Hweinstock
committed
refactor(tel): rename end to emit
1 parent da68951 commit f01e5ff

5 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ process.exit(
9393
throw error;
9494
} finally {
9595
try {
96-
await commandRunMetricEvent.end(Date.now() - startTime);
96+
await commandRunMetricEvent.emit(Date.now() - startTime);
9797
} catch (e) {
9898
const error = AgentCoreCLIError.fromError(e);
9999
rootLogger.child({ error: error.json() }).warn("failed to emit telemetry");

src/router/router.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ test.each([
721721
commandRunMetricEvent.setAttributes({ exit_reason: "success" });
722722
}
723723

724-
await commandRunMetricEvent.end(100);
724+
await commandRunMetricEvent.emit(100);
725725

726726
expect(recordedMetrics).toHaveLength(1);
727727
expect(recordedMetrics[0]!.metricName).toBe("cli.command_run");

src/telemetry/client.test.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ describe("DefaultTelemetryClient", () => {
4545
command_path: "/agentcore",
4646
});
4747

48-
await metricEvent.end(123);
48+
await metricEvent.emit(123);
4949

5050
// Start a second event with failure
5151
const metricEvent2 = client.startMetricEvent("cli.command_run", {
5252
exit_reason: "failure",
5353
command_path: "/agentcore",
5454
});
5555

56-
await metricEvent2.end(456);
56+
await metricEvent2.emit(456);
5757
await client.shutdown();
5858

5959
expect(fileSystemSink.getName()).toBe("FileSystemSink");
@@ -139,14 +139,14 @@ describe("DefaultTelemetryClient", () => {
139139
command_path: "/agentcore",
140140
is_tui: true,
141141
});
142-
await enabledEvent.end(123);
142+
await enabledEvent.emit(123);
143143

144144
const disabledEvent = disabledClient.startMetricEvent("cli.command_run", {
145145
exit_reason: "failure",
146146
command_path: "/agentcore",
147147
is_tui: false,
148148
});
149-
await disabledEvent.end(123);
149+
await disabledEvent.emit(123);
150150

151151
await Promise.all([enabledClient.shutdown(), disabledClient.shutdown()]);
152152

@@ -181,7 +181,7 @@ describe("DefaultTelemetryClient", () => {
181181

182182
const metricEvent = client.startMetricEvent("cli.command_run");
183183

184-
await expect(metricEvent.end(100)).rejects.toThrow();
184+
await expect(metricEvent.emit(100)).rejects.toThrow();
185185
await client.shutdown();
186186
});
187187

@@ -202,7 +202,7 @@ describe("DefaultTelemetryClient", () => {
202202
exit_reason: "success",
203203
command_path: "/agentcore",
204204
});
205-
await metricEvent.end(1);
205+
await metricEvent.emit(1);
206206
await client.shutdown();
207207

208208
await assertLogsMatch(tempDir, [
@@ -248,7 +248,7 @@ describe("DefaultTelemetryClient", () => {
248248
});
249249

250250
// end should not throw even though the sink's send() throws
251-
await metricEvent.end(100);
251+
await metricEvent.emit(100);
252252
// shutdown should not throw even though the sink's shutdown() rejects
253253
await client.shutdown();
254254

src/telemetry/client.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class InMemoryMetricEvent<TMetricName extends MetricName> implements MetricEvent
140140
};
141141
}
142142

143-
async end(value: ValueOf<TMetricName>): Promise<void> {
143+
async emit(value: ValueOf<TMetricName>): Promise<void> {
144144
const metricAttributes = METRICS[this.metricName]["attributeSchema"].parse(this.data);
145145
const validatedValue = METRICS[this.metricName]["valueSchema"].parse(value);
146146
const resourceAttributes = await this.getResourceAttributes();

src/telemetry/types.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export interface MetricEvent<TMetricName extends MetricName> {
2424
/** Accumulate attributes incrementally. Later calls overwrite earlier values for the same key. */
2525
setAttributes(data: Partial<AttributesOf<TMetricName>>): void;
2626

27-
/** Validate attributes, emit value + attributes to all sinks. */
28-
end(value: ValueOf<TMetricName>): Promise<void>;
27+
/** Validate attributes and emit value + attributes to all sinks. */
28+
emit(value: ValueOf<TMetricName>): Promise<void>;
2929
}
3030

3131
/**

0 commit comments

Comments
 (0)