Skip to content

Commit

Permalink
feat : enable observability
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Dec 24, 2024
1 parent 09c1cb4 commit 373e62f
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ ports:
onOpen: open-browser
- port: 5050
visibility: public
- port: 3000
visibility: public
onOpen: open-browser

vscode:
extensions:
- vscjava.vscode-java-pack
Expand Down
10 changes: 10 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@
"projectName": "rag-springai-ollama-llm",
"args": "",
"envFile": "${workspaceFolder}/.env"
},
{
"type": "java",
"name": "Spring Boot-ChatbotOllamaApplication<chatbot-ollama-springai>",
"request": "launch",
"cwd": "${workspaceFolder}",
"mainClass": "com.example.chatbot.ChatbotOllamaApplication",
"projectName": "chatbot-ollama-springai",
"args": "",
"envFile": "${workspaceFolder}/.env"
}
]
}
20 changes: 19 additions & 1 deletion chatbot/chatbot-ollama-springai/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
version: '3.7'
services:

ollama:
container_name: ollama
image: ollama/ollama:latest
ports:
- '11434:11434'

postgresqldb:
container_name: postgresqldb
image: pgvector/pgvector:pg17
Expand Down Expand Up @@ -41,3 +47,15 @@ services:
- "/bin/sh"
- "-c"
- "/bin/echo 'postgresqldb:5432:*:appuser:secret' > /tmp/pgpassfile && chmod 600 /tmp/pgpassfile && /entrypoint.sh"

lgtm-stack:
image: grafana/otel-lgtm:0.8.1
extra_hosts: [ 'host.docker.internal:host-gateway' ]
container_name: lgtm-stack
environment:
- OTEL_METRIC_EXPORT_INTERVAL=500
ports:
- "3000:3000"
- "4317:4317"
- "4318:4318"
- "9090:9090"
41 changes: 41 additions & 0 deletions chatbot/chatbot-ollama-springai/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<java.version>21</java.version>
<spotless.version>2.43.0</spotless.version>
<spring-ai.version>1.0.0-M5</spring-ai.version>
<otelInstrumentation.version>2.10.0-alpha</otelInstrumentation.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -51,6 +52,34 @@
<optional>true</optional>
</dependency>

<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-otel</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-exporter-otlp</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-otlp</artifactId>
</dependency>
<dependency>
<groupId>net.ttddyy.observation</groupId>
<artifactId>datasource-micrometer-spring-boot</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-logback-appender-1.0</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down Expand Up @@ -81,6 +110,11 @@
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>grafana</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<dependencyManagement>
Expand All @@ -92,6 +126,13 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-instrumentation-bom-alpha</artifactId>
<version>${otelInstrumentation.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.example.chatbot.config;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.servers.Server;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = false)
@OpenAPIDefinition(info = @Info(title = "chatbot-ollama-springai", version = "v1.0.0"), servers = @Server(url = "/"))
class SwaggerConfig {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,29 @@ spring.application.name=chatbot-ollama
spring.threads.virtual.enabled=true
spring.mvc.problemdetails.enabled=true

spring.ai.ollama.init.pull-model-strategy=when_missing
spring.ai.ollama.init.pull-model-strategy=WHEN_MISSING
spring.ai.ollama.chat.options.model=llama3.2
# default is mxbai-embed-large
spring.ai.ollama.embedding.model=nomic-embed-text

#PgVector
spring.ai.vectorstore.pgvector.initialize-schema=true
spring.ai.vectorstore.pgvector.schema-validation=true

##Observability
spring.ai.vectorstore.observations.include-query-response=true
spring.ai.chat.observations.include-completion=true
spring.ai.chat.observations.include-prompt=true
spring.ai.chat.client.observations.include-input=true

management.endpoints.web.exposure.include=*
management.metrics.tags.service.name=${spring.application.name}
management.tracing.sampling.probability=1.0
management.otlp.tracing.endpoint=http://localhost:4318/v1/traces
management.otlp.logging.endpoint=http://localhost:4318/v1/logs

spring.testcontainers.beans.startup=parallel

spring.datasource.url=jdbc:postgresql://localhost:5432/appdb
spring.datasource.username=appuser
spring.datasource.password=secret
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml" />

<appender name="OpenTelemetry"
class="io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender">
<captureExperimentalAttributes>true</captureExperimentalAttributes>
<captureCodeAttributes>true</captureCodeAttributes>
<captureKeyValuePairAttributes>true</captureKeyValuePairAttributes>
</appender>

<root level="INFO">
<appender-ref ref="OpenTelemetry"/>
</root>

</configuration>

0 comments on commit 373e62f

Please sign in to comment.