Skip to content

Commit

Permalink
Merge pull request #56 from modern-sapien/otel-implementation
Browse files Browse the repository at this point in the history
updated instrumentation file to sample all traces.
  • Loading branch information
modern-sapien authored Jul 17, 2024
2 parents 217b18b + cac45cb commit e820f6e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
3 changes: 1 addition & 2 deletions next-webstore/app/components/bookCards.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use client';

import Link from 'next/link';
import { trace, SpanStatusCode
} from '@opentelemetry/api';
import { trace, SpanStatusCode } from '@opentelemetry/api';
import BookProfile from './bookProfile';
import { useState, useEffect } from 'react';

Expand Down
21 changes: 7 additions & 14 deletions next-webstore/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,12 @@ export function register() {
spanProcessors: ['auto'],
traceSampler: {
shouldSample: (context: Context) => {
const isChecklySpan = trace.getSpan(context)?.spanContext()?.traceState?.get('checkly')
if (isChecklySpan) {
console.log('Sampling decision for Checkly span:', SamplingDecision.RECORD_AND_SAMPLED)
return {
decision: SamplingDecision.RECORD_AND_SAMPLED
}
} else {
console.log('Sampling decision for non-Checkly span:', SamplingDecision.NOT_RECORD)
return {
decision: SamplingDecision.NOT_RECORD
}
}
// Always sample all spans
console.log('Sampling decision:', SamplingDecision.RECORD_AND_SAMPLED);
return {
decision: SamplingDecision.RECORD_AND_SAMPLED,
};
},
},
})
}
});
}
2 changes: 1 addition & 1 deletion next-webstore/tests/e2e/otel.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test';

test('Custom Browser Check', async ({ page }) => {
const response = await page.goto('https://next-danube-webshop.vercel.app'); // <- Change this
const response = await page.goto('https://next-danube-webshop.vercel.app');
expect(response?.status()).toBeLessThan(400);
});

0 comments on commit e820f6e

Please sign in to comment.