Skip to content

Commit ba5ab65

Browse files
committed
Move tracing SDK out of main application code
1 parent 609c40a commit ba5ab65

File tree

6 files changed

+19
-20
lines changed

6 files changed

+19
-20
lines changed

Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ FROM denoland/deno:alpine-1.31.2
22
RUN apk add --no-cache graphviz
33
ADD fonts/ /usr/share/fonts/truetype/
44

5+
ENV DENO_NO_UPDATE_CHECK=1
56
WORKDIR /src
67
ADD deps.ts .
78
RUN deno check deps.ts
89
ADD . .
9-
RUN deno check server.ts
10-
ENTRYPOINT ["deno","run","--allow-sys=hostname","--allow-env","--allow-net","--allow-run=deno,dot","--allow-read=.","server.ts"]
10+
RUN deno check entrypoint.ts
11+
ENTRYPOINT ["deno","run","--allow-sys=hostname","--allow-env","--allow-net","--allow-run=deno,dot","--allow-read=.","entrypoint.ts"]

deps.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ export {
2323
trace,
2424
context,
2525
type Context,
26-
} from "https://raw.githubusercontent.com/cloudydeno/deno-observability/9d996d1ce0ba6b15641cbc882b15fc63992418b9/tracing/api.ts";
26+
} from "https://deno.land/x/[email protected]/opentelemetry/api.js";
27+
export {
28+
httpTracer,
29+
} from "https://deno.land/x/[email protected]/instrumentation/http-server.ts";

entrypoint.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import "./tracer.ts";
2+
import "./server.ts";

public/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ <h2>
6666

6767
<p>Just browsing? Here's a few interesting modules:</p>
6868
<ul>
69-
<li><a href="/dependencies-of/https/raw.githubusercontent.com/cloudydeno/module-visualizer/main/server.ts?rankdir=LR">raw.githubusercontent.com/cloudydeno/module-visualizer/main/server.ts</a> (this website!, minimal)</li>
69+
<li><a href="/dependencies-of/https/raw.githubusercontent.com/cloudydeno/module-visualizer/main/server.ts?rankdir=LR">raw.githubusercontent.com/cloudydeno/module-visualizer/main/server.ts</a> (this website!)</li>
7070
<li><a href="/dependencies-of/x/[email protected]/mod.ts?rankdir=LR">deno.land/x/[email protected]/mod.ts</a> (minimal)</li>
7171
<li><a href="/dependencies-of/x/[email protected]/mod.ts">deno.land/x/[email protected]/mod.ts</a> (uses NPM packages via esm.sh)</li>
7272
<li><a href="/dependencies-of/x/[email protected]+0.20.0/mod.ts">deno.land/x/[email protected]+0.20.0/mod.ts</a></li>

server.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/usr/bin/env -S deno run --watch --check --allow-sys=hostname --allow-read --allow-net --allow-run=deno,dot --allow-env
22

3-
import { http, trace } from "./deps.ts";
3+
import { http, httpTracer, trace } from "./deps.ts";
44
import { serveFont, servePublic, serveTemplatedHtml } from './lib/request-handling.ts';
5-
import { httpTracer, provider } from "./tracer.ts";
65

76
// The different HTTP surfaces we expose
87
import * as DependenciesOf from './feat/dependencies-of/api.ts';

tracer.ts

+8-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
import { httpTracer, DenoFetchInstrumentation, DenoTracerProvider, OTLPTraceFetchExporter, Resource, SubProcessInstrumentation } from "https://deno.land/x/[email protected]/mod.ts";
2-
import { GoogleCloudPropagator } from "https://deno.land/x/[email protected]/tracing/propagators/google-cloud.ts";
3-
export { httpTracer };
1+
// TODO: this could be added to /x/observability as a preconfigured SDK
42

5-
export const provider = new DenoTracerProvider({
6-
resource: new Resource({
3+
import { DenoTelemetrySdk } from "https://deno.land/x/[email protected]/sdk.ts";
4+
import { CloudPropagator } from "https://deno.land/x/[email protected]/otel-platform/propagators/google-cloud.ts";
5+
6+
new DenoTelemetrySdk({
7+
resourceAttrs: {
78
'service.name': 'module-visualizer',
89
'service.version': Deno.env.get('K_REVISION')?.slice((Deno.env.get('K_SERVICE')?.length ?? -1)+1),
910
'deployment.environment': Deno.env.get('K_SERVICE') ? 'production' : 'local',
10-
}),
11-
propagator: new GoogleCloudPropagator(),
12-
instrumentations: [
13-
new DenoFetchInstrumentation(),
14-
new SubProcessInstrumentation(),
15-
],
16-
batchSpanProcessors: [
17-
new OTLPTraceFetchExporter(),
18-
],
11+
},
12+
propagator: new CloudPropagator(),
1913
});

0 commit comments

Comments
 (0)