feat: add OpenTelemetry-aware scaffolding to new:lambda, new:service and new:domain [DEV-542]#203
Merged
Merged
Conversation
…folding - new:lambda auto-detects OTEL vs X-Ray by reading the parent service's serverless.yml build tag; bootstrap templates branch on UseOtel for all lambda types (plain, http, sqs, cron, snssqs, custom) - new:service always generates OTEL config: build tag "lambda.norpc,otel", tracing disabled, otelFunctionLayers, ADOT collector layer, and all required DD_* / OTEL_* environment variables - new:domain service layer uses oteltracer.StartSpan(); repository layer removes X-Ray spans (driver instrumentation handles them automatically) - adds 29 template syntax tests covering all lambda types x OTEL/X-Ray, service templates, and domain templates (postgres + dynamo)
…alphabetically
- all lambda-config.yml templates now include layers: \${self:custom.otelFunctionLayers}
when UseOtel is true, required for ADOT collector and DD extension to attach
- Select input now sorts options alphabetically before rendering, making
service and type lists consistent and easier to navigate
danteay
approved these changes
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Scaffolding commands in draft-cli had X-Ray tracing hardcoded across all generated templates, making them incompatible with services already migrated to OpenTelemetry. This PR aligns the scaffolding output with the observability standard established in the api repo: OTEL for new services and domains, and smart auto-detection for lambdas added to existing services.
Task Context
What is the current behavior?
new:servicealways generatesserverless.ymlwith X-Ray tracing (tracing: lambda: true), theserverless-plugin-datadogplugin, and no OTEL environment variables or ADOT collector layer.new:lambdaalways generates bootstrap handlers usingtracer.BeginSubSegmentfromframev2/pkg/tracer, regardless of whether the target service uses OTEL or X-Ray.new:domaingenerates service and repository layers withtracer.BeginSubSegmentthroughout, including repository methods where the DB driver already instruments automatically.What is the new behavior?
new:service— always OTEL:serverless.ymluses build tag"lambda.norpc,otel", setstracing: false/false, configuresotelFunctionLayers(ADOT collector + DD Extension), and removesserverless-plugin-datadog.environment.ymlincludes all requiredDD_*andOTEL_*variables.config/otel-layer/collector.yamlwith the ADOT → Datadog pipeline.layers: ${self:custom.otelFunctionLayers}in itslambda-config.yml.new:lambda— smart detection:serverless.ymland checks for the"lambda.norpc,otel"build tag viaproject.IsOtelService().oteltracer.StartSpan()with domain/layer attributes andlayersinlambda-config.yml.tracer.BeginSubSegment()(existing behavior preserved).new:domain— always OTEL:oteltracer.StartSpan()withServiceSpanName,Domain, andLayerattributes.Select prompts:
Additional Context
Adds 29 template syntax tests in
internal/templates/templates_test.gothat render every template with representative inputs and validate the output usinggo/parser(Go files) andgopkg.in/yaml.v3(YAML files). No files are written to disk — all validation happens in memory. Tests cover all lambda types × OTEL/X-Ray, service templates, and domain templates (postgres + dynamo).