Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove metrics in fe #38240

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 9 additions & 48 deletions app/client/src/UITelemetry/auto-otel-web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@ import {
} from "@opentelemetry/semantic-conventions/incubating";
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
import { getAppsmithConfigs } from "ee/configs";
import {
MeterProvider,
PeriodicExportingMetricReader,
} from "@opentelemetry/sdk-metrics";
import {
AggregationTemporalityPreference,
OTLPMetricExporter,
} from "@opentelemetry/exporter-metrics-otlp-http";
import { metrics } from "@opentelemetry/api";
import { registerInstrumentations } from "@opentelemetry/instrumentation";
import { PageLoadInstrumentation } from "./PageLoadInstrumentation";
import { getWebAutoInstrumentations } from "@opentelemetry/auto-instrumentations-web";
Expand All @@ -44,7 +35,7 @@ const tracerProvider = new WebTracerProvider({
});

const nrTracesExporter = new OTLPTraceExporter({
url: addPathToCurrentUrl("/monitoring/traces"),
url: getAbsoluteUrl("/monitoring/traces"),
compression: CompressionAlgorithm.GZIP,
headers: {
"api-key": otlpLicenseKey,
Expand All @@ -71,41 +62,13 @@ tracerProvider.register({
contextManager: new ZoneContextManager(),
});

const nrMetricsExporter = new OTLPMetricExporter({
compression: CompressionAlgorithm.GZIP,
temporalityPreference: AggregationTemporalityPreference.DELTA,
url: addPathToCurrentUrl("/monitoring/metrics"),
headers: {
"api-key": otlpLicenseKey,
},
});

const meterProvider = new MeterProvider({
resource: new Resource({
[ATTR_DEPLOYMENT_NAME]: deploymentName,
[ATTR_SERVICE_INSTANCE_ID]: serviceInstanceId,
[ATTR_SERVICE_NAME]: serviceName,
}),
readers: [
new PeriodicExportingMetricReader({
exporter: nrMetricsExporter,
exportIntervalMillis: 30000, // Adjust the export interval as needed
}),
],
});

// Register the MeterProvider globally
metrics.setGlobalMeterProvider(meterProvider);

registerInstrumentations({
tracerProvider,
meterProvider,
instrumentations: [
new PageLoadInstrumentation({
ignoreResourceUrls: [
browserAgentEndpoint,
addPathToCurrentUrl("/monitoring/traces"),
addPathToCurrentUrl("/monitoring/metrics"),
getAbsoluteUrl("/monitoring/traces"),
smartlookBaseDomain,
],
}),
Expand All @@ -117,13 +80,11 @@ registerInstrumentations({
],
});

// Replaces the pathname of the current URL with the provided path.
function addPathToCurrentUrl(path: string) {
const origin = window.location.origin;

const currentUrl = new URL(origin);

currentUrl.pathname = path.startsWith("/") ? path : `/${path}`;

return currentUrl.toString();
/**
* This function adds the given path to the current URL and returns the absolute URL.
* @param path The path to be added to the current URL.
* @returns The absolute URL.
*/
function getAbsoluteUrl(path: string) {
return new URL(path, window.location.origin).toString();
}
Loading