Skip to content

Commit 6f182a9

Browse files
author
mike dupont
committed
now compiles
1 parent 86028bc commit 6f182a9

File tree

3 files changed

+139
-19
lines changed

3 files changed

+139
-19
lines changed

agent/run.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
# --trace-event-categories node,node.bootstrap,node.console,node.vm.script,v8,node.http,node.net.native,node.environment
3+
node --enable-source-maps --heap-prof --expose-gc --prof --cpu-prof --loader ts-node/esm src/index.ts "--isRoot" "--characters=characters/eliza.character.json"

agent/src/index.ts

+78-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
console.log("Hello agent")
1+
//
2+
import { registerInstrumentations } from '@opentelemetry/instrumentation';
3+
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
24
import { diag, DiagConsoleLogger, DiagLogLevel } from '@opentelemetry/api';
3-
import { NodeSDK } from '@opentelemetry/sdk-node';
5+
//import { NodeSDK } from '@opentelemetry/sdk-node';
6+
import { SpanExporter, Span } from '@opentelemetry/sdk-trace-base';
7+
// , ExportResult
48
import { ConsoleSpanExporter } from '@opentelemetry/sdk-trace-node';
59
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
610
import { PeriodicExportingMetricReader, ConsoleMetricExporter,} from '@opentelemetry/sdk-metrics';
@@ -35,25 +39,80 @@ const options = {
3539
}
3640
}
3741
const traceExporter_zipkin = new ZipkinExporter(options);
38-
// parts from https://stackoverflow.com/questions/71654897/opentelemetry-typescript-project-zipkin-exporter
39-
40-
const sdk = new NodeSDK({
41-
resource: new Resource({
42-
[ATTR_SERVICE_NAME]: 'eliza-agent',
43-
[ATTR_SERVICE_VERSION]: '1.0',
44-
}),
45-
//traceExporter: new ConsoleSpanExporter(),
46-
traceExporter: traceExporter_zipkin,
47-
instrumentations: [getNodeAutoInstrumentations(),
48-
new HttpInstrumentation()
49-
50-
],
51-
});
42+
const traceExporter = new ConsoleSpanExporter();
43+
44+
45+
export class CustomConsoleSpanExporter implements SpanExporter {
46+
export(spans: Span[], resultCallback: (result: ExportResult) => void): void {
47+
console.log("hello1")
48+
traceExporter.export(spans,resultCallback);
49+
traceExporter.export(traceExporter_zipkin,resultCallback);
50+
for (const span of spans) {
51+
const spanData = {
52+
name: span.name,
53+
traceId: span.spanContext().traceId,
54+
spanId: span.spanContext().spanId,
55+
startTime: span.startTime,
56+
endTime: span.endTime,
57+
attributes: span.attributes,
58+
events: span.events,
59+
status: span.status,
60+
kind: span.kind,
61+
};
62+
console.log(JSON.stringify(spanData, null, 2));
63+
}
64+
resultCallback(ExportResult.SUCCESS);
65+
}
66+
shutdown(): Promise<void> {
67+
return Promise.resolve();
68+
}
69+
}
70+
//const myExporter = new CustomConsoleSpanExporter()
5271

53-
// For troubleshooting, set the log level to DiagLogLevel.DEBUG
54-
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.ALL);
72+
// parts from https://stackoverflow.com/questions/71654897/opentelemetry-typescript-project-zipkin-exporter
73+
//const { SimpleSpanProcessor } = import('@opentelemetry/sdk-trace-base');
74+
import { NodeTracerProvider, SimpleSpanProcessor } from "@opentelemetry/sdk-trace-node";
75+
const txz=new SimpleSpanProcessor(traceExporter_zipkin);
76+
const tx=new SimpleSpanProcessor(traceExporter);
77+
78+
try {
79+
const serviceName = 'eliza-agent';
80+
const provider = new NodeTracerProvider({
81+
resource: new Resource({
82+
[SEMRESATTRS_SERVICE_NAME]: serviceName,
83+
[ATTR_SERVICE_NAME]: serviceName,
84+
[ATTR_SERVICE_VERSION]: '1.0', }),
85+
spanProcessors: [
86+
txz,
87+
tx
88+
]
89+
});
5590

56-
console.log(sdk.start());
91+
// Initialize the OpenTelemetry APIs to use the NodeTracerProvider bindings
92+
provider.register();
93+
94+
registerInstrumentations({
95+
instrumentations: [
96+
getNodeAutoInstrumentations(),
97+
new HttpInstrumentation(),
98+
],
99+
});
100+
101+
opentelemetry.trace.getTracer('http-example');
102+
console.log("setup!")
103+
} catch(error){
104+
console.log("ERROR",error)
105+
}
106+
// const sdk = new NodeSDK({ resource: new Resource({
107+
108+
// //traceExporter: new ConsoleSpanExporter(),
109+
// traceExporter: myExporter,
110+
// //traceExporter_zipkin
111+
// instrumentations: [, new HttpInstrumentation() ],
112+
// });
113+
// // For troubleshooting, set the log level to DiagLogLevel.DEBUG
114+
// diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.ALL);
115+
// console.log(sdk.start());
57116

58117

59118
import { PostgresDatabaseAdapter } from "@elizaos/adapter-postgres";

packages.txt

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
./docs/package.json
2+
./packages/plugin-ton/package.json
3+
./packages/plugin-video-generation/package.json
4+
./packages/plugin-coinbase/package.json
5+
./packages/plugin-coinbase/advanced-sdk-ts/package.json
6+
./packages/plugin-twitter/package.json
7+
./packages/plugin-echochambers/package.json
8+
./packages/plugin-tee/package.json
9+
./packages/client-telegram/package.json
10+
./packages/plugin-solana/package.json
11+
./packages/plugin-image-generation/package.json
12+
./packages/plugin-fuel/package.json
13+
./packages/plugin-bootstrap/package.json
14+
./packages/plugin-conflux/package.json
15+
./packages/plugin-near/package.json
16+
./packages/adapter-sqljs/package.json
17+
./packages/plugin-trustdb/package.json
18+
./packages/plugin-aptos/package.json
19+
./packages/client-twitter/package.json
20+
./packages/client-slack/package.json
21+
./packages/plugin-node/package.json
22+
./packages/plugin-flow/package.json
23+
./packages/client-direct/package.json
24+
./packages/plugin-0g/package.json
25+
./packages/adapter-supabase/package.json
26+
./packages/plugin-intiface/package.json
27+
./packages/client-github/package.json
28+
./packages/plugin-zksync-era/package.json
29+
./packages/plugin-abstract/package.json
30+
./packages/client-auto/package.json
31+
./packages/plugin-goat/package.json
32+
./packages/client-discord/package.json
33+
./packages/plugin-ferePro/package.json
34+
./packages/plugin-cronoszkevm/package.json
35+
./packages/plugin-web-search/package.json
36+
./packages/plugin-gitbook/package.json
37+
./packages/plugin-whatsapp/package.json
38+
./packages/plugin-icp/package.json
39+
./packages/core/package.json
40+
./packages/plugin-sui/package.json
41+
./packages/adapter-sqlite/package.json
42+
./packages/plugin-avalanche/package.json
43+
./packages/_examples/plugin/package.json
44+
./packages/plugin-multiversx/package.json
45+
./packages/adapter-redis/package.json
46+
./packages/client-farcaster/package.json
47+
./packages/plugin-nft-generation/package.json
48+
./packages/create-eliza-app/package.json
49+
./packages/adapter-postgres/package.json
50+
./packages/plugin-story/package.json
51+
./packages/plugin-starknet/package.json
52+
./packages/plugin-evm/package.json
53+
./packages/client-lens/package.json
54+
./packages/plugin-3d-generation/package.json
55+
./package.json
56+
./scripts/jsdoc-automation/package.json
57+
./client/package.json
58+
./agent/package.json

0 commit comments

Comments
 (0)