Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/lfx-v2-project-service/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ apiVersion: v2
name: lfx-v2-project-service
description: LFX Platform V2 Project Service chart
type: application
version: 0.5.4
version: 0.5.5
appVersion: "latest"
43 changes: 43 additions & 0 deletions charts/lfx-v2-project-service/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,49 @@ spec:
value: {{ .Values.app.skipEtagValidation | quote }}
- name: JWT_AUTH_DISABLED_MOCK_LOCAL_PRINCIPAL
value: {{ .Values.app.jwtAuthDisabledMockLocalPrincipal }}
{{- with .Values.app.extraEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.app.otel.serviceName }}
- name: OTEL_SERVICE_NAME
value: {{ .Values.app.otel.serviceName | quote }}
{{- end }}
{{- if .Values.app.otel.serviceVersion }}
- name: OTEL_SERVICE_VERSION
value: {{ .Values.app.otel.serviceVersion | quote }}
{{- end }}
{{- if .Values.app.otel.endpoint }}
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: {{ .Values.app.otel.endpoint | quote }}
{{- end }}
{{- if .Values.app.otel.protocol }}
- name: OTEL_EXPORTER_OTLP_PROTOCOL
value: {{ .Values.app.otel.protocol | quote }}
{{- end }}
{{- if .Values.app.otel.insecure }}
- name: OTEL_EXPORTER_OTLP_INSECURE
value: {{ .Values.app.otel.insecure | quote }}
{{- end }}
{{- if .Values.app.otel.tracesExporter }}
- name: OTEL_TRACES_EXPORTER
value: {{ .Values.app.otel.tracesExporter | quote }}
{{- end }}
{{- if .Values.app.otel.tracesSampleRatio }}
- name: OTEL_TRACES_SAMPLE_RATIO
value: {{ .Values.app.otel.tracesSampleRatio | quote }}
{{- end }}
{{- if .Values.app.otel.metricsExporter }}
- name: OTEL_METRICS_EXPORTER
value: {{ .Values.app.otel.metricsExporter | quote }}
{{- end }}
{{- if .Values.app.otel.logsExporter }}
- name: OTEL_LOGS_EXPORTER
value: {{ .Values.app.otel.logsExporter | quote }}
{{- end }}
{{- if .Values.app.otel.propagators }}
- name: OTEL_PROPAGATORS
value: {{ .Values.app.otel.propagators | quote }}
{{- end }}
ports:
- containerPort: {{ .Values.service.port }}
name: web
Expand Down
37 changes: 37 additions & 0 deletions charts/lfx-v2-project-service/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,43 @@ app:
jwtAuthDisabledMockLocalPrincipal: ""
# use_oidc_contextualizer is a boolean to determine if the OIDC contextualizer should be used
use_oidc_contextualizer: true
# extraEnv is a list of additional environment variables to set in the container.
# Supports both simple key-value pairs and Kubernetes field references.
extraEnv: []
# otel is the configuration for OpenTelemetry tracing
otel:
# serviceName is the service name for OpenTelemetry resource identification
# (default: "lfx-v2-project-service")
serviceName: ""
# serviceVersion is the service version for OpenTelemetry resource identification
# (default: "1.0.0")
serviceVersion: ""
# protocol specifies the OTLP protocol: "grpc" or "http"
# (default: "grpc")
protocol: "grpc"
# endpoint is the OTLP collector endpoint
# For gRPC: typically "host:4317", for HTTP: typically "host:4318"
endpoint: ""
# insecure disables TLS for the OTLP connection
# Set to "true" for in-cluster communication without TLS
insecure: "false"
# tracesExporter specifies the traces exporter: "otlp" or "none"
# (default: "none")
tracesExporter: "none"
# tracesSampleRatio specifies the sampling ratio for traces (0.0 to 1.0)
# A value of 1.0 means all traces are sampled, 0.5 means 50% are sampled
# (default: "1.0")
tracesSampleRatio: "1.0"
# metricsExporter specifies the metrics exporter: "otlp" or "none"
# (default: "none")
metricsExporter: "none"
# logsExporter specifies the logs exporter: "otlp" or "none"
# (default: "none")
logsExporter: "none"
# propagators specifies the propagators to use, comma-separated
# Supported values: "tracecontext", "baggage", "jaeger"
# (default: "tracecontext,baggage")
propagators: "tracecontext,baggage,jaeger"

# traefik is the configuration for Traefik Gateway API routing
traefik:
Expand Down
18 changes: 18 additions & 0 deletions cmd/project-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

nats "github.com/nats-io/nats.go"
"github.com/nats-io/nats.go/jetstream"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
goahttp "goa.design/goa/v3/http"

genhttp "github.com/linuxfoundation/lfx-v2-project-service/api/project/v1/gen/http/project_service/server"
Expand All @@ -29,6 +30,7 @@ import (
"github.com/linuxfoundation/lfx-v2-project-service/internal/middleware"
"github.com/linuxfoundation/lfx-v2-project-service/internal/service"
"github.com/linuxfoundation/lfx-v2-project-service/pkg/constants"
"github.com/linuxfoundation/lfx-v2-project-service/pkg/utils"
)

const (
Expand All @@ -46,6 +48,20 @@ func main() {

log.InitStructureLogConfig()

// Set up OpenTelemetry SDK.
ctx := context.Background()
otelConfig := utils.OTelConfigFromEnv()
otelShutdown, err := utils.SetupOTelSDKWithConfig(ctx, otelConfig)
if err != nil {
slog.With(errKey, err).Error("error setting up OpenTelemetry SDK")
os.Exit(1)
}
defer func() {
if shutdownErr := otelShutdown(context.Background()); shutdownErr != nil {
slog.With(errKey, shutdownErr).Error("error shutting down OpenTelemetry SDK")
}
}()

// Set up JWT validator needed by the [ProjectsService.JWTAuth] security handler.
jwtAuthConfig := auth.JWTAuthConfig{
JWKSURL: os.Getenv("JWKS_URL"),
Expand Down Expand Up @@ -200,6 +216,8 @@ func setupHTTPServer(flags flags, svc *ProjectsAPI, gracefulCloseWG *sync.WaitGr
handler = middleware.RequestLoggerMiddleware()(handler)
handler = middleware.RequestIDMiddleware()(handler)
handler = middleware.AuthorizationMiddleware()(handler)
// Wrap the handler with OpenTelemetry instrumentation
handler = otelhttp.NewHandler(handler, "project-service")

// Set up http listener in a goroutine using provided command line parameters.
var addr string
Expand Down
32 changes: 31 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,23 @@ require (
github.com/go-viper/mapstructure/v2 v2.4.0
github.com/google/uuid v1.6.0
github.com/nats-io/nats.go v1.47.0
github.com/remychantenay/slog-otel v1.3.4
github.com/rustyoz/svg v0.0.0-20250705135709-8b1786137cb3
github.com/stretchr/testify v1.11.1
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0
go.opentelemetry.io/contrib/propagators/jaeger v1.39.0
go.opentelemetry.io/otel v1.39.0
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.15.0
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.15.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.39.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.39.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.39.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.39.0
go.opentelemetry.io/otel/log v0.15.0
go.opentelemetry.io/otel/sdk v1.39.0
go.opentelemetry.io/otel/sdk/log v0.15.0
go.opentelemetry.io/otel/sdk/metric v1.39.0
go.opentelemetry.io/otel/trace v1.39.0
goa.design/goa/v3 v3.22.6
golang.org/x/sync v0.18.0
)
Expand All @@ -36,11 +51,17 @@ require (
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.8 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.41.1 // indirect
github.com/aws/smithy-go v1.23.2 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dimfeld/httppath v0.0.0-20170720192232-ee938bf73598 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-chi/chi/v5 v5.2.3 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gohugoio/hashstructure v0.6.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 // indirect
github.com/klauspost/compress v1.18.1 // indirect
github.com/manveru/faker v0.0.0-20171103152722-9fbc68a78c4d // indirect
github.com/nats-io/nkeys v0.4.11 // indirect
Expand All @@ -49,11 +70,20 @@ require (
github.com/rustyoz/Mtransform v0.0.0-20250628105438-00796a985d0a // indirect
github.com/rustyoz/genericlexer v0.0.0-20250522144106-d3cfee480384 // indirect
github.com/stretchr/objx v0.5.3 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0 // indirect
go.opentelemetry.io/otel/metric v1.39.0 // indirect
go.opentelemetry.io/proto/otlp v1.9.0 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/mod v0.30.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/sys v0.39.0 // indirect
golang.org/x/text v0.31.0 // indirect
golang.org/x/tools v0.39.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/grpc v1.77.0 // indirect
google.golang.org/protobuf v1.36.10 // indirect
gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading