Skip to content

Commit

Permalink
cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
jholm117 committed Sep 11, 2024
1 parent 8f77ed5 commit 9992ee1
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 148 deletions.
22 changes: 0 additions & 22 deletions charts/awsxray-exporter/templates/NOTES.txt

This file was deleted.

15 changes: 7 additions & 8 deletions charts/awsxray-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ spec:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
command: ["node", "index.js"]
env:
- name: OTEL_COLLECTOR_URL
value: {{ required "otelCollectorUrl is required" .Values.otelCollectorUrl }}
- name: OTEL_COLLECTOR_HOSTNAME
value: {{ required "otelCollector.hostname is required" .Values.otelCollector.hostname }}
{{- if .Values.otelCollector.port }}
- name: OTEL_COLLECTOR_PORT
value: {{ .Values.otelCollector.port }}
{{- end }}
{{- if .Values.pollingIntervalSeconds }}
- name: POLLING_INTERVAL_SECONDS
value: {{ .Values.pollingIntervalSeconds }}
Expand All @@ -47,14 +52,8 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
Expand Down
61 changes: 0 additions & 61 deletions charts/awsxray-exporter/templates/ingress.yaml

This file was deleted.

15 changes: 0 additions & 15 deletions charts/awsxray-exporter/templates/service.yaml

This file was deleted.

32 changes: 3 additions & 29 deletions charts/awsxray-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
# defaults to 10s
# pollingIntervalSeconds: "10"

# otelCollectorUrl: ""
# otelCollector.hostname: ""
# otelCollector.port: 2000

# filterExpression: ""

Expand Down Expand Up @@ -44,35 +45,17 @@ podSecurityContext:
# fsGroup: 2000

securityContext:
{}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
runAsUser: 1001

service:
type: ClusterIP
port: 80

ingress:
enabled: false
className: ""
annotations:
{}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local

resources:
{}
# We usually recommend not to specify default resources and to leave this as a conscious
Expand All @@ -86,15 +69,6 @@ resources:
# cpu: 100m
# memory: 128Mi

livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http

autoscaling:
enabled: false
minReplicas: 1
Expand Down
30 changes: 17 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,29 @@ import {
} from "@aws-sdk/client-xray";

const POLLING_INTERVAL_MILLISECONDS =
Number(process.env.POLLING_INTERVAL_SECONDS) * 1000 || 10000;
const OTEL_COLLECTOR_URL = process.env.OTEL_COLLECTOR_URL;
if (!OTEL_COLLECTOR_URL) {
throw new Error("OTEL_COLLECTOR_URL environment variable is required");
Number(process.env.POLLING_INTERVAL_SECONDS ?? 10) * 1000;

const OTEL_COLLECTOR_HOSTNAME = process.env.OTEL_COLLECTOR_HOSTNAME;
if (!OTEL_COLLECTOR_HOSTNAME) {
throw new Error("OTEL_COLLECTOR_HOSTNAME environment variable is required");
}

const OTEL_COLLECTOR_PORT = Number(process.env.OTEL_COLLECTOR_PORT ?? "2000");

const FILTER_EXPRESSION = process.env.FILTER_EXPRESSION;
const client = new XRayClient({ region: "us-east-2" });

async function fetchTraces() {
const EndTime = new Date();
const StartTime = new Date(EndTime.getTime() - POLLING_INTERVAL_MILLISECONDS); // Fetch traces from the last 60 seconds

// Generator function to yield chunks of specified size
function* batchArray(array: any[], size: number) {
for (let i = 0; i < array.length; i += size) {
yield array.slice(i, i + size);
}
}

try {
for await (const traceSummaries of paginateGetTraceSummaries(
{ client },
Expand All @@ -33,13 +44,6 @@ async function fetchTraces() {
return;
}

// Generator function to yield chunks of specified size
function* batchArray(array: any[], size: number) {
for (let i = 0; i < array.length; i += size) {
yield array.slice(i, i + size);
}
}

console.log("Found", traceIds.length, "traces from xray");

// BatchGetTraces supports a maximum of 5 trace IDs
Expand Down Expand Up @@ -78,8 +82,8 @@ function sendTracesToOtelUdp(traceData: Trace) {
message,
0,
message.length,
2000,
OTEL_COLLECTOR_URL,
OTEL_COLLECTOR_PORT,
OTEL_COLLECTOR_HOSTNAME,
(err) => {
if (err) {
console.error("Error sending trace to daemon:", err);
Expand Down

0 comments on commit 9992ee1

Please sign in to comment.