|
1 | 1 | import {resourceFromAttributes} from "@opentelemetry/resources"; |
2 | 2 |
|
3 | | -export const resource = resourceFromAttributes({ |
4 | | - ...(process.env.NEXT_PUBLIC_OTEL_SERVICE_NAME ? {'service.name': process.env.NEXT_PUBLIC_OTEL_SERVICE_NAME} : {}), |
5 | | - 'service.version': (process.env.NEXT_PUBLIC_SCULPTOR_VERSION ?? "0.0.0") + "-" + (process.env.NEXT_PUBLIC_EDITION ?? "edition"), |
6 | | - ...(process.env.NEXT_PUBLIC_OTEL_ENVIRONMENT ? {'deployment.environment.name': process.env.NEXT_PUBLIC_OTEL_ENVIRONMENT} : {}), |
| 3 | +/** |
| 4 | + * Runtime OpenTelemetry configuration for the browser. These values are served |
| 5 | + * by the `/api/config` route handler and read on the server at request |
| 6 | + * time, so they can be changed at runtime without rebuilding the app (unlike |
| 7 | + * `NEXT_PUBLIC_*` variables, which are inlined at build time). |
| 8 | + */ |
| 9 | +export interface ClientOtelConfig { |
| 10 | + tracesEndpoint?: string | null |
| 11 | + logsEndpoint?: string | null |
| 12 | + header?: string | null |
| 13 | + serviceName?: string | null |
| 14 | + environment?: string | null |
| 15 | + version?: string | null |
| 16 | + edition?: string | null |
| 17 | +} |
| 18 | + |
| 19 | +export const buildClientResource = (config: ClientOtelConfig) => resourceFromAttributes({ |
| 20 | + ...(config.serviceName ? {'service.name': config.serviceName} : {}), |
| 21 | + 'service.version': (config.version ?? "0.0.0") + "-" + (config.edition ?? "edition"), |
| 22 | + ...(config.environment ? {'deployment.environment.name': config.environment} : {}), |
7 | 23 | }); |
8 | 24 |
|
9 | 25 | export const serverResource = resourceFromAttributes({ |
|
0 commit comments