Skip to content

Commit ce8011d

Browse files
committed
js: stub out observe api datadog
1 parent 0b2aa9d commit ce8011d

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

js/src/lib/adapters/datadog/formatter.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import {
2-
Nanoseconds,
2+
Log,
33
MemoryGrowAmount,
4+
Metric,
5+
MetricFormat,
6+
Nanoseconds,
47
newSpanId,
58
newTraceId,
69
TelemetryId,
@@ -52,6 +55,20 @@ export const addAllocation = (span: Span, amount: MemoryGrowAmount) => {
5255
span.meta[allocationKey] = sumAmount.toString();
5356
};
5457

58+
export const addMetric = (span: Span, metric: Metric) => {
59+
if (metric.format !== MetricFormat.StatsdFormat) {
60+
console.error('cannot add non-statsd metric');
61+
return;
62+
}
63+
const [key, value] = metric.message.split(/:(.*)/);
64+
};
65+
66+
export const addTags = (span: Span, tags: string[]) => {
67+
};
68+
69+
export const addLog = (span: Span, log: Log) => {
70+
};
71+
5572
export class DatadogFormatter {
5673
constructor(public traces: Trace[]) { }
5774

js/src/lib/adapters/datadog/mod.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ import {
55
CustomEvent,
66
FunctionCall,
77
MemoryGrow,
8+
Metric,
9+
MetricFormat,
10+
Log,
11+
LogLevel,
812
ObserveEvent,
913
Options,
1014
TelemetryId,
1115
WASM,
16+
SpanTags,
1217
} from "../../mod.ts";
1318
import { SpanCollector } from "../../collectors/span/mod.ts";
14-
import { addAllocation, DatadogFormatter, Trace } from "./formatter.ts";
19+
import { addAllocation, addMetric, addTags, addLog, DatadogFormatter, Trace } from "./formatter.ts";
20+
1521
export enum DatadogTraceType {
1622
Web = "web",
1723
Db = "db",
@@ -179,6 +185,15 @@ export class DatadogAdapter extends Adapter {
179185
if (event instanceof MemoryGrow) {
180186
addAllocation(span, event.amount);
181187
}
188+
if (event instanceof Metric) {
189+
addMetric(span, event);
190+
}
191+
if (event instanceof SpanTags) {
192+
addTags(span, event.tags);
193+
}
194+
if (event instanceof Log) {
195+
addLog(span, event);
196+
}
182197
});
183198
}
184199

0 commit comments

Comments
 (0)