Skip to content

Commit

Permalink
Rename to tracer (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicole White authored Oct 27, 2023
1 parent 51b97b8 commit 865d4fe
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,24 @@ jobs:
- name: Run script
run: npm run start

# This allows us to have one required status check on the "test" job
# since it's not feasible to maintain required status checks on each
# job in the matrixes above.
test:
needs:
- test-python
- test-javascript

if: always()

runs-on: ubuntu-latest

steps:
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: |
echo "::error::One of the jobs failed or was cancelled."
exit 1
notify:
needs:
- test-python
Expand Down
13 changes: 6 additions & 7 deletions JavaScript/openai-manual/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
});

const traceId = crypto.randomUUID();
const ab = new AutoblocksTracer(process.env.AUTOBLOCKS_INGESTION_KEY, {
const tracer = new AutoblocksTracer(process.env.AUTOBLOCKS_INGESTION_KEY, {
// These apply to every call of ab.sendEvent() so we don't have to repeat them
traceId,
traceId: crypto.randomUUID(),
properties: {
provider: 'openai',
source: 'NODE_EXAMPLE',
Expand Down Expand Up @@ -41,29 +40,29 @@ async function run() {
n: 1,
};

await ab.sendEvent('ai.request', {
await tracer.sendEvent('ai.request', {
properties: openAIRequest,
});

try {
const now = Date.now();
const response = await openai.chat.completions.create(openAIRequest);
await ab.sendEvent('ai.response', {
await tracer.sendEvent('ai.response', {
properties: {
response,
latency: Date.now() - now,
},
});
} catch (error) {
await ab.sendEvent('ai.error', {
await tracer.sendEvent('ai.error', {
properties: {
error,
},
});
}

console.log(
`Finished running example. View the trace at https://app.autoblocks.ai/explore/trace/${traceId}`,
`Finished running example. View the trace at https://app.autoblocks.ai/explore/trace/${tracer.traceId}`,
);
}

Expand Down

1 comment on commit 865d4fe

@vercel
Copy link

@vercel vercel bot commented on 865d4fe Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.