Skip to content

Commit d219a40

Browse files
fix: work with remote server (#69)
1 parent a0fd1e2 commit d219a40

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

jest-opentelemetry.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
22
timeout: 2000,
3-
useRemoteOtelReceiver: false,
3+
useLocalOtelReceiver: true, // default (false) is to use traceloop backend
44
};

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"start:test-servers": "lerna run --scope @traceloop/test-servers start",
1010
"docker:instrument-opentelemetry": "docker build -f packages/instrument-opentelemetry/Dockerfile . -t instrument-opentelemetry",
1111
"docker:test-servers": "docker build -f packages/test-servers/Dockerfile . -t test-servers",
12-
"test": "jest",
13-
"test-ci": "concurrently -k --success \"command-1\" --hide 0 \"npm:start:test-servers\" \"npm:test\"",
12+
"test": "TRACELOOP_URL='http://localhost:4123/v1/traces' jest",
13+
"test-ci": "TRACELOOP_URL='http://localhost:4123/v1/traces' concurrently -k --success \"command-1\" --hide 0 \"npm:start:test-servers\" \"npm:test\"",
1414
"release": "npm run build && lerna publish --conventional-commits --no-private"
1515
},
1616
"workspaces": [

packages/expect-opentelemetry/src/trace-loop/fetch-traces.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ export interface FetchTracesConfig {
1010
pollInterval: number;
1111
awaitAllSpansInTraceTimeout: number;
1212
url: string;
13-
customerId: string;
13+
apiKey: string;
1414
}
1515

1616
export const fetchTracesConfigBase: FetchTracesConfig = {
1717
maxPollTime: 9000,
1818
pollInterval: 1000,
1919
awaitAllSpansInTraceTimeout: 2000,
20-
url: 'http://localhost:4123/v1/traces',
21-
customerId: 'local',
20+
url: process.env.TRACELOOP_URL || 'https://api.traceloop.dev/v1/traces',
21+
apiKey: process.env.TRACELOOP_API_KEY || 'none',
2222
};
2323

2424
/**

packages/expect-opentelemetry/src/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import http from 'http';
2+
import https from 'https';
23
import { opentelemetry } from '@traceloop/otel-proto';
34
import { FetchTracesConfig } from './trace-loop/fetch-traces';
45

@@ -88,7 +89,8 @@ export function httpGetBinary(
8889
): Promise<Buffer> {
8990
const url = `${config.url}/${traceloopId}`;
9091
return new Promise((resolve, reject) => {
91-
http.get(url, { headers: { Authorization: config.customerId } }, (res) => {
92+
const method = config.url.includes('https') ? https : http;
93+
method.get(url, { headers: { Authorization: config.apiKey } }, (res) => {
9294
const { statusCode } = res;
9395

9496
if (!statusCode || statusCode < 200 || statusCode >= 300) {

packages/jest-environment-otel/src/global.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export async function setup(jestConfig: JestConfig = {}) {
1818
didAlreadyRunInWatchMode = true;
1919
}
2020

21-
if (config.useRemoteOtelReceiver) {
21+
if (!config?.useLocalOtelReceiver) {
2222
return;
2323
}
2424

0 commit comments

Comments
 (0)