Skip to content
Discussion options

You must be logged in to vote

TL;DR: The OTEL_EXPORTER_OTLP_* values you see on the frontend container are server-side env vars. The browser bundle can’t read them automatically. You need to bridge them into the client code.

In vite.config.ts load the container env and add the values you need into the bundle as a constant:

// vite.config.ts

import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";

export default ({ mode }) => {
  const env = loadEnv(mode, process.cwd(), ""); // read all process envs

  return defineConfig({
    plugins: [react()],
    define: {
      __OTEL_EXPORTER_OTLP_HEADERS__: JSON.stringify(env.OTEL_EXPORTER_OTLP_HEADERS || ""),
    },
  });
};

Use it in the telem…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by farkhutdinova
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants