Skip to content
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
25 changes: 25 additions & 0 deletions front/src/utils/handoff.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* StackBlaze handoff context. Users minted by the embedding product's
* handoff (api/handoff.go) carry a synthetic @handoff.local email, and the
* consume step stores where the product is (coroot_return_url cookie).
*/
export function isHandoffUser(api) {
const email = (api && api.auth && api.auth.user && api.auth.user.email) || '';
return email.endsWith('@handoff.local');
}

/** The embedding product's origin (https://dashboard…), or '' when unknown. */
export function returnUrlOrigin() {
const m = document.cookie.match(/(?:^|; )coroot_return_url=([^;]*)(?:;|$)/);
if (!m) {
return '';
}
try {
return new URL(decodeURIComponent(m[1])).origin;
} catch {
return '';
}
}

/** The platform's OpenTelemetry collector, reachable from every app namespace. */
export const PLATFORM_OTLP_ENDPOINT = 'http://otel-collector.otel.svc:4318';
52 changes: 50 additions & 2 deletions front/src/views/OpenTelemetryIntegration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,41 @@
<slot></slot>
</v-btn>
</template>
<v-card class="pa-5">
<!-- StackBlaze handoff users: nothing is sent to Coroot directly (no
URL, no key, no collector of their own); the platform collects
traces from their apps. Admins keep the upstream dialog below. -->
<v-card v-if="handoff" class="pa-5">
<div class="d-flex align-center text-h5 mb-4">
Send traces from your apps
<v-spacer />
<v-btn icon @click="dialog = false"><v-icon>mdi-close</v-icon></v-btn>
</div>
<p>
Traces show every request's path through an app. Your apps never talk to Coroot directly: the platform collects their traces and keeps
them private to your workspace.
</p>

<div class="subtitle-1 font-weight-medium mt-4">1. Automatic (recommended)</div>
<p class="mb-2">
In StackBlaze, open the app's settings and turn <b>Tracing</b> on. Java, Node.js, Python and .NET apps are instrumented on their next
deploy, with no code changes.
</p>
<v-btn v-if="stackblazeUrl" :href="stackblazeUrl" color="primary" small>Open StackBlaze</v-btn>

<div class="subtitle-1 font-weight-medium mt-6">2. Your own OpenTelemetry SDK</div>
<p class="mb-2">
Already instrumented (Go, PHP, Ruby, Rust, …)? Turn Tracing on for the app with <b>Other: my own OpenTelemetry SDK</b> and point the
SDK at the platform collector:
</p>
<Code>
OTEL_EXPORTER_OTLP_ENDPOINT={{ platformEndpoint }}
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf OTEL_SERVICE_NAME=&lt;your app name&gt;
</Code>
<p class="mt-2 mb-0 grey--text">
No API key is needed: the collector accepts traces only from apps with Tracing on and tags them with your workspace.
</p>
</v-card>
<v-card v-else class="pa-5">
<div class="d-flex align-center text-h5 mb-4">
OpenTelemetry Integration
<v-spacer />
Expand Down Expand Up @@ -132,6 +166,7 @@ service:

<script>
import Code from '../components/Code.vue';
import { PLATFORM_OTLP_ENDPOINT, isHandoffUser, returnUrlOrigin } from '../utils/handoff';

export default {
props: {
Expand All @@ -156,9 +191,22 @@ export default {
};
},

computed: {
handoff() {
return isHandoffUser(this.$api);
},
stackblazeUrl() {
return returnUrlOrigin();
},
platformEndpoint() {
return PLATFORM_OTLP_ENDPOINT;
},
},

watch: {
dialog() {
this.dialog && this.get();
// Project API keys are admin-only; the handoff variant needs none.
this.dialog && !this.handoff && this.get();
},
},

Expand Down
33 changes: 17 additions & 16 deletions front/src/views/Traces.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@
</template>
<v-alert v-else-if="view.message" color="info" outlined text class="message">
<template v-if="view.message === 'not_found'">
This page only shows traces from OpenTelemetry integrations, not from eBPF.
<template v-if="handoff"
>No traces yet. Turn Tracing on for an app in StackBlaze; its traces appear here after the next deploy.</template
>
<template v-else>This page only shows traces from OpenTelemetry integrations, not from eBPF.</template>
<div class="mt-2">
<OpenTelemetryIntegration color="primary">Integrate OpenTelemetry</OpenTelemetryIntegration>
<OpenTelemetryIntegration color="primary">{{ integrateLabel }}</OpenTelemetryIntegration>
</div>
</template>
<template v-if="view.message === 'no_clickhouse'"> Clickhouse integration is not configured. </template>
Expand All @@ -50,7 +53,7 @@
<template v-else>
<div class="d-flex">
<v-spacer />
<OpenTelemetryIntegration small color="primary">Integrate OpenTelemetry</OpenTelemetryIntegration>
<OpenTelemetryIntegration small color="primary">{{ integrateLabel }}</OpenTelemetryIntegration>
</div>

<v-alert v-if="view.error" color="error" icon="mdi-alert-octagon-outline" outlined text class="mt-2">
Expand Down Expand Up @@ -433,6 +436,7 @@ import Heatmap from '../components/Heatmap.vue';
import TracingTrace from '../components/TracingTrace.vue';
import FlameGraph from '../components/FlameGraph.vue';
import OpenTelemetryIntegration from '@/views/OpenTelemetryIntegration.vue';
import { isHandoffUser, returnUrlOrigin } from '../utils/handoff';

export default {
components: { Views, OpenTelemetryIntegration, FlameGraph, TracingTrace, Heatmap },
Expand Down Expand Up @@ -480,20 +484,17 @@ export default {
},

computed: {
handoff() {
return isHandoffUser(this.$api);
},
integrateLabel() {
return this.handoff ? 'Send traces from your apps' : 'Integrate OpenTelemetry';
},
upgradeUrl() {
// Set on handoff consume (coroot_return_url): the embedding
// product's page. Its billing page opens the plan-upgrade window
// for the tracing gate.
const m = document.cookie.match(/(?:^|; )coroot_return_url=([^;]*)(?:;|$)/);
if (!m) {
return '';
}
try {
const u = new URL(decodeURIComponent(m[1]));
return `${u.origin}/billing?upgrade=TRACING_PLAN_REQUIRED`;
} catch {
return '';
}
// The embedding product's billing page opens the plan-upgrade
// window for the tracing gate (coroot_return_url cookie).
const origin = returnUrlOrigin();
return origin ? `${origin}/billing?upgrade=TRACING_PLAN_REQUIRED` : '';
},
views() {
return [
Expand Down
Loading