Skip to content

Commit

Permalink
add opentelemetry #178
Browse files Browse the repository at this point in the history
  • Loading branch information
ukorvl committed Jun 12, 2024
1 parent 626e863 commit 0ff03ad
Show file tree
Hide file tree
Showing 12 changed files with 254 additions and 95 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ jobs:
PROOFMARKET_TOOLCHAIN_REPO = "${{ secrets.PROOFMARKET_TOOLCHAIN_REPO }}"
CIRCUIT_DEVELOPER_GUIDE_URL = "${{ secrets.CIRCUIT_DEVELOPER_GUIDE_URL }}"
API_RESPONSE_WAIT_TIMEOUT = "${{ secrets.API_RESPONSE_WAIT_TIMEOUT }}"
DATADOG_APPLICATION_ID = "${{ secrets.DATADOG_APPLICATION_ID }}"
DATADOG_CLIENT_TOKEN = "${{ secrets.DATADOG_CLIENT_TOKEN }}"
DATADOG_SITE = "${{ secrets.DATADOG_SITE }}"
DATADOG_SERVICE_NAME = "${{ secrets.DATADOG_SERVICE_NAME }}"
OTEL_TRACE_EXPORTER_URL = "${{ secrets.OTEL_TRACE_EXPORTER_URL }}"
'
echo "$config" > runtime-config.toml
echo runtime-config.toml
Expand Down
208 changes: 174 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"version": "0.1.9",
"private": true,
"dependencies": {
"@datadog/browser-rum": "^5.17.1",
"@loadable/component": "^5.15.3",
"@nilfoundation/react-components": "^0.8.3",
"@nilfoundation/ui-kit": "^2.1.3",
"@opentelemetry/exporter-trace-otlp-http": "^0.51.1",
"@opentelemetry/sdk-trace-web": "^1.24.1",
"@reduxjs/toolkit": "^1.8.5",
"baseui": "^13.0.0",
"bootstrap-sass": "^3.4.3",
Expand Down
5 changes: 1 addition & 4 deletions public/runtime-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@ GA_TRACKING_ID = ""
PROOFMARKET_TOOLCHAIN_REPO = ""
CIRCUIT_DEVELOPER_GUIDE_URL = ""
API_RESPONSE_WAIT_TIMEOUT = ""
DATADOG_APPLICATION_ID = ""
DATADOG_CLIENT_TOKEN = ""
DATADOG_SITE = ""
DATADOG_SERVICE_NAME = ""
OTEL_TRACE_EXPORTER_URL = ""
8 changes: 7 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useBreakpoint } from './features/shared';
import { MobileRouter } from './features/mobile';
import { NotificationContainer } from './features/notifications';
import { BREAKPOINT } from './styles/Breakpoint';
import { exportErrorToOtelCollector } from './opentelemetry';

const baseDocumentTitle = getRuntimeConfigOrThrow().SITE_DEFAULT_TITLE;

Expand All @@ -24,8 +25,13 @@ const baseDocumentTitle = getRuntimeConfigOrThrow().SITE_DEFAULT_TITLE;
function App(): ReactElement {
const bp = useBreakpoint();

throw new Error('Test error');

return (
<ErrorBoundary fallback={<ErrorView />}>
<ErrorBoundary
fallback={<ErrorView />}
onError={e => exportErrorToOtelCollector(e)}
>
<Helmet
titleTemplate={`${baseDocumentTitle} | %s`}
defaultTitle={baseDocumentTitle}
Expand Down
8 changes: 8 additions & 0 deletions src/api/common/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ky from 'ky';
import { LocalStorageAPI } from '@/packages/localStorageAdapter';
import { getRuntimeConfigOrThrow } from '@/utils';
import { apiBaseUrl } from './apiHelpers';
import { exportErrorToOtelCollector } from '../../opentelemetry';

/**
* Create api client settings.
Expand Down Expand Up @@ -61,6 +62,13 @@ export const createApiClient = (params: CreateApiClientParameters) => {
request.headers.set('Authorization', `Bearer ${LocalStorageAPI.getItem('userToken')}`);
},
],
beforeError: [
error => {
exportErrorToOtelCollector(error);

return error;
},
],
},
timeout: Number(API_RESPONSE_WAIT_TIMEOUT) ?? defaultTimeout,
...options,
Expand Down
40 changes: 0 additions & 40 deletions src/datadog.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/features/routing/constants/routesConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* @copyright Yury Korotovskikh <[email protected]>
*/

import { lazy } from 'react';
import { Navigate } from 'react-router-dom';
import type { RouteObject } from 'react-router-dom';
import { RouterParam } from '@/enums';
Expand Down
4 changes: 2 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import { Provider as StyletronProvider } from 'styletron-react';
import { BaseProvider } from 'baseui';
import App from './App';
import { store } from './redux';
import { configureDatadogRUM } from './datadog';
import { initOpentelemetry } from './opentelemetry';
import { reportWebVitals } from './reportWebVitals';
import configureGA from './ga';
//import * as serviceWorkerRegistration from './serviceWorkerRegistration';
import { checkRuntimeConfig } from './utils';

checkRuntimeConfig();
configureDatadogRUM();
configureGA();
initOpentelemetry();

const engine = new Styletron();
const { theme } = createTheme(engine, { enableDefaultFonts: false });
Expand Down
Loading

0 comments on commit 0ff03ad

Please sign in to comment.