basic-example

July 3, 2026 · View on GitHub

REST API demonstrating all well-known gen_ai.operation.name values from OTel GenAI Semantic Conventions v1.41.1.

Run

# Edit src/main/resources/application.yml — replace <your-dashscope-api-key> and CMS placeholders

cd examples/basic-example
mvn spring-boot:run

Endpoints

Endpointoperation.name
POST /api/chatchat
POST /api/embeddingembeddings
POST /api/toolexecute_tool
POST /api/agentinvoke_agent
POST /api/workflowinvoke_workflow
POST /api/retrievalretrieval
POST /api/create-agentcreate_agent

Example

curl -X POST http://localhost:8080/api/chat \
  -H "Content-Type: application/json" \
  -d '{"message": "Hello"}'

Configuration: src/main/resources/application.yml

otel-util-genai required settings

PropertyPurposeEnv var
otel.semconv.stability.opt.inEnable GenAI experimental semconvOTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental
otel.instrumentation.genai.capture.message.contentMessage content capture modeOTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=span_and_event
otel.instrumentation.genai.emit.eventEmit OTel Log Events (recommended true)OTEL_INSTRUMENTATION_GENAI_EMIT_EVENT=true

Alibaba Cloud CMS/ARMS GenAI view

When exporting OTLP to CMS, add to OTEL_RESOURCE_ATTRIBUTES:

gen_ai.instrumentation.sdk.name=loongsuite-genai-utils
acs.arms.service.feature=genai_app
acs.cms.workspace=<your-workspace-id>

See comments in application.yml.