Skip to content

Commit

Permalink
Export open telemetry traces to gcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanvuong2021 committed Jan 30, 2024
1 parent 2ce875b commit 880e8be
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/main/k8s/dev/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,8 @@ cue_dump(
srcs = ["open_telemetry_gke.cue"],
tags = ["manual"],
deps = [
":base_gke",
":config_gke",
"//src/main/k8s:open_telemetry",
],
)
Expand Down
81 changes: 79 additions & 2 deletions src/main/k8s/dev/open_telemetry_gke.cue
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,91 @@

package k8s

// Name of K8s service account for OpenTelemetry collector.
#CollectorServiceAccount: "internal-reporting-server"

objectSets: [
openTelemetry.collectors,
collectors,
openTelemetry.instrumentations,
openTelemetry.networkPolicies,
networkPolicies,
]

#OpenTelemetryCollector: {
spec: resources: requests: memory: "48Mi"
}

openTelemetry: #OpenTelemetry

collectors: [Name=string]: #OpenTelemetryCollector & {
metadata: name: Name
}

collectors: {
"default": {
spec: {
nodeSelector: #ServiceAccountNodeSelector
serviceAccount: #CollectorServiceAccount
config: """
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:\(#OpenTelemetryReceiverPort)
processors:
batch:
send_batch_size: 200
timeout: 10s
filter:
spans:
exclude:
match_type: strict
attributes:
- key: rpc.method
value: Check
exporters:
prometheus:
send_timestamps: true
endpoint: 0.0.0.0:\(#OpenTelemetryPrometheusExporterPort)
resource_to_telemetry_conversion:
enabled: true
googlecloud:
project: \(#GCloudProject)
trace:
extensions:
health_check:
service:
extensions: [health_check]
pipelines:
traces:
receivers: [otlp]
processors: [batch, filter]
exporters: [googlecloud]
metrics:
receivers: [otlp]
processors: [batch]
exporters: [prometheus]
"""
}
}
}

networkPolicies: [Name=_]: #NetworkPolicy & {
_policyPodSelectorMatchLabels: "app.kubernetes.io/component": "opentelemetry-collector"
_name: Name
}

networkPolicies: {
"opentelemetry-collector": {
_ingresses: {
any: {}
}
_egresses: {
any: {}
}
}
}

5 changes: 4 additions & 1 deletion src/main/k8s/open_telemetry.cue
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ import "encoding/yaml"
env: [
{
name: "OTEL_TRACES_EXPORTER"
value: "none"
value: "otlp"
}, {
name: "OTEL_EXPORTER_OTLP_TRACES_PROTOCOL"
value: "grpc"
}, {
name: "OTEL_EXPORTER_OTLP_ENDPOINT"
value: #OpenTelemetryCollectorEndpoint
Expand Down

0 comments on commit 880e8be

Please sign in to comment.