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: Switch from OTLP HTTP/protobuf (New Relic) to HTTP/JSON (Grafana) #37404

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 10 additions & 10 deletions app/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@
"@mantine/hooks": "^5.10.1",
"@newrelic/browser-agent": "^1.255.0",
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/auto-instrumentations-web": "^0.41.0",
"@opentelemetry/context-zone": "1.25.1",
"@opentelemetry/core": "^1.26.0",
"@opentelemetry/exporter-metrics-otlp-http": "0.52.1",
"@opentelemetry/exporter-trace-otlp-proto": "0.52.1",
"@opentelemetry/instrumentation": "0.52.1",
"@opentelemetry/resources": "1.25.1",
"@opentelemetry/sdk-metrics": "1.25.1",
"@opentelemetry/sdk-trace-base": "1.25.1",
"@opentelemetry/sdk-trace-web": "1.25.1",
"@opentelemetry/auto-instrumentations-web": "^0.42.0",
"@opentelemetry/context-zone": "^1.27.0",
"@opentelemetry/core": "^1.27.0",
"@opentelemetry/exporter-metrics-otlp-http": "^0.54.2",
"@opentelemetry/exporter-trace-otlp-http": "^0.54.2",
"@opentelemetry/instrumentation": "^0.54.2",
"@opentelemetry/resources": "^1.27.0",
"@opentelemetry/sdk-metrics": "^1.27.0",
"@opentelemetry/sdk-trace-base": "^1.27.0",
"@opentelemetry/sdk-trace-web": "^1.27.0",
"@opentelemetry/semantic-conventions": "^1.27.0",
"@react-spring/web": "^9.7.4",
"@react-types/shared": "^3.23.0",
Expand Down
7 changes: 5 additions & 2 deletions app/client/packages/rts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
"start": "./start-server.sh"
},
"dependencies": {
"@opentelemetry/instrumentation-http": "^0.53.0",
"@opentelemetry/sdk-trace-node": "^1.26.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.54.2",
"@opentelemetry/instrumentation": "^0.54.2",
"@opentelemetry/instrumentation-http": "^0.54.2",
"@opentelemetry/resources": "^1.27.0",
"@opentelemetry/sdk-trace-node": "^1.27.0",
"@opentelemetry/semantic-conventions": "^1.27.0",
"@shared/ast": "workspace:^",
"axios": "^1.7.4",
Expand Down
8 changes: 6 additions & 2 deletions app/client/packages/rts/src/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import {
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
import { registerInstrumentations } from "@opentelemetry/instrumentation";
import { HttpInstrumentation } from "@opentelemetry/instrumentation-http";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";

const APPSMITH_NEW_RELIC_OTEL_EXPORTER_OTLP_ENDPOINT =
process.env.APPSMITH_NEW_RELIC_OTEL_EXPORTER_OTLP_ENDPOINT ||
"http://localhost:4318";

const provider = new NodeTracerProvider({
resource: new Resource({
Expand All @@ -21,7 +25,7 @@ const provider = new NodeTracerProvider({
});

const nrTracesExporter = new OTLPTraceExporter({
url: `${process.env.APPSMITH_NEW_RELIC_OTEL_EXPORTER_OTLP_ENDPOINT}/v1/traces`,
url: `${APPSMITH_NEW_RELIC_OTEL_EXPORTER_OTLP_ENDPOINT}/v1/traces`,
headers: {
"api-key": `${process.env.APPSMITH_NEW_RELIC_OTLP_LICENSE_KEY}`,
},
Expand Down
24 changes: 18 additions & 6 deletions app/client/src/UITelemetry/auto-otel-web.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
import { WebTracerProvider } from "@opentelemetry/sdk-trace-web";
import { ZoneContextManager } from "@opentelemetry/context-zone";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
import { Resource } from "@opentelemetry/resources";
import {
ATTR_DEPLOYMENT_NAME,
Expand All @@ -14,8 +14,8 @@ import {
PeriodicExportingMetricReader,
} from "@opentelemetry/sdk-metrics";
import {
OTLPMetricExporter,
AggregationTemporalityPreference,
OTLPMetricExporter,
} from "@opentelemetry/exporter-metrics-otlp-http";
import { metrics } from "@opentelemetry/api";
import { registerInstrumentations } from "@opentelemetry/instrumentation";
Expand All @@ -27,7 +27,7 @@ enum CompressionAlgorithm {
GZIP = "gzip",
}
const { newRelic, observability } = getAppsmithConfigs();
const { browserAgentEndpoint, otlpEndpoint, otlpLicenseKey } = newRelic;
const { browserAgentEndpoint, otlpLicenseKey } = newRelic;

subhrashisdas marked this conversation as resolved.
Show resolved Hide resolved
const { deploymentName, serviceInstanceId, serviceName } = observability;

Expand All @@ -44,7 +44,7 @@ const tracerProvider = new WebTracerProvider({
});

const nrTracesExporter = new OTLPTraceExporter({
url: `${otlpEndpoint}/v1/traces`,
url: addPathToCurrentUrl("/monitoring/traces"),
compression: CompressionAlgorithm.GZIP,
headers: {
"api-key": otlpLicenseKey,
Expand Down Expand Up @@ -74,7 +74,7 @@ tracerProvider.register({
const nrMetricsExporter = new OTLPMetricExporter({
compression: CompressionAlgorithm.GZIP,
temporalityPreference: AggregationTemporalityPreference.DELTA,
url: `${otlpEndpoint}/v1/metrics`,
url: addPathToCurrentUrl("/monitoring/metrics"),
headers: {
"api-key": otlpLicenseKey,
},
Expand Down Expand Up @@ -104,7 +104,8 @@ registerInstrumentations({
new PageLoadInstrumentation({
ignoreResourceUrls: [
browserAgentEndpoint,
otlpEndpoint,
addPathToCurrentUrl("/monitoring/traces"),
addPathToCurrentUrl("/monitoring/metrics"),
smartlookBaseDomain,
],
}),
Expand All @@ -115,3 +116,14 @@ 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();
}
Loading
Loading