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
8 changes: 8 additions & 0 deletions packages/services/api/src/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { oidcIntegrationsModule } from './modules/oidc-integrations';
import { OIDC_INTEGRATIONS_ENABLED } from './modules/oidc-integrations/providers/tokens';
import { operationsModule } from './modules/operations';
import { CLICKHOUSE_CONFIG, ClickHouseConfig } from './modules/operations/providers/tokens';
import { OTEL_TRACING_ENABLED } from './modules/operations/providers/traces';
import { organizationModule } from './modules/organization';
import { schemaPolicyModule } from './modules/policy';
import {
Expand Down Expand Up @@ -113,6 +114,7 @@ export function createRegistry({
organizationOIDC,
pubSub,
appDeploymentsEnabled,
otelTracingEnabled,
prometheus,
}: {
logger: Logger;
Expand Down Expand Up @@ -157,6 +159,7 @@ export function createRegistry({
organizationOIDC: boolean;
pubSub: HivePubSub;
appDeploymentsEnabled: boolean;
otelTracingEnabled: boolean;
prometheus: null | Record<string, unknown>;
}) {
const s3Config: S3Config = [
Expand Down Expand Up @@ -284,6 +287,11 @@ export function createRegistry({
useValue: appDeploymentsEnabled,
scope: Scope.Singleton,
},
{
provide: OTEL_TRACING_ENABLED,
useValue: otelTracingEnabled,
scope: Scope.Singleton,
},
{
provide: WEB_APP_URL,
useValue: app?.baseUrl.replace(/\/$/, '') ?? 'http://localhost:3000',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import DataLoader from 'dataloader';
import stableJSONStringify from 'fast-json-stable-stringify';
import { Injectable } from 'graphql-modules';
import { Inject, Injectable, InjectionToken } from 'graphql-modules';
import { z } from 'zod';
import { subDays } from '@/lib/date-time';
import * as GraphQLSchema from '../../../__generated__/types';
Expand All @@ -12,6 +12,8 @@ import { ClickHouse, sql } from './clickhouse-client';
import { formatDate } from './operations-reader';
import { SqlValue } from './sql';

export const OTEL_TRACING_ENABLED = new InjectionToken<boolean>('OTEL_TRACING_ENABLED');

@Injectable({
global: true,
})
Expand All @@ -20,11 +22,12 @@ export class Traces {
private clickHouse: ClickHouse,
private logger: Logger,
private storage: Storage,
@Inject(OTEL_TRACING_ENABLED) private otelTracingEnabled: boolean,
) {}

async viewerCanAccessTraces(organizationId: string) {
const organization = await this.storage.getOrganization({ organizationId });
return organization.featureFlags.otelTracing;
return organization.featureFlags.otelTracing || this.otelTracingEnabled;
}

private async _guardViewerCanAccessTraces(organizationId: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
resourceLevelToHumanReadableName,
resourceLevelToResourceLevelType,
} from '../../auth/resolvers/Permission';
import { OTEL_TRACING_ENABLED } from '../../operations/providers/traces';
import { IdTranslator } from '../../shared/providers/id-translator';
import { Logger } from '../../shared/providers/logger';
import { PG_POOL_CONFIG } from '../../shared/providers/pg-pool';
Expand Down Expand Up @@ -152,6 +153,7 @@ export class OrganizationAccessTokens {
private storage: Storage,
private members: OrganizationMembers,
logger: Logger,
@Inject(OTEL_TRACING_ENABLED) private otelTracingEnabled: boolean,
) {
this.logger = logger.child({
source: 'OrganizationAccessTokens',
Expand Down Expand Up @@ -890,7 +892,7 @@ export class OrganizationAccessTokens {

private createFeatureFlagPermissionFilter(organization: Organization) {
const isAppDeplymentsEnabled = organization.featureFlags.appDeployments;
const isOTELTracingEnabled = organization.featureFlags.otelTracing;
const isOTELTracingEnabled = organization.featureFlags.otelTracing || this.otelTracingEnabled;

return (id: Permission) =>
(!isAppDeplymentsEnabled && id.startsWith('appDeployment:')) ||
Expand Down
1 change: 1 addition & 0 deletions packages/services/server/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ INTEGRATION_GITHUB="<sync>"
INTEGRATION_GITHUB_APP_ID="<sync>"
INTEGRATION_GITHUB_APP_PRIVATE_KEY="<sync>"
FEATURE_FLAGS_APP_DEPLOYMENTS_ENABLED="0"
FEATURE_FLAGS_OTEL_TRACING_ENABLED="0"

# Zendesk Support
ZENDESK_SUPPORT='0'
Expand Down
5 changes: 5 additions & 0 deletions packages/services/server/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ const EnvironmentModel = zod.object({
FEATURE_FLAGS_APP_DEPLOYMENTS_ENABLED: emptyString(
zod.union([zod.literal('1'), zod.literal('0')]).optional(),
),
FEATURE_FLAGS_OTEL_TRACING_ENABLED: emptyString(
zod.union([zod.literal('1'), zod.literal('0')]).optional(),
),
});

const CommerceModel = zod.object({
Expand Down Expand Up @@ -529,5 +532,7 @@ export const env = {
featureFlags: {
/** Whether app deployments should be enabled by default for everyone. */
appDeploymentsEnabled: base.FEATURE_FLAGS_APP_DEPLOYMENTS_ENABLED === '1',
/** Whether OTEL tracing should be enabled for all organizations. */
otelTracingEnabled: base.FEATURE_FLAGS_OTEL_TRACING_ENABLED === '1',
},
} as const;
1 change: 1 addition & 0 deletions packages/services/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ export async function main() {
supportConfig: env.zendeskSupport,
pubSub,
appDeploymentsEnabled: env.featureFlags.appDeploymentsEnabled,
otelTracingEnabled: env.featureFlags.otelTracingEnabled,
prometheus: env.prometheus,
});

Expand Down
Loading